From 94e4d69dee22bc53acfe6da006db467dae561b69 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Fri, 22 Nov 2024 23:51:10 +0100 Subject: [PATCH] ADL for AlmostEqual* and use math:: instead of base:: Signed-off-by: Alexander Borsuk --- .../main/cpp/app/organicmaps/Framework.cpp | 2 +- base/base_tests/cache_test.cpp | 10 +-- base/base_tests/cancellable_tests.cpp | 4 +- base/base_tests/levenshtein_dfa_test.cpp | 4 +- base/base_tests/math_test.cpp | 77 ++++++++++--------- base/math.cpp | 9 +-- base/math.hpp | 10 ++- base/matrix.hpp | 2 +- base/rolling_hash.hpp | 2 +- base/sunrise_sunset.cpp | 12 +-- .../geometry_serialization_test.cpp | 2 +- coding/coding_tests/point_coding_tests.cpp | 2 +- coding/coding_tests/traffic_test.cpp | 14 ++-- coding/geometry_coding.cpp | 4 +- coding/point_coding.cpp | 2 +- coding/point_coding.hpp | 2 +- drape/color.hpp | 6 +- drape/cpu_buffer.cpp | 2 +- drape/drape_tests/stipple_pen_tests.cpp | 8 +- drape/stipple_pen_resource.cpp | 2 +- drape/texture_manager.cpp | 4 +- drape/texture_of_colors.cpp | 2 +- drape/vulkan/vulkan_memory_manager.cpp | 6 +- drape_frontend/animation/interpolators.cpp | 2 +- drape_frontend/apply_feature_functors.cpp | 2 +- .../drape_frontend_tests/navigator_test.cpp | 4 +- drape_frontend/gps_track_renderer.cpp | 4 +- drape_frontend/gui/compass.cpp | 4 +- drape_frontend/gui/ruler_helper.cpp | 4 +- drape_frontend/line_shape_helper.cpp | 2 +- drape_frontend/my_position_controller.cpp | 4 +- drape_frontend/route_shape.cpp | 4 +- drape_frontend/traffic_renderer.cpp | 2 +- drape_frontend/transit_scheme_builder.cpp | 6 +- drape_frontend/user_event_stream.cpp | 2 +- drape_frontend/user_mark_shapes.cpp | 2 +- drape_frontend/visual_params.cpp | 16 ++-- editor/server_api.cpp | 2 +- ge0/ge0_tests/parser_tests.cpp | 2 +- generator/borders.cpp | 2 +- generator/borders.hpp | 6 +- generator/composite_id.hpp | 2 +- generator/feature_builder.cpp | 2 +- generator/feature_helpers.hpp | 10 +-- .../feature_segments_checker.cpp | 2 +- .../collector_boundary_postcode_tests.cpp | 2 +- ...ollector_routing_city_boundaries_tests.cpp | 8 +- .../generator_tests/mini_roundabout_tests.cpp | 22 +++--- .../generator_tests/osm_o5m_source_test.cpp | 4 +- .../generator_tests/raw_generator_test.cpp | 2 +- .../generator_tests/speed_cameras_test.cpp | 6 +- generator/hierarchy_entry.cpp | 2 +- generator/mini_roundabout_transformer.cpp | 8 +- generator/osm2meta.cpp | 2 +- generator/osm2type.cpp | 2 +- generator/osm_element.cpp | 4 +- generator/place_processor.cpp | 2 +- generator/restriction_collector.cpp | 6 +- generator/tesselator.cpp | 8 +- generator/tesselator.hpp | 2 +- geometry/angles.cpp | 2 +- geometry/area_on_earth.cpp | 11 +-- geometry/avg_vector.hpp | 2 +- geometry/circle_on_earth.cpp | 12 +-- geometry/covering_utils.hpp | 4 +- geometry/distance_on_sphere.cpp | 6 +- geometry/geometry_tests/angle_test.cpp | 8 +- .../geometry_tests/circle_on_earth_tests.cpp | 2 +- .../intersection_score_tests.cpp | 10 +-- .../parametrized_segment_tests.cpp | 8 +- geometry/geometry_tests/point3d_tests.cpp | 2 +- geometry/geometry_tests/point_test.cpp | 22 +++--- geometry/geometry_tests/polyline_tests.cpp | 2 +- geometry/geometry_tests/region_tests.cpp | 2 +- geometry/geometry_tests/screen_test.cpp | 8 +- geometry/geometry_tests/vector_test.cpp | 2 +- geometry/latlon.cpp | 15 ++-- geometry/latlon.hpp | 23 +++--- geometry/mercator.cpp | 10 +-- geometry/mercator.hpp | 12 +-- geometry/oblate_spheroid.cpp | 3 +- geometry/parametrized_segment.hpp | 2 +- geometry/point2d.hpp | 53 +++++-------- geometry/point3d.hpp | 17 ++-- geometry/polygon.hpp | 8 +- geometry/rect2d.hpp | 4 +- geometry/region2d.hpp | 8 +- geometry/screenbase.cpp | 6 +- geometry/screenbase.hpp | 4 +- indexer/cell_id.hpp | 8 +- indexer/feature_impl.cpp | 2 +- indexer/ftypes_matcher.cpp | 2 +- indexer/indexer_tests/trie_test.cpp | 2 +- indexer/scales.cpp | 4 +- .../SideButtons/MWMSideButtonsView.mm | 2 +- iphone/Maps/Core/Location/location_util.h | 4 +- map/bookmark_manager.cpp | 2 +- map/chart_generator.cpp | 2 +- map/extrapolation/extrapolator.cpp | 4 +- .../extrapolation_benchmark.cpp | 2 +- map/framework.cpp | 2 +- map/map_tests/bookmarks_test.cpp | 12 +-- map/map_tests/chart_generator_tests.cpp | 12 +-- map/map_tests/extrapolator_tests.cpp | 14 ++-- map/map_tests/mwm_url_tests.cpp | 4 +- map/routing_manager.cpp | 6 +- map/track.cpp | 4 +- openlr/candidate_paths_getter.cpp | 4 +- openlr/openlr_decoder.cpp | 6 +- openlr/openlr_model_xml.cpp | 4 +- openlr/router.cpp | 12 +-- openlr/score_candidate_paths_getter.cpp | 4 +- platform/distance.cpp | 2 +- platform/measurement_utils.cpp | 6 +- platform/platform_tests/measurement_tests.cpp | 16 ++-- platform/utm_mgrs_utils.cpp | 10 +-- poly_borders/borders_data.cpp | 6 +- .../remove_empty_spaces_tests.cpp | 2 +- qt/qt_common/qtoglcontext.cpp | 4 +- qt/qt_common/scale_slider.cpp | 2 +- routing/base/astar_progress.cpp | 4 +- routing/car_directions.cpp | 2 +- routing/cross_mwm_index_graph.hpp | 2 +- routing/directions_engine.cpp | 2 +- routing/fake_ending.cpp | 2 +- routing/features_road_graph.cpp | 2 +- routing/geometry.cpp | 2 +- routing/index_router.cpp | 2 +- routing/road_graph.hpp | 2 +- routing/route.cpp | 4 +- routing/route.hpp | 2 +- routing/route_weight.hpp | 4 +- routing/routing_benchmarks/helpers.cpp | 6 +- .../get_altitude_test.cpp | 2 +- .../routing_test_tools.cpp | 6 +- .../routing_quality_tool/benchmark_stat.cpp | 6 +- .../routing_quality_tool/utils.hpp | 4 +- routing/routing_session.cpp | 8 +- routing/routing_tests/astar_router_test.cpp | 6 +- .../checkpoint_predictor_test.cpp | 4 +- .../cross_border_graph_tests.cpp | 4 +- routing/routing_tests/index_graph_test.cpp | 2 +- routing/routing_tests/index_graph_tools.cpp | 8 +- .../position_accumulator_tests.cpp | 18 ++--- .../routing_tests/routing_session_test.cpp | 8 +- routing/routing_tests/speed_cameras_tests.cpp | 2 +- routing/routing_tests/turns_sound_test.cpp | 12 +-- routing/turn_candidate.hpp | 2 +- routing/turns_generator.cpp | 4 +- routing/turns_generator_utils.cpp | 4 +- routing/turns_sound_settings.cpp | 4 +- .../vehicle_model_test.cpp | 4 +- search/house_detector.cpp | 2 +- .../postcode_points_tests.cpp | 16 ++-- .../pre_ranker_test.cpp | 2 +- .../search_quality_tool.cpp | 4 +- search/search_tests/latlon_match_test.cpp | 2 +- .../utm_mgrs_coords_match_test.cpp | 4 +- search/street_vicinity_loader.cpp | 2 +- search/utm_mgrs_coords_match.cpp | 4 +- storage/storage_tests/helpers.cpp | 8 +- testing/testing.hpp | 12 +-- .../track_analyzer/cmd_balance_csv.cpp | 2 +- tracking/tracking_tests/protocol_test.cpp | 4 +- tracking/tracking_tests/reporter_test.cpp | 4 +- traffic/pytraffic/bindings.cpp | 8 +- traffic/speed_groups.cpp | 2 +- transit/transit_tests/transit_tools.hpp | 6 +- transit/transit_types.cpp | 8 +- transit/world_feed/feed_helpers.cpp | 8 +- transit/world_feed/subway_converter.cpp | 12 +-- .../world_feed_tests/world_feed_tests.cpp | 10 +-- 172 files changed, 518 insertions(+), 534 deletions(-) diff --git a/android/app/src/main/cpp/app/organicmaps/Framework.cpp b/android/app/src/main/cpp/app/organicmaps/Framework.cpp index d1ec74cc4a..69c68577f6 100644 --- a/android/app/src/main/cpp/app/organicmaps/Framework.cpp +++ b/android/app/src/main/cpp/app/organicmaps/Framework.cpp @@ -132,7 +132,7 @@ void Framework::OnLocationUpdated(location::GpsInfo const & info) void Framework::OnCompassUpdated(location::CompassInfo const & info, bool forceRedraw) { - static double const COMPASS_THRESHOLD = base::DegToRad(1.0); + static double const COMPASS_THRESHOLD = math::DegToRad(1.0); /// @todo Do not emit compass bearing too often. /// Need to make more experiments in future. diff --git a/base/base_tests/cache_test.cpp b/base/base_tests/cache_test.cpp index 4d3a4521d3..013d8acacb 100644 --- a/base/base_tests/cache_test.cpp +++ b/base/base_tests/cache_test.cpp @@ -119,30 +119,30 @@ UNIT_TEST(CacheSmoke_3) base::CacheWithStat cache(3); // it contains 2^3=8 elements // 0 access, cache miss is 0 - TEST(base::AlmostEqualAbs(0.0, cache.GetCacheMiss(), kEpsilon), ()); + TEST(AlmostEqualAbs(0.0, cache.GetCacheMiss(), kEpsilon), ()); bool found = true; cache.Find(1, found); TEST(!found, ()); // 1 access, 1 miss, cache miss = 1/1 = 1 - TEST(base::AlmostEqualAbs(1.0, cache.GetCacheMiss(), kEpsilon), ()); + TEST(AlmostEqualAbs(1.0, cache.GetCacheMiss(), kEpsilon), ()); found = false; cache.Find(1, found); TEST(found, ()); // 2 access, 1 miss, cache miss = 1/2 = 0.5 - TEST(base::AlmostEqualAbs(0.5, cache.GetCacheMiss(), kEpsilon), ()); + TEST(AlmostEqualAbs(0.5, cache.GetCacheMiss(), kEpsilon), ()); found = false; cache.Find(2, found); TEST(!found, ()); // 3 access, 2 miss, cache miss = 2/3 = 0.6(6) - TEST(base::AlmostEqualAbs(2.0/3.0, cache.GetCacheMiss(), kEpsilon), ()); + TEST(AlmostEqualAbs(2.0/3.0, cache.GetCacheMiss(), kEpsilon), ()); cache.Reset(); // 0 access, cache miss is 0 - TEST(base::AlmostEqualAbs(0.0, cache.GetCacheMiss(), kEpsilon), ()); + TEST(AlmostEqualAbs(0.0, cache.GetCacheMiss(), kEpsilon), ()); } UNIT_TEST(CacheSmoke_4) diff --git a/base/base_tests/cancellable_tests.cpp b/base/base_tests/cancellable_tests.cpp index af0fc161a7..97bb42979b 100644 --- a/base/base_tests/cancellable_tests.cpp +++ b/base/base_tests/cancellable_tests.cpp @@ -40,7 +40,7 @@ UNIT_TEST(Cancellable_Smoke) TEST(cancellable.IsCancelled(), ()); TEST_EQUAL(cancellable.CancellationStatus(), Cancellable::Status::CancelCalled, ()); - TEST(base::AlmostEqualAbs(x, 0.739, 1e-3), ()); + TEST(AlmostEqualAbs(x, 0.739, 1e-3), ()); } UNIT_TEST(Cancellable_Deadline) @@ -72,7 +72,7 @@ UNIT_TEST(Cancellable_Deadline) TEST(cancellable.IsCancelled(), ()); TEST_EQUAL(cancellable.CancellationStatus(), Cancellable::Status::DeadlineExceeded, ()); - TEST(base::AlmostEqualAbs(x, 0.739, 1e-3), ()); + TEST(AlmostEqualAbs(x, 0.739, 1e-3), ()); cancellable.Cancel(); TEST(cancellable.IsCancelled(), ()); diff --git a/base/base_tests/levenshtein_dfa_test.cpp b/base/base_tests/levenshtein_dfa_test.cpp index 6744059bcf..33aed94143 100644 --- a/base/base_tests/levenshtein_dfa_test.cpp +++ b/base/base_tests/levenshtein_dfa_test.cpp @@ -270,12 +270,12 @@ UNIT_TEST(LevenshteinDFA_PrefixDFASmoke) auto generate = [](vector const & alphabet, size_t size, vector & result) { result.clear(); - result.resize(base::PowUint(alphabet.size(), size)); + result.resize(math::PowUint(alphabet.size(), size)); for (size_t letterNumber = 0; letterNumber < size; ++letterNumber) { for (size_t i = 0; i < result.size(); ++i) { - auto const letterIndex = (i / base::PowUint(alphabet.size(), size - letterNumber - 1)) % alphabet.size(); + auto const letterIndex = (i / math::PowUint(alphabet.size(), size - letterNumber - 1)) % alphabet.size(); result[i].push_back(alphabet[letterIndex]); } } diff --git a/base/base_tests/math_test.cpp b/base/base_tests/math_test.cpp index 2be6f69c5b..10256b36ff 100644 --- a/base/base_tests/math_test.cpp +++ b/base/base_tests/math_test.cpp @@ -6,6 +6,10 @@ #include +namespace math_test +{ +using namespace math; + namespace { // Returns the next representable floating point value without using conversion to integer. @@ -29,12 +33,12 @@ void TestMaxULPs() Float y = x; for (unsigned int i = 0; i <= maxULPs; ++i) { - TEST(base::AlmostEqualULPs(x, y, maxULPs), (x, y, maxULPs, x - y, dir)); + TEST(AlmostEqualULPs(x, y, maxULPs), (x, y, maxULPs, x - y, dir)); Float const nextY = NextFloat(y, dir); TEST_NOT_EQUAL(y, nextY, (i, base, dir)); y = nextY; } - TEST(!base::AlmostEqualULPs(x, y, maxULPs), (x, y, maxULPs, x - y)); + TEST(!AlmostEqualULPs(x, y, maxULPs), (x, y, maxULPs, x - y)); } } } @@ -43,7 +47,7 @@ void TestMaxULPs() UNIT_TEST(PowUInt) { - TEST_EQUAL(base::PowUint(3, 10), 59049, ()); + TEST_EQUAL(PowUint(3, 10), 59049, ()); } UNIT_TEST(AlmostEqualULPs_double) @@ -64,10 +68,10 @@ UNIT_TEST(AlmostEqualULPs_double) TEST_ALMOST_EQUAL_ULPS(1.0/dmax, 1.0/dmax, ()); TEST_ALMOST_EQUAL_ULPS(-1.0/dmax, -1.0/dmax, ()); - TEST(!base::AlmostEqualULPs(1.0, -1.0), ()); - TEST(!base::AlmostEqualULPs(2.0, -2.0), ()); - TEST(!base::AlmostEqualULPs(dmax, -dmax), ()); - TEST(!base::AlmostEqualULPs(0.0, eps), ()); + TEST(!AlmostEqualULPs(1.0, -1.0), ()); + TEST(!AlmostEqualULPs(2.0, -2.0), ()); + TEST(!AlmostEqualULPs(dmax, -dmax), ()); + TEST(!AlmostEqualULPs(0.0, eps), ()); } UNIT_TEST(AlmostEqualULPs_float) @@ -88,10 +92,10 @@ UNIT_TEST(AlmostEqualULPs_float) TEST_ALMOST_EQUAL_ULPS(1.0f/dmax, 1.0f/dmax, ()); TEST_ALMOST_EQUAL_ULPS(-1.0f/dmax, -1.0f/dmax, ()); - TEST(!base::AlmostEqualULPs(1.0f, -1.0f), ()); - TEST(!base::AlmostEqualULPs(2.0f, -2.0f), ()); - TEST(!base::AlmostEqualULPs(dmax, -dmax), ()); - TEST(!base::AlmostEqualULPs(0.0f, eps), ()); + TEST(!AlmostEqualULPs(1.0f, -1.0f), ()); + TEST(!AlmostEqualULPs(2.0f, -2.0f), ()); + TEST(!AlmostEqualULPs(dmax, -dmax), ()); + TEST(!AlmostEqualULPs(0.0f, eps), ()); } UNIT_TEST(AlmostEqual_Smoke) @@ -99,15 +103,15 @@ UNIT_TEST(AlmostEqual_Smoke) double constexpr small = 1e-18; double constexpr eps = 1e-10; - TEST(base::AlmostEqualAbs(0.0, 0.0 + small, eps), ()); - TEST(!base::AlmostEqualRel(0.0, 0.0 + small, eps), ()); - TEST(!base::AlmostEqualULPs(0.0, 0.0 + small), ()); + TEST(AlmostEqualAbs(0.0, 0.0 + small, eps), ()); + TEST(!AlmostEqualRel(0.0, 0.0 + small, eps), ()); + TEST(!AlmostEqualULPs(0.0, 0.0 + small), ()); - TEST(base::AlmostEqualAbs(1.0, 1.0 + small, eps), ()); - TEST(base::AlmostEqualRel(1.0, 1.0 + small, eps), ()); - TEST(base::AlmostEqualULPs(1.0, 1.0 + small), ()); + TEST(AlmostEqualAbs(1.0, 1.0 + small, eps), ()); + TEST(AlmostEqualRel(1.0, 1.0 + small, eps), ()); + TEST(AlmostEqualULPs(1.0, 1.0 + small), ()); - TEST(base::AlmostEqualRel(123456789.0, 123456780.0, 1e-7), ()); + TEST(AlmostEqualRel(123456789.0, 123456780.0, 1e-7), ()); } UNIT_TEST(AlmostEqualULPs_MaxULPs_double) @@ -135,32 +139,33 @@ UNIT_TEST(TEST_FLOAT_DOUBLE_EQUAL_macros) UNIT_TEST(GCD) { - TEST_EQUAL(base::GCD(6, 3), 3, ()); - TEST_EQUAL(base::GCD(14, 7), 7, ()); - TEST_EQUAL(base::GCD(100, 100), 100, ()); - TEST_EQUAL(base::GCD(7, 3), 1, ()); - TEST_EQUAL(base::GCD(8, 3), 1, ()); - TEST_EQUAL(base::GCD(9, 3), 3, ()); + TEST_EQUAL(GCD(6, 3), 3, ()); + TEST_EQUAL(GCD(14, 7), 7, ()); + TEST_EQUAL(GCD(100, 100), 100, ()); + TEST_EQUAL(GCD(7, 3), 1, ()); + TEST_EQUAL(GCD(8, 3), 1, ()); + TEST_EQUAL(GCD(9, 3), 3, ()); } UNIT_TEST(LCM) { - TEST_EQUAL(base::LCM(6, 3), 6, ()); - TEST_EQUAL(base::LCM(14, 7), 14, ()); - TEST_EQUAL(base::LCM(100, 100), 100, ()); - TEST_EQUAL(base::LCM(7, 3), 21, ()); - TEST_EQUAL(base::LCM(8, 3), 24, ()); - TEST_EQUAL(base::LCM(9, 3), 9, ()); + TEST_EQUAL(LCM(6, 3), 6, ()); + TEST_EQUAL(LCM(14, 7), 14, ()); + TEST_EQUAL(LCM(100, 100), 100, ()); + TEST_EQUAL(LCM(7, 3), 21, ()); + TEST_EQUAL(LCM(8, 3), 24, ()); + TEST_EQUAL(LCM(9, 3), 9, ()); } UNIT_TEST(Sign) { - TEST_EQUAL(1, base::Sign(1), ()); - TEST_EQUAL(1, base::Sign(10.4), ()); + TEST_EQUAL(1, Sign(1), ()); + TEST_EQUAL(1, Sign(10.4), ()); - TEST_EQUAL(0, base::Sign(0), ()); - TEST_EQUAL(0, base::Sign(0.0), ()); + TEST_EQUAL(0, Sign(0), ()); + TEST_EQUAL(0, Sign(0.0), ()); - TEST_EQUAL(-1, base::Sign(-11), ()); - TEST_EQUAL(-1, base::Sign(-10.4), ()); + TEST_EQUAL(-1, Sign(-11), ()); + TEST_EQUAL(-1, Sign(-10.4), ()); } +} // namespace math_test \ No newline at end of file diff --git a/base/math.cpp b/base/math.cpp index c3f875d35c..bc1075aeb8 100644 --- a/base/math.cpp +++ b/base/math.cpp @@ -5,9 +5,6 @@ #include #include -namespace base -{ - template bool AlmostEqualULPs(Float x, Float y, uint32_t maxULPs) { @@ -38,14 +35,12 @@ bool AlmostEqualULPs(Float x, Float y, uint32_t maxULPs) // Calculate diff with special case to avoid IntType overflow. UIntType diff; if ((xInt >= 0) == (yInt >= 0)) - diff = Abs(xInt - yInt); + diff = math::Abs(xInt - yInt); else - diff = UIntType(Abs(xInt)) + UIntType(Abs(yInt)); + diff = UIntType(math::Abs(xInt)) + UIntType(math::Abs(yInt)); return diff <= maxULPs; } template bool AlmostEqualULPs(float x, float y, uint32_t maxULPs); template bool AlmostEqualULPs(double x, double y, uint32_t maxULPs); - -} // namespace base diff --git a/base/math.hpp b/base/math.hpp index 357f6f7a1c..e7d05b9fbe 100644 --- a/base/math.hpp +++ b/base/math.hpp @@ -12,10 +12,7 @@ namespace math double constexpr pi = 3.14159265358979323846; double constexpr pi2 = pi / 2.0; double constexpr pi4 = pi / 4.0; -} // namespace math -namespace base -{ template T Abs(T x) { @@ -30,6 +27,7 @@ int constexpr Sign(Number const number) noexcept { return number == 0 ? 0 : number > 0 ? 1 : -1; } +} // namespace math // Compare floats or doubles for almost equality. // maxULPs - number of closest floating point values that are considered equal. @@ -39,6 +37,7 @@ int constexpr Sign(Number const number) noexcept // This function is deprecated. Use AlmostEqualAbs, AlmostEqualRel or AlmostEqualAbsOrRel instead. // See https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ // for details. +// NOTE: Intentionally in the global namespace for ADL (see point2d.hpp) template bool AlmostEqualULPs(Float x, Float y, uint32_t maxULPs = 256); @@ -47,6 +46,7 @@ bool AlmostEqualULPs(Float x, Float y, uint32_t maxULPs = 256); // The default value for eps is deliberately not provided: the intended usage // is for the client to choose the precision according to the problem domain, // explicitly define the precision constant and call this function. +// NOTE: Intentionally in the global namespace for ADL (see point2d.hpp) template bool AlmostEqualAbs(Float x, Float y, Float eps) { @@ -69,6 +69,8 @@ bool AlmostEqualAbsOrRel(Float x, Float y, Float eps) return AlmostEqualAbs(x, y, eps) || AlmostEqualRel(x, y, eps); } +namespace math +{ template Float constexpr DegToRad(Float deg) { @@ -171,4 +173,4 @@ size_t Hash(T1 const & t1, T2 const & t2) /// @todo Probably, we need better hash for 2 integral types. return (std::hash()(t1) ^ (std::hash()(t2) << 1)); } -} // namespace base +} // namespace math diff --git a/base/matrix.hpp b/base/matrix.hpp index ec511a1495..3d574f8c94 100644 --- a/base/matrix.hpp +++ b/base/matrix.hpp @@ -68,7 +68,7 @@ namespace math { for (size_t i = 0; i < Rows; ++i) for (size_t j = 0; j < Cols; ++j) - if (base::Abs(m_data[i * Cols + j] - m(i, j)) > eps) + if (Abs(m_data[i * Cols + j] - m(i, j)) > eps) return false; return true; diff --git a/base/rolling_hash.hpp b/base/rolling_hash.hpp index daaddc1678..2637898713 100644 --- a/base/rolling_hash.hpp +++ b/base/rolling_hash.hpp @@ -23,7 +23,7 @@ public: { ASSERT_GREATER(m_windowSize, 0, ()); m_windowSize = windowSize; - m_removeMultiplier = base::PowUint(m_multiplier, m_windowSize - 1); + m_removeMultiplier = math::PowUint(m_multiplier, m_windowSize - 1); #ifdef DEBUG while (!m_queue.empty()) m_queue.pop(); #endif diff --git a/base/sunrise_sunset.cpp b/base/sunrise_sunset.cpp index 09d7e77e1d..fc4bc0e074 100644 --- a/base/sunrise_sunset.cpp +++ b/base/sunrise_sunset.cpp @@ -118,13 +118,13 @@ std::pair CalculateDayEventTime(time_t timeUtc, // 4. calculate the Sun's true longitude - double L = M + (1.916 * sin(base::DegToRad(M))) + (0.020 * sin(2 * base::DegToRad(M))) + 282.634; + double L = M + (1.916 * sin(math::DegToRad(M))) + (0.020 * sin(2 * math::DegToRad(M))) + 282.634; // NOTE: L potentially needs to be adjusted into the range [0,360) by adding/subtracting 360 L = NormalizeAngle(L); // 5a. calculate the Sun's right ascension - double RA = base::RadToDeg( atan(0.91764 * tan(base::DegToRad(L))) ); + double RA = math::RadToDeg( atan(0.91764 * tan(math::DegToRad(L))) ); // NOTE: RA potentially needs to be adjusted into the range [0,360) by adding/subtracting 360 RA = NormalizeAngle(RA); @@ -140,12 +140,12 @@ std::pair CalculateDayEventTime(time_t timeUtc, // 6. calculate the Sun's declination - double sinDec = 0.39782 * sin(base::DegToRad(L)); + double sinDec = 0.39782 * sin(math::DegToRad(L)); double cosDec = cos(asin(sinDec)); // 7a. calculate the Sun's local hour angle - double cosH = (cos(base::DegToRad(kZenith)) - (sinDec * sin(base::DegToRad(latitude)))) / (cosDec * cos(base::DegToRad(latitude))); + double cosH = (cos(math::DegToRad(kZenith)) - (sinDec * sin(math::DegToRad(latitude)))) / (cosDec * cos(math::DegToRad(latitude))); // if cosH > 1 then sun is never rises on this location on specified date (polar night) // if cosH < -1 then sun is never sets on this location on specified date (polar day) @@ -163,9 +163,9 @@ std::pair CalculateDayEventTime(time_t timeUtc, double H = 0; if (sunrise) - H = 360 - base::RadToDeg(acos(cosH)); + H = 360 - math::RadToDeg(acos(cosH)); else - H = base::RadToDeg(acos(cosH)); + H = math::RadToDeg(acos(cosH)); H = H / 15; diff --git a/coding/coding_tests/geometry_serialization_test.cpp b/coding/coding_tests/geometry_serialization_test.cpp index 05e592e7f1..2fb98529ad 100644 --- a/coding/coding_tests/geometry_serialization_test.cpp +++ b/coding/coding_tests/geometry_serialization_test.cpp @@ -19,7 +19,7 @@ namespace { bool IsEqual(double d1, double d2) { - return base::AlmostEqualAbs(d1, d2, kMwmPointAccuracy); + return AlmostEqualAbs(d1, d2, kMwmPointAccuracy); } bool IsEqual(m2::PointD const & p1, m2::PointD const & p2) diff --git a/coding/coding_tests/point_coding_tests.cpp b/coding/coding_tests/point_coding_tests.cpp index 1a642bd229..a061367c22 100644 --- a/coding/coding_tests/point_coding_tests.cpp +++ b/coding/coding_tests/point_coding_tests.cpp @@ -102,7 +102,7 @@ UNIT_TEST(PointDToPointU_WithLimitRect) auto const pt = m2::PointD(distX(rng), distY(rng)); auto const pointU = PointDToPointU(pt, coordBits, limitRect); auto const pointD = PointUToPointD(pointU, coordBits, limitRect); - TEST(base::AlmostEqualAbs(pt, pointD, kEps), (limitRect, pt, pointD, coordBits, kEps)); + TEST(AlmostEqualAbs(pt, pointD, kEps), (limitRect, pt, pointD, coordBits, kEps)); } } } diff --git a/coding/coding_tests/traffic_test.cpp b/coding/coding_tests/traffic_test.cpp index 1cc22f24ba..3c6dcd3a04 100644 --- a/coding/coding_tests/traffic_test.cpp +++ b/coding/coding_tests/traffic_test.cpp @@ -12,10 +12,10 @@ #include #include -using namespace std; - -namespace coding +namespace traffic_test { +using std::vector; + double CalculateLength(vector const & path) { double res = 0; @@ -30,7 +30,7 @@ double CalculateLength(vector const & path) void Test(vector & points) { - double const kEps = 1e-5; + double constexpr kEps = 1e-5; for (uint32_t version = 0; version <= TrafficGPSEncoder::kLatestVersion; ++version) { @@ -48,9 +48,9 @@ void Test(vector & points) { TEST_EQUAL(points[i].m_timestamp, result[i].m_timestamp, (points[i].m_timestamp, result[i].m_timestamp)); - TEST(base::AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps), + TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps), (points[i].m_latLon.m_lat, result[i].m_latLon.m_lat)); - TEST(base::AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps), + TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps), (points[i].m_latLon.m_lon, result[i].m_latLon.m_lon)); } @@ -150,4 +150,4 @@ UNIT_TEST(Traffic_Serialization_ExtremeLatLon) }; Test(path); } -} // namespace coding +} // namespace traffic_test diff --git a/coding/geometry_coding.cpp b/coding/geometry_coding.cpp index 74644c2687..fd2d27edbc 100644 --- a/coding/geometry_coding.cpp +++ b/coding/geometry_coding.cpp @@ -14,8 +14,8 @@ namespace inline m2::PointU ClampPoint(m2::PointD const & maxPoint, m2::PointD const & point) { using uvalue_t = m2::PointU::value_type; - return { static_cast(base::Clamp(point.x, 0.0, maxPoint.x)), - static_cast(base::Clamp(point.y, 0.0, maxPoint.y)) }; + return { static_cast(math::Clamp(point.x, 0.0, maxPoint.x)), + static_cast(math::Clamp(point.y, 0.0, maxPoint.y)) }; } struct edge_less_p0 diff --git a/coding/point_coding.cpp b/coding/point_coding.cpp index ffabe79ddd..49c83bc5d3 100644 --- a/coding/point_coding.cpp +++ b/coding/point_coding.cpp @@ -50,7 +50,7 @@ double Uint32ToDouble(uint32_t x, double min, double max, uint8_t coordBits) // It doesn't work because of possible floating errors. //ASSERT(d >= min && d <= max, (d, x, min, max, coordBits)); - return base::Clamp(d, min, max); + return math::Clamp(d, min, max); } m2::PointU PointDToPointU(double x, double y, uint8_t coordBits) diff --git a/coding/point_coding.hpp b/coding/point_coding.hpp index 9e545230f9..26b849af97 100644 --- a/coding/point_coding.hpp +++ b/coding/point_coding.hpp @@ -13,7 +13,7 @@ uint8_t constexpr kFeatureSorterPointCoordBits = 27; // The absolute precision of the point encoding in the mwm files. // If both x and y coordinates of two points lie within |kMwmPointAccuracy| of one // another we consider the points equal. In other words, |kMwmPointAccuracy| may -// be used as the eps value for both x and y in Point::EqualDxDy, base::AlmostEqualAbs and such. +// be used as the eps value for both x and y in Point::EqualDxDy, AlmostEqualAbs and such. // // The constant is loosely tied to mercator::Bounds::kRangeX / (1 << kPointCoordBits): // The range of possible values for point coordinates diff --git a/drape/color.hpp b/drape/color.hpp index 20967dfe3e..fca5effe6c 100644 --- a/drape/color.hpp +++ b/drape/color.hpp @@ -38,9 +38,9 @@ struct Color constexpr Color operator*(float s) const { - return {static_cast(base::Clamp(GetRedF() * s, 0.0f, 1.0f) * 255.0f), - static_cast(base::Clamp(GetGreenF() * s, 0.0f, 1.0f) * 255.0f), - static_cast(base::Clamp(GetBlueF() * s, 0.0f, 1.0f) * 255.0f), GetAlpha()}; + return {static_cast(math::Clamp(GetRedF() * s, 0.0f, 1.0f) * 255.0f), + static_cast(math::Clamp(GetGreenF() * s, 0.0f, 1.0f) * 255.0f), + static_cast(math::Clamp(GetBlueF() * s, 0.0f, 1.0f) * 255.0f), GetAlpha()}; } constexpr static Color Black() { return {0, 0, 0, 255}; } diff --git a/drape/cpu_buffer.cpp b/drape/cpu_buffer.cpp index ea2f4cf0dc..cab6dd30ea 100644 --- a/drape/cpu_buffer.cpp +++ b/drape/cpu_buffer.cpp @@ -11,7 +11,7 @@ namespace dp CPUBuffer::CPUBuffer(uint8_t elementSize, uint32_t capacity) : TBase(elementSize, capacity) { - uint32_t memorySize = base::NextPowOf2(GetCapacity() * GetElementSize()); + uint32_t memorySize = math::NextPowOf2(GetCapacity() * GetElementSize()); m_memory = SharedBufferManager::instance().reserveSharedBuffer(memorySize); m_memoryCursor = NonConstData(); } diff --git a/drape/drape_tests/stipple_pen_tests.cpp b/drape/drape_tests/stipple_pen_tests.cpp index f4f38fff95..0d1cce5c9c 100644 --- a/drape/drape_tests/stipple_pen_tests.cpp +++ b/drape/drape_tests/stipple_pen_tests.cpp @@ -21,10 +21,10 @@ void TestPacker(StipplePenPacker & packer, uint32_t width, m2::RectU const & exp bool IsRectsEqual(m2::RectF const & r1, m2::RectF const & r2) { - return base::AlmostEqualULPs(r1.minX(), r2.minX()) && - base::AlmostEqualULPs(r1.minY(), r2.minY()) && - base::AlmostEqualULPs(r1.maxX(), r2.maxX()) && - base::AlmostEqualULPs(r1.maxY(), r2.maxY()); + return AlmostEqualULPs(r1.minX(), r2.minX()) && + AlmostEqualULPs(r1.minY(), r2.minY()) && + AlmostEqualULPs(r1.maxX(), r2.maxX()) && + AlmostEqualULPs(r1.maxY(), r2.maxY()); } } // namespace diff --git a/drape/stipple_pen_resource.cpp b/drape/stipple_pen_resource.cpp index cb642f0aee..c941a5ba46 100644 --- a/drape/stipple_pen_resource.cpp +++ b/drape/stipple_pen_resource.cpp @@ -195,7 +195,7 @@ void StipplePenIndex::UploadResources(ref_ptr context, ref_ for (auto const & n : pendingNodes) height += n.second.GetSize().y; - uint32_t const reserveBufferSize = base::NextPowOf2(height * kMaxStipplePenLength); + uint32_t const reserveBufferSize = math::NextPowOf2(height * kMaxStipplePenLength); SharedBufferManager & mng = SharedBufferManager::instance(); SharedBufferManager::shared_buffer_ptr_t ptr = mng.reserveSharedBuffer(reserveBufferSize); diff --git a/drape/texture_manager.cpp b/drape/texture_manager.cpp index 2dd84f1ba6..82f0fdad02 100644 --- a/drape/texture_manager.cpp +++ b/drape/texture_manager.cpp @@ -56,7 +56,7 @@ void ParseColorsList(std::string const & colorsFile, ToDo toDo) m2::PointU StipplePenTextureSize(size_t patternsCount, uint32_t maxTextureSize) { - uint32_t const sz = base::NextPowOf2(static_cast(patternsCount) + kReservedPatterns); + uint32_t const sz = math::NextPowOf2(static_cast(patternsCount) + kReservedPatterns); // No problem if assert will fire here. Just pen texture will be 2x bigger :) //ASSERT_LESS_OR_EQUAL(sz, kMinStippleTextureHeight, (patternsCount)); uint32_t const stippleTextureHeight = std::min(maxTextureSize, std::max(sz, kMinStippleTextureHeight)); @@ -69,7 +69,7 @@ m2::PointU ColorTextureSize(size_t colorsCount, uint32_t maxTextureSize) uint32_t const sz = static_cast(floor(sqrt(colorsCount + kReservedColors))); // No problem if assert will fire here. Just color texture will be 2x bigger :) ASSERT_LESS_OR_EQUAL(sz, kMinColorTextureSize, (colorsCount)); - uint32_t colorTextureSize = std::max(base::NextPowOf2(sz), kMinColorTextureSize); + uint32_t colorTextureSize = std::max(math::NextPowOf2(sz), kMinColorTextureSize); colorTextureSize *= ColorTexture::GetColorSizeInPixels(); colorTextureSize = std::min(maxTextureSize, colorTextureSize); diff --git a/drape/texture_of_colors.cpp b/drape/texture_of_colors.cpp index 4b98dd8f14..047ed1a5e2 100644 --- a/drape/texture_of_colors.cpp +++ b/drape/texture_of_colors.cpp @@ -144,7 +144,7 @@ void ColorPalette::UploadResources(ref_ptr context, ref_ptr size_t const pixelStride = uploadRect.SizeX(); size_t const byteCount = kBytesPerPixel * uploadRect.SizeX() * uploadRect.SizeY(); - size_t const bufferSize = static_cast(base::NextPowOf2(static_cast(byteCount))); + size_t const bufferSize = static_cast(math::NextPowOf2(static_cast(byteCount))); SharedBufferManager::shared_buffer_ptr_t buffer = SharedBufferManager::instance().reserveSharedBuffer(bufferSize); uint8_t * pointer = SharedBufferManager::GetRawPointer(buffer); diff --git a/drape/vulkan/vulkan_memory_manager.cpp b/drape/vulkan/vulkan_memory_manager.cpp index d464d2b1cb..0ba78bcd98 100644 --- a/drape/vulkan/vulkan_memory_manager.cpp +++ b/drape/vulkan/vulkan_memory_manager.cpp @@ -125,20 +125,20 @@ uint32_t VulkanMemoryManager::GetOffsetAlignment(ResourceType resourceType) cons if (resourceType == ResourceType::Uniform) { static uint32_t const kUniformAlignment = - base::LCM(static_cast(m_deviceLimits.minUniformBufferOffsetAlignment), + math::LCM(static_cast(m_deviceLimits.minUniformBufferOffsetAlignment), static_cast(m_deviceLimits.nonCoherentAtomSize)); return kUniformAlignment; } static uint32_t const kAlignment = - base::LCM(static_cast(m_deviceLimits.minMemoryMapAlignment), + math::LCM(static_cast(m_deviceLimits.minMemoryMapAlignment), static_cast(m_deviceLimits.nonCoherentAtomSize)); return kAlignment; } uint32_t VulkanMemoryManager::GetSizeAlignment(VkMemoryRequirements const & memReqs) const { - return base::LCM(static_cast(memReqs.alignment), + return math::LCM(static_cast(memReqs.alignment), static_cast(m_deviceLimits.nonCoherentAtomSize)); } diff --git a/drape_frontend/animation/interpolators.cpp b/drape_frontend/animation/interpolators.cpp index 1e2d24abc5..9484147078 100644 --- a/drape_frontend/animation/interpolators.cpp +++ b/drape_frontend/animation/interpolators.cpp @@ -12,7 +12,7 @@ double CalcAnimSpeedDuration(double pxDiff, double pxSpeed) { double constexpr kEps = 1e-5; - if (base::AlmostEqualAbs(pxDiff, 0.0, kEps)) + if (AlmostEqualAbs(pxDiff, 0.0, kEps)) return 0.0; return fabs(pxDiff) / pxSpeed; diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp index 74956b88de..04c88964fb 100644 --- a/drape_frontend/apply_feature_functors.cpp +++ b/drape_frontend/apply_feature_functors.cpp @@ -774,7 +774,7 @@ ApplyLineFeatureGeometry::ApplyLineFeatureGeometry(TileKey const & tileKey, TIns : TBase(tileKey, insertShape, f, CaptionDescription()) , m_currentScaleGtoP(currentScaleGtoP) // TODO(pastk) : calculate just once in the RuleDrawer. - , m_minSegmentSqrLength(base::Pow2(4.0 * df::VisualParams::Instance().GetVisualScale() / currentScaleGtoP)) + , m_minSegmentSqrLength(math::Pow2(4.0 * df::VisualParams::Instance().GetVisualScale() / currentScaleGtoP)) , m_simplify(tileKey.m_zoomLevel >= 10 && tileKey.m_zoomLevel <= 12) { m_spline.Reset(new m2::Spline(f.GetPointsCount())); diff --git a/drape_frontend/drape_frontend_tests/navigator_test.cpp b/drape_frontend/drape_frontend_tests/navigator_test.cpp index d182517117..440c89eefe 100644 --- a/drape_frontend/drape_frontend_tests/navigator_test.cpp +++ b/drape_frontend/drape_frontend_tests/navigator_test.cpp @@ -61,8 +61,8 @@ namespace P const & pxP = arr[i]; P const gP = nav.PtoG(pxP); P const pxP2 = nav.GtoP(gP); - TEST(base::AlmostEqualAbs(pxP.x, pxP2.x, 0.00001), (pxP.x, pxP2.x)); - TEST(base::AlmostEqualAbs(pxP.y, pxP2.y, 0.00001), (pxP.y, pxP2.y)); + TEST(AlmostEqualAbs(pxP.x, pxP2.x, 0.00001), (pxP.x, pxP2.x)); + TEST(AlmostEqualAbs(pxP.y, pxP2.y, 0.00001), (pxP.y, pxP2.y)); } } } diff --git a/drape_frontend/gps_track_renderer.cpp b/drape_frontend/gps_track_renderer.cpp index c30c0615b0..a22511493c 100644 --- a/drape_frontend/gps_track_renderer.cpp +++ b/drape_frontend/gps_track_renderer.cpp @@ -145,7 +145,7 @@ dp::Color GpsTrackRenderer::CalculatePointColor(size_t pointIndex, m2::PointD co endAlpha = kMaxNightAlpha; } - double const ta = base::Clamp(lengthFromStart / fullLength, 0.0, 1.0); + double const ta = math::Clamp(lengthFromStart / fullLength, 0.0, 1.0); double const alpha = startAlpha * (1.0 - ta) + endAlpha * ta; if ((end.m_timestamp - start.m_timestamp) > kUnknownDistanceTime) @@ -157,7 +157,7 @@ dp::Color GpsTrackRenderer::CalculatePointColor(size_t pointIndex, m2::PointD co double const length = (end.m_point - start.m_point).Length(); double const dist = (curPoint - start.m_point).Length(); - double const td = base::Clamp(dist / length, 0.0, 1.0); + double const td = math::Clamp(dist / length, 0.0, 1.0); double const speed = std::max(start.m_speedMPS * (1.0 - td) + end.m_speedMPS * td, 0.0); dp::Color const color = GetColorBySpeed(speed); diff --git a/drape_frontend/gui/compass.cpp b/drape_frontend/gui/compass.cpp index 4e6694b19d..34e3107df9 100644 --- a/drape_frontend/gui/compass.cpp +++ b/drape_frontend/gui/compass.cpp @@ -51,8 +51,8 @@ public: bool Update(ScreenBase const & screen) override { - static double const kVisibleStartAngle = base::DegToRad(5.0); - static double const kVisibleEndAngle = base::DegToRad(355.0); + static double const kVisibleStartAngle = math::DegToRad(5.0); + static double const kVisibleEndAngle = math::DegToRad(355.0); auto const angle = static_cast(ang::AngleIn2PI(screen.GetAngle())); diff --git a/drape_frontend/gui/ruler_helper.cpp b/drape_frontend/gui/ruler_helper.cpp index 22200c636f..1bd432c01a 100644 --- a/drape_frontend/gui/ruler_helper.cpp +++ b/drape_frontend/gui/ruler_helper.cpp @@ -113,7 +113,7 @@ RulerHelper::RulerHelper() void RulerHelper::Update(ScreenBase const & screen) { m2::PointD pivot = screen.PixelRect().Center(); - int const minPxWidth = base::SignedRound(kMinPixelWidth * df::VisualParams::Instance().GetVisualScale()); + int const minPxWidth = math::SignedRound(kMinPixelWidth * df::VisualParams::Instance().GetVisualScale()); m2::PointD pt1 = screen.PtoG(pivot); m2::PointD pt0 = screen.PtoG(pivot - m2::PointD(minPxWidth, 0)); @@ -133,7 +133,7 @@ void RulerHelper::Update(ScreenBase const & screen) double const a = ang::AngleTo(pt1, pt0); pt0 = mercator::GetSmPoint(pt1, cos(a) * metersDiff, sin(a) * metersDiff); - m_pixelLength = base::SignedRound(pivot.Length(screen.GtoP(pt0))); + m_pixelLength = math::SignedRound(pivot.Length(screen.GtoP(pt0))); } int drawScale = df::GetDrawTileScale(screen); diff --git a/drape_frontend/line_shape_helper.cpp b/drape_frontend/line_shape_helper.cpp index 07c7b37052..41949b358b 100644 --- a/drape_frontend/line_shape_helper.cpp +++ b/drape_frontend/line_shape_helper.cpp @@ -264,7 +264,7 @@ float GetProjectionLength(glsl::vec2 const & newPoint, glsl::vec2 const & startP glsl::vec2 const v2 = newPoint - startPoint; float const squareLen = glsl::dot(v1, v1); float const proj = glsl::dot(v1, v2) / squareLen; - return sqrt(squareLen) * base::Clamp(proj, 0.0f, 1.0f); + return sqrt(squareLen) * math::Clamp(proj, 0.0f, 1.0f); } } // namespace df diff --git a/drape_frontend/my_position_controller.cpp b/drape_frontend/my_position_controller.cpp index 7495be826a..3a74c1ad89 100644 --- a/drape_frontend/my_position_controller.cpp +++ b/drape_frontend/my_position_controller.cpp @@ -428,7 +428,7 @@ void MyPositionController::OnLocationUpdate(location::GpsInfo const & info, bool if ((!m_isCompassAvailable || glueArrowInRouting || isMovingFast) && info.HasBearing()) { - SetDirection(base::DegToRad(info.m_bearing)); + SetDirection(math::DegToRad(info.m_bearing)); m_lastGPSBearingTimer.Reset(); } @@ -614,7 +614,7 @@ bool MyPositionController::AlmostCurrentPosition(m2::PointD const & pos) const bool MyPositionController::AlmostCurrentAzimut(double azimut) const { double constexpr kDirectionEqualityDelta = 1e-3; - return base::AlmostEqualAbs(azimut, m_drawDirection, kDirectionEqualityDelta); + return AlmostEqualAbs(azimut, m_drawDirection, kDirectionEqualityDelta); } void MyPositionController::SetDirection(double bearing) diff --git a/drape_frontend/route_shape.cpp b/drape_frontend/route_shape.cpp index 4c61d20e22..1ad9b93ec2 100644 --- a/drape_frontend/route_shape.cpp +++ b/drape_frontend/route_shape.cpp @@ -666,8 +666,8 @@ void RouteShape::BatchGeometry(ref_ptr context, dp::RenderS uint32_t constexpr kMaxBatchSize = 65000; uint32_t constexpr kIndicesScalar = 2; - verticesCount = base::Clamp(verticesCount, kMinBatchSize, kMaxBatchSize); - auto const indicesCount = base::Clamp(verticesCount * kIndicesScalar, kMinBatchSize, kMaxBatchSize); + verticesCount = math::Clamp(verticesCount, kMinBatchSize, kMaxBatchSize); + auto const indicesCount = math::Clamp(verticesCount * kIndicesScalar, kMinBatchSize, kMaxBatchSize); dp::Batcher batcher(indicesCount, verticesCount); batcher.SetBatcherHash(static_cast(BatcherBucket::Routing)); diff --git a/drape_frontend/traffic_renderer.cpp b/drape_frontend/traffic_renderer.cpp index 3b39eecb52..0d60eed55d 100644 --- a/drape_frontend/traffic_renderer.cpp +++ b/drape_frontend/traffic_renderer.cpp @@ -323,7 +323,7 @@ bool TrafficRenderer::CanBeRenderedAsLine(RoadClass const & roadClass, int zoomL if (it == lineDrawerEnd) return false; - width = std::max(1, base::SignedRound(TrafficRenderer::GetPixelWidthInternal(roadClass, zoomLevel))); + width = std::max(1, math::SignedRound(TrafficRenderer::GetPixelWidthInternal(roadClass, zoomLevel))); return width <= dp::SupportManager::Instance().GetMaxLineWidth(); } } // namespace df diff --git a/drape_frontend/transit_scheme_builder.cpp b/drape_frontend/transit_scheme_builder.cpp index 15c6ff5d8b..3b8afdf2c7 100644 --- a/drape_frontend/transit_scheme_builder.cpp +++ b/drape_frontend/transit_scheme_builder.cpp @@ -851,8 +851,8 @@ void UpdateShapeInfos(std::vector & shapeInfos, m2::PointD const & for (ShapeInfoPT & info : shapeInfos) { - if (base::AlmostEqualAbs(info.m_direction, newDir, kEps) || - base::AlmostEqualAbs(info.m_direction, newDirReverse, kEps)) + if (AlmostEqualAbs(info.m_direction, newDir, kEps) || + AlmostEqualAbs(info.m_direction, newDirReverse, kEps)) { for (auto const & color : colors) info.m_colors.insert(color); @@ -1249,7 +1249,7 @@ bool StopHasMultipleShapes(std::vector const & shapeInfosIn, { auto const it = std::find_if(shapeInfosOut.begin(), shapeInfosOut.end(), [&si](ShapeInfoPT const & so) { - return base::AlmostEqualAbs(si.m_direction, so.m_direction, kEps); + return AlmostEqualAbs(si.m_direction, so.m_direction, kEps); }); if (it != shapeInfosOut.end()) ++count; diff --git a/drape_frontend/user_event_stream.cpp b/drape_frontend/user_event_stream.cpp index 0c364f78e7..ff4ca3967a 100644 --- a/drape_frontend/user_event_stream.cpp +++ b/drape_frontend/user_event_stream.cpp @@ -144,7 +144,7 @@ UserEventStream::UserEventStream() , m_animationSystem(AnimationSystem::Instance()) , m_startDragOrg(m2::PointD::Zero()) , m_startDoubleTapAndHold(m2::PointD::Zero()) - , m_dragThreshold(base::Pow2(VisualParams::Instance().GetDragThreshold())) + , m_dragThreshold(math::Pow2(VisualParams::Instance().GetDragThreshold())) { } diff --git a/drape_frontend/user_mark_shapes.cpp b/drape_frontend/user_mark_shapes.cpp index 084486274f..4bb9e0f36a 100644 --- a/drape_frontend/user_mark_shapes.cpp +++ b/drape_frontend/user_mark_shapes.cpp @@ -549,7 +549,7 @@ void CacheUserLines(ref_ptr context, TileKey const & tileKe // This var is used only if simplify == true. double minSegmentSqrLength = 1.0; if (simplify) - minSegmentSqrLength = base::Pow2(4.0 * vs * GetScreenScale(tileKey.m_zoomLevel)); + minSegmentSqrLength = math::Pow2(4.0 * vs * GetScreenScale(tileKey.m_zoomLevel)); m2::RectD const tileRect = tileKey.GetGlobalRect(); diff --git a/drape_frontend/visual_params.cpp b/drape_frontend/visual_params.cpp index d91b0796a0..2cb358a2b2 100644 --- a/drape_frontend/visual_params.cpp +++ b/drape_frontend/visual_params.cpp @@ -61,7 +61,7 @@ double VisualParams::GetFontScale() const void VisualParams::SetFontScale(double fontScale) { ASSERT_INITED; - m_fontScale = base::Clamp(fontScale, 0.5, 2.0); + m_fontScale = math::Clamp(fontScale, 0.5, 2.0); } void VisualParams::SetVisualScale(double visualScale) @@ -186,7 +186,7 @@ int GetTileScaleBase(m2::RectD const & r) { double const sz = std::max(r.SizeX(), r.SizeY()); ASSERT_GREATER(sz, 0., ("Rect should not be a point:", r)); - return std::max(1, base::SignedRound(std::log2(mercator::Bounds::kRangeX / sz))); + return std::max(1, math::SignedRound(std::log2(mercator::Bounds::kRangeX / sz))); } double GetTileScaleBase(double drawScale) @@ -224,12 +224,12 @@ m2::RectD GetRectForDrawScale(int drawScale, m2::PointD const & center) m2::RectD GetRectForDrawScale(double drawScale, m2::PointD const & center, uint32_t tileSize, double visualScale) { - return GetRectForDrawScale(base::SignedRound(drawScale), center, tileSize, visualScale); + return GetRectForDrawScale(math::SignedRound(drawScale), center, tileSize, visualScale); } m2::RectD GetRectForDrawScale(double drawScale, m2::PointD const & center) { - return GetRectForDrawScale(base::SignedRound(drawScale), center); + return GetRectForDrawScale(math::SignedRound(drawScale), center); } uint32_t CalculateTileSize(uint32_t screenWidth, uint32_t screenHeight) @@ -257,9 +257,9 @@ uint32_t CalculateTileSize(uint32_t screenWidth, uint32_t screenHeight) } #ifndef OMIM_OS_DESKTOP - return static_cast(base::Clamp(res / 2, 256, 1024)); + return static_cast(math::Clamp(res / 2, 256, 1024)); #else - return static_cast(base::Clamp(res / 2, 512, 1024)); + return static_cast(math::Clamp(res / 2, 512, 1024)); #endif } @@ -312,7 +312,7 @@ void ExtractZoomFactors(ScreenBase const & s, double & zoom, int & index, float double GetNormalizedZoomLevel(double screenScale, int minZoom) { double const kMaxZoom = scales::GetUpperStyleScale() + 1.0; - return base::Clamp((GetZoomLevel(screenScale) - minZoom) / (kMaxZoom - minZoom), 0.0, 1.0); + return math::Clamp((GetZoomLevel(screenScale) - minZoom) / (kMaxZoom - minZoom), 0.0, 1.0); } double GetScreenScale(double zoomLevel) @@ -330,7 +330,7 @@ double GetZoomLevel(double screenScale) auto const pxLen = static_cast(p.GetTileSize()); auto const len = pxLen * screenScale; auto const factor = mercator::Bounds::kRangeX / len; - return base::Clamp(GetDrawTileScale(fabs(std::log2(factor))), 1.0, scales::GetUpperStyleScale() + 1.0); + return math::Clamp(GetDrawTileScale(fabs(std::log2(factor))), 1.0, scales::GetUpperStyleScale() + 1.0); } float CalculateRadius(ScreenBase const & screen, ArrayView const & zoom2radius) diff --git a/editor/server_api.cpp b/editor/server_api.cpp index 3ed493ef26..1430f70afa 100644 --- a/editor/server_api.cpp +++ b/editor/server_api.cpp @@ -190,7 +190,7 @@ OsmOAuth::Response ServerApi06::GetXmlFeaturesAtLatLon(double lat, double lon, d double const latDegreeOffset = radiusInMeters * mercator::Bounds::kDegreesInMeter; double const minLat = std::max(-90.0, lat - latDegreeOffset); double const maxLat = std::min( 90.0, lat + latDegreeOffset); - double const cosL = std::max(cos(base::DegToRad(std::max(fabs(minLat), fabs(maxLat)))), 0.00001); + double const cosL = std::max(cos(math::DegToRad(std::max(fabs(minLat), fabs(maxLat)))), 0.00001); double const lonDegreeOffset = radiusInMeters * mercator::Bounds::kDegreesInMeter / cosL; double const minLon = std::max(-180.0, lon - lonDegreeOffset); double const maxLon = std::min( 180.0, lon + lonDegreeOffset); diff --git a/ge0/ge0_tests/parser_tests.cpp b/ge0/ge0_tests/parser_tests.cpp index ce82c31531..bb9a7a9203 100644 --- a/ge0/ge0_tests/parser_tests.cpp +++ b/ge0/ge0_tests/parser_tests.cpp @@ -76,7 +76,7 @@ bool ConvergenceTest(double lat, double lon, double latEps, double lonEps) ge0::LatLonToString(tmpLat, tmpLon, urlPrefix + 0, 9); parser.DecodeLatLon(urlPrefix, tmpLat, tmpLon); } - return base::AlmostEqualAbs(lat, tmpLat, latEps) && base::AlmostEqualAbs(lon, tmpLon, lonEps); + return AlmostEqualAbs(lat, tmpLat, latEps) && AlmostEqualAbs(lon, tmpLon, lonEps); } UNIT_TEST(Base64DecodingWorksForAValidChar) diff --git a/generator/borders.cpp b/generator/borders.cpp index 3269660aac..b0a6b6036c 100644 --- a/generator/borders.cpp +++ b/generator/borders.cpp @@ -87,7 +87,7 @@ public: std::vector out; /// @todo Choose scale level for simplification. - SimplifyDefault(in.begin(), in.end(), base::Pow2(scales::GetEpsilonForSimplify(10)), out); + SimplifyDefault(in.begin(), in.end(), math::Pow2(scales::GetEpsilonForSimplify(10)), out); serial::SaveOuterPath(out, cp, *w); } diff --git a/generator/borders.hpp b/generator/borders.hpp index 3ff531d81b..88cde0ffbe 100644 --- a/generator/borders.hpp +++ b/generator/borders.hpp @@ -70,12 +70,12 @@ public: explicit ContainsCompareFn(double eps) : m_eps(eps), m_squareEps(eps*eps) {} bool EqualPoints(m2::PointD const & p1, m2::PointD const & p2) const { - return base::AlmostEqualAbs(p1.x, p2.x, m_eps) && - base::AlmostEqualAbs(p1.y, p2.y, m_eps); + return AlmostEqualAbs(p1.x, p2.x, m_eps) && + AlmostEqualAbs(p1.y, p2.y, m_eps); } bool EqualZeroSquarePrecision(double val) const { - return base::AlmostEqualAbs(val, 0.0, m_squareEps); + return AlmostEqualAbs(val, 0.0, m_squareEps); } }; diff --git a/generator/composite_id.hpp b/generator/composite_id.hpp index 652a684e3c..e61a52bcdc 100644 --- a/generator/composite_id.hpp +++ b/generator/composite_id.hpp @@ -36,7 +36,7 @@ struct hash { size_t operator()(generator::CompositeId const & id) const { - return base::Hash(id.m_mainId, id.m_additionalId); + return math::Hash(id.m_mainId, id.m_additionalId); } }; } // namespace std diff --git a/generator/feature_builder.cpp b/generator/feature_builder.cpp index 01b1042c60..38bf4a9340 100644 --- a/generator/feature_builder.cpp +++ b/generator/feature_builder.cpp @@ -29,7 +29,7 @@ namespace { bool IsEqual(double d1, double d2) { - return base::AlmostEqualAbs(d1, d2, kMwmPointAccuracy); + return AlmostEqualAbs(d1, d2, kMwmPointAccuracy); } bool IsEqual(m2::PointD const & p1, m2::PointD const & p2) diff --git a/generator/feature_helpers.hpp b/generator/feature_helpers.hpp index 51362084cc..57b4b9affd 100644 --- a/generator/feature_helpers.hpp +++ b/generator/feature_helpers.hpp @@ -68,10 +68,10 @@ public: // p is close to the borders of |m_rect|, in which case returns a very large number. double operator()(m2::PointD const & a, m2::PointD const & b, m2::PointD const & p) const { - if (base::AlmostEqualAbs(p.x, m_rect.minX(), m_eps) || - base::AlmostEqualAbs(p.x, m_rect.maxX(), m_eps) || - base::AlmostEqualAbs(p.y, m_rect.minY(), m_eps) || - base::AlmostEqualAbs(p.y, m_rect.maxY(), m_eps)) + if (AlmostEqualAbs(p.x, m_rect.minX(), m_eps) || + AlmostEqualAbs(p.x, m_rect.maxX(), m_eps) || + AlmostEqualAbs(p.y, m_rect.minY(), m_eps) || + AlmostEqualAbs(p.y, m_rect.maxY(), m_eps)) { // Points near rect should be in a result simplified vector. return std::numeric_limits::max(); @@ -96,7 +96,7 @@ void SimplifyPoints(DistanceFn distFn, int level, PointsContainer const & in, Po if (in.size() < 2) return; - double const eps = base::Pow2(scales::GetEpsilonForSimplify(level)); + double const eps = math::Pow2(scales::GetEpsilonForSimplify(level)); SimplifyNearOptimal(20, in.begin(), in.end(), eps, distFn, AccumulateSkipSmallTrg(distFn, out, eps)); diff --git a/generator/feature_segments_checker/feature_segments_checker.cpp b/generator/feature_segments_checker/feature_segments_checker.cpp index ab6ca3f177..11e314b5b3 100644 --- a/generator/feature_segments_checker/feature_segments_checker.cpp +++ b/generator/feature_segments_checker/feature_segments_checker.cpp @@ -97,7 +97,7 @@ bool LinearLeastSquaresFactors(std::vector const & xs, std::vector> const & data, for (size_t i = 0; i < geometry.size(); ++i) { - if (!m2::AlmostEqualAbs(geometry[i], it->second[i], kMwmPointAccuracy)) + if (!AlmostEqualAbs(geometry[i], it->second[i], kMwmPointAccuracy)) return false; } diff --git a/generator/generator_tests/collector_routing_city_boundaries_tests.cpp b/generator/generator_tests/collector_routing_city_boundaries_tests.cpp index 792437f3d7..c8072fa796 100644 --- a/generator/generator_tests/collector_routing_city_boundaries_tests.cpp +++ b/generator/generator_tests/collector_routing_city_boundaries_tests.cpp @@ -123,7 +123,7 @@ bool CheckPolygonExistance(std::vector> const & polygons for (size_t i = 0; i < polygon.size(); ++i) { - if (!m2::AlmostEqualAbs(polygon[i], polygonToFind[i], 1e-6)) + if (!AlmostEqualAbs(polygon[i], polygonToFind[i], 1e-6)) { same = false; break; @@ -262,7 +262,7 @@ UNIT_TEST(AreaOnEarth_Convex_Polygon_1) double const areaOnEarth = generator::AreaOnEarth(points); - TEST(base::AlmostEqualRel(areaTriangulated, + TEST(AlmostEqualRel(areaTriangulated, areaOnEarth, 1e-6), (areaTriangulated, areaOnEarth)); } @@ -286,7 +286,7 @@ UNIT_TEST(AreaOnEarth_Convex_Polygon_2) double const areaOnEarth = generator::AreaOnEarth(points); double const areaForConvexPolygon = CalculateEarthAreaForConvexPolygon(latlons); - TEST(base::AlmostEqualRel(areaForConvexPolygon, + TEST(AlmostEqualRel(areaForConvexPolygon, areaOnEarth, 1e-6), (areaForConvexPolygon, areaOnEarth)); } @@ -319,7 +319,7 @@ UNIT_TEST(AreaOnEarth_Concave_Polygon) double const areaOnEarth = generator::AreaOnEarth(points); - TEST(base::AlmostEqualRel(areaTriangulated, + TEST(AlmostEqualRel(areaTriangulated, areaOnEarth, 1e-6), ()); } diff --git a/generator/generator_tests/mini_roundabout_tests.cpp b/generator/generator_tests/mini_roundabout_tests.cpp index 2438d7547f..65d696d293 100644 --- a/generator/generator_tests/mini_roundabout_tests.cpp +++ b/generator/generator_tests/mini_roundabout_tests.cpp @@ -55,12 +55,12 @@ void TestRunCmpPoints(std::vector const & pointsFact, TEST_EQUAL(pointsFact.size(), pointsPlan.size(), ()); TEST_GREATER(pointsFact.size(), 2, ()); for (size_t i = 0; i < pointsFact.size(); ++i) - TEST(m2::AlmostEqualAbs(pointsFact[i], pointsPlan[i], kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(pointsFact[i], pointsPlan[i], kMwmPointAccuracy), ()); } void TestRunCmpNumbers(double val1, double val2) { - TEST(base::AlmostEqualAbs(val1, val2, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(val1, val2, kMwmPointAccuracy), ()); } UNIT_TEST(PointToPolygon_GeneralProperties) @@ -81,10 +81,10 @@ UNIT_TEST(PointToPolygon_GeneralProperties) for (size_t i = 0; i < circlePlain.size() - 1; ++i) { double const rCurrent = DistanceOnPlain(circlePlain[i], center); - TEST(base::AlmostEqualAbs(rCurrent, r, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(rCurrent, r, kMwmPointAccuracy), ()); double const vertexLengthCurrent = DistanceOnPlain(circlePlain[i], circlePlain[i + 1]); - TEST(base::AlmostEqualAbs(vertexLengthCurrent, vertexLenght, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(vertexLengthCurrent, vertexLenght, kMwmPointAccuracy), ()); } } } @@ -97,7 +97,7 @@ UNIT_TEST(TrimSegment_Vertical) double const dist = 1.0; m2::PointD const point = GetPointAtDistFromTarget(a /* source */, b /* target */, dist); m2::PointD const pointPlan(2.0, 2.0); - TEST(m2::AlmostEqualAbs(point, pointPlan, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(point, pointPlan, kMwmPointAccuracy), ()); } UNIT_TEST(TrimSegment_VerticalNegative) @@ -107,7 +107,7 @@ UNIT_TEST(TrimSegment_VerticalNegative) double const dist = 4.0; m2::PointD const point = GetPointAtDistFromTarget(a /* source */, b /* target */, dist); m2::PointD const pointPlan(-3.0, 2.0); - TEST(m2::AlmostEqualAbs(point, pointPlan, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(point, pointPlan, kMwmPointAccuracy), ()); } UNIT_TEST(TrimSegment_ExceptionalCase) @@ -116,7 +116,7 @@ UNIT_TEST(TrimSegment_ExceptionalCase) m2::PointD const b(2.0, 3.0); double const dist = 10.0; m2::PointD const point = GetPointAtDistFromTarget(a /* source */, b /* target */, dist); - TEST(m2::AlmostEqualAbs(point, a, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(point, a, kMwmPointAccuracy), ()); } UNIT_TEST(PointToCircle_ZeroMeridian) @@ -192,19 +192,19 @@ UNIT_TEST(Manage_MiniRoundabout_1Road) // Check for "diameters" equality. double const diameter = r * 2.; - TEST(base::AlmostEqualAbs(DistanceOnPlain(circlePlain[0], circlePlain[3]), diameter, + TEST(AlmostEqualAbs(DistanceOnPlain(circlePlain[0], circlePlain[3]), diameter, kMwmPointAccuracy), ()); - TEST(base::AlmostEqualAbs(DistanceOnPlain(circlePlain[1], circlePlain[4]), diameter, + TEST(AlmostEqualAbs(DistanceOnPlain(circlePlain[1], circlePlain[4]), diameter, kMwmPointAccuracy), ()); - TEST(base::AlmostEqualAbs(DistanceOnPlain(circlePlain[2], circlePlain[5]), diameter, + TEST(AlmostEqualAbs(DistanceOnPlain(circlePlain[2], circlePlain[5]), diameter, kMwmPointAccuracy), ()); double const edgeLen = DistanceOnPlain(circlePlain[0], circlePlain[1]); for (size_t i = 1; i < circlePlain.size(); ++i) - TEST(base::AlmostEqualAbs(DistanceOnPlain(circlePlain[i - 1], circlePlain[i]), edgeLen, + TEST(AlmostEqualAbs(DistanceOnPlain(circlePlain[i - 1], circlePlain[i]), edgeLen, kMwmPointAccuracy), ()); diff --git a/generator/generator_tests/osm_o5m_source_test.cpp b/generator/generator_tests/osm_o5m_source_test.cpp index 5ab34b9119..39856f5709 100644 --- a/generator/generator_tests/osm_o5m_source_test.cpp +++ b/generator/generator_tests/osm_o5m_source_test.cpp @@ -31,8 +31,8 @@ UNIT_TEST(OSM_O5M_Source_Node_read_test) TEST_EQUAL(em.uid, 395071, ()); TEST_EQUAL(em.version, 8, ()); TEST_EQUAL(em.changeset, 12059128, ()); - TEST(base::AlmostEqualAbs(em.lon, 38.7666704, 1e-7), ()); - TEST(base::AlmostEqualAbs(em.lat, 55.0927062, 1e-7), ()); + TEST(AlmostEqualAbs(em.lon, 38.7666704, 1e-7), ()); + TEST(AlmostEqualAbs(em.lat, 55.0927062, 1e-7), ()); auto const tags = em.Tags(); auto tagIterator = tags.begin(); diff --git a/generator/generator_tests/raw_generator_test.cpp b/generator/generator_tests/raw_generator_test.cpp index 78c6f3699f..ebdab66a3c 100644 --- a/generator/generator_tests/raw_generator_test.cpp +++ b/generator/generator_tests/raw_generator_test.cpp @@ -928,7 +928,7 @@ UNIT_TEST(MiniRoundabout_Connectivity) { for (auto const & p : roundabout) { - if (m2::AlmostEqualAbs(p, pt, kMwmPointAccuracy)) + if (AlmostEqualAbs(p, pt, kMwmPointAccuracy)) return true; } return false; diff --git a/generator/generator_tests/speed_cameras_test.cpp b/generator/generator_tests/speed_cameras_test.cpp index 2b915605f1..961d06d232 100644 --- a/generator/generator_tests/speed_cameras_test.cpp +++ b/generator/generator_tests/speed_cameras_test.cpp @@ -97,7 +97,7 @@ void CheckCameraMapsEquality(CameraMap const & lhs, CameraMap const & rhs, doubl // It can differ on Jenknins and local computer. TEST_EQUAL(vectorL[i].first.GetPointId(), vectorR[i].first.GetPointId(), ()); TEST_EQUAL(vectorL[i].second.m_maxSpeedKmPH, vectorR[i].second.m_maxSpeedKmPH, ()); - TEST(base::AlmostEqualAbs(vectorL[i].second.m_coef, vectorR[i].second.m_coef, epsilon), ()); + TEST(AlmostEqualAbs(vectorL[i].second.m_coef, vectorR[i].second.m_coef, epsilon), ()); } } @@ -352,7 +352,7 @@ UNIT_TEST(SpeedCameraGenerationTest_CameraIsNearFeature_1) auto epsilon = mercator::DistanceOnEarth({0, 0}, {kMwmPointAccuracy, kMwmPointAccuracy}) / mercator::DistanceOnEarth(mercator::FromLatLon(55.7793100, 37.3699100), mercator::FromLatLon(55.7793300, 37.3699300)); - epsilon = base::Clamp(epsilon, 0.0, 1.0); + epsilon = math::Clamp(epsilon, 0.0, 1.0); CameraMap const answer = { {SegmentCoord(0, 0), std::vector{{0.5, 100}}}}; TestSpeedCameraSectionBuilding(osmContent, answer, epsilon); @@ -389,7 +389,7 @@ UNIT_TEST(SpeedCameraGenerationTest_CameraIsNearFeature_2) auto epsilon = mercator::DistanceOnEarth({0, 0}, {kMwmPointAccuracy, kMwmPointAccuracy}) / mercator::DistanceOnEarth(mercator::FromLatLon(55.7793100, 37.3699100), mercator::FromLatLon(55.7793300, 37.3699300)); - epsilon = base::Clamp(epsilon, 0.0, 1.0); + epsilon = math::Clamp(epsilon, 0.0, 1.0); CameraMap const answer = { {SegmentCoord(0, 0), std::vector{{0.25, 100}}} diff --git a/generator/hierarchy_entry.cpp b/generator/hierarchy_entry.cpp index cd150d2d2e..42c243d6da 100644 --- a/generator/hierarchy_entry.cpp +++ b/generator/hierarchy_entry.cpp @@ -36,7 +36,7 @@ namespace generator { bool operator==(HierarchyEntry const & lhs, HierarchyEntry const & rhs) { - return base::AlmostEqualAbs(lhs.m_center, rhs.m_center, 1e-7) && + return AlmostEqualAbs(lhs.m_center, rhs.m_center, 1e-7) && (std::tie(lhs.m_id, lhs.m_parentId, lhs.m_depth, lhs.m_name, lhs.m_country, lhs.m_type) == std::tie(rhs.m_id, rhs.m_parentId, rhs.m_depth, rhs.m_name, rhs.m_country, rhs.m_type)); } diff --git a/generator/mini_roundabout_transformer.cpp b/generator/mini_roundabout_transformer.cpp index 96c63436b9..d82ed5e1fd 100644 --- a/generator/mini_roundabout_transformer.cpp +++ b/generator/mini_roundabout_transformer.cpp @@ -46,7 +46,7 @@ feature::FeatureBuilder::PointSeq::iterator GetIterOnRoad(m2::PointD const & poi { return std::find_if(road.begin(), road.end(), [&point](m2::PointD const & pointOnRoad) { - return m2::AlmostEqualAbs(pointOnRoad, point, kMwmPointAccuracy); + return AlmostEqualAbs(pointOnRoad, point, kMwmPointAccuracy); }); } } // namespace @@ -149,7 +149,7 @@ MiniRoundaboutTransformer::PointsT MiniRoundaboutTransformer::CreateSurrogateRoa *itPointOnSurrogateRoad /* source */, roundaboutOnRoad.m_location /* target */, m_radiusMercator /* dist */); - if (m2::AlmostEqualAbs(nextPointOnSurrogateRoad, *itPointOnSurrogateRoad, kMwmPointAccuracy)) + if (AlmostEqualAbs(nextPointOnSurrogateRoad, *itPointOnSurrogateRoad, kMwmPointAccuracy)) return {}; AddPointToCircle(roundaboutCircle, nextPointOnSurrogateRoad); @@ -174,7 +174,7 @@ bool MiniRoundaboutTransformer::AddRoundaboutToRoad(RoundaboutUnit const & round GetPointAtDistFromTarget(*itPointNearRoundabout /* source */, roundaboutCenter /* target */, m_radiusMercator /* dist */); - if (isMiddlePoint && !m2::AlmostEqualAbs(nextPointOnRoad, *itPointNearRoundabout, kMwmPointAccuracy)) + if (isMiddlePoint && !AlmostEqualAbs(nextPointOnRoad, *itPointNearRoundabout, kMwmPointAccuracy)) { auto surrogateRoad = CreateSurrogateRoad(roundaboutOnRoad, roundaboutCircle, road, itPointUpd); if (surrogateRoad.size() < 2) @@ -319,7 +319,7 @@ std::vector PointToPolygon(m2::PointD const & center, double radiusM vertices.reserve(verticesCount); double const kAngularPitch = 2 * math::pi / static_cast(verticesCount); - double angle = base::DegToRad(initAngleDeg); + double angle = math::DegToRad(initAngleDeg); for (size_t i = 0; i < verticesCount; ++i) { diff --git a/generator/osm2meta.cpp b/generator/osm2meta.cpp index b0386b1206..99d9516324 100644 --- a/generator/osm2meta.cpp +++ b/generator/osm2meta.cpp @@ -375,7 +375,7 @@ std::string MetadataTagProcessorImpl::ValidateAndFormat_duration(std::string con return {}; auto const format = [](double hours) -> std::string { - if (base::AlmostEqualAbs(hours, 0.0, 1e-5)) + if (AlmostEqualAbs(hours, 0.0, 1e-5)) return {}; std::stringstream ss; diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index 84fb9992ec..df3dba944b 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -1391,7 +1391,7 @@ void GetNameAndType(OsmElement * p, FeatureBuilderParams & params, // atoi error value (0) should match empty layer constant. static_assert(feature::LAYER_EMPTY == 0); params.layer = atoi(v.c_str()); - params.layer = base::Clamp(params.layer, int8_t{feature::LAYER_LOW}, int8_t{feature::LAYER_HIGH}); + params.layer = math::Clamp(params.layer, int8_t{feature::LAYER_LOW}, int8_t{feature::LAYER_HIGH}); } }}, }); diff --git a/generator/osm_element.cpp b/generator/osm_element.cpp index ebb615dd5d..62f2a71042 100644 --- a/generator/osm_element.cpp +++ b/generator/osm_element.cpp @@ -187,8 +187,8 @@ bool OsmElement::operator==(OsmElement const & other) const { return m_type == other.m_type && m_id == other.m_id - && base::AlmostEqualAbs(m_lon, other.m_lon, mercator::kPointEqualityEps) - && base::AlmostEqualAbs(m_lat, other.m_lat, mercator::kPointEqualityEps) + && AlmostEqualAbs(m_lon, other.m_lon, mercator::kPointEqualityEps) + && AlmostEqualAbs(m_lat, other.m_lat, mercator::kPointEqualityEps) && m_ref == other.m_ref && m_k == other.m_k && m_v == other.m_v diff --git a/generator/place_processor.cpp b/generator/place_processor.cpp index 68847c1803..f50b0dbefc 100644 --- a/generator/place_processor.cpp +++ b/generator/place_processor.cpp @@ -81,7 +81,7 @@ bool IsWorsePlace(FeaturePlace const & left, FeaturePlace const & right) // We need to compare areas to choose bigger feature from multipolygonal features. // |kMaxAreaM2| should be greater than cities exclaves (like airports or Zelenograd for Moscow). double const kMaxAreaM2 = 4e8; - area = base::Clamp(area, 0.0, kMaxAreaM2); + area = math::Clamp(area, 0.0, kMaxAreaM2); return area / kMaxAreaM2; }; diff --git a/generator/restriction_collector.cpp b/generator/restriction_collector.cpp index 4a88718433..7ee00f0480 100644 --- a/generator/restriction_collector.cpp +++ b/generator/restriction_collector.cpp @@ -150,7 +150,7 @@ bool RestrictionCollector::FeatureHasPointWithCoords(uint32_t featureId, for (uint32_t i = 0; i < pointsCount; ++i) { static double constexpr kEps = 1e-5; - if (base::AlmostEqualAbs(mercator::FromLatLon(roadGeometry.GetPoint(i)), coords, kEps)) + if (AlmostEqualAbs(mercator::FromLatLon(roadGeometry.GetPoint(i)), coords, kEps)) return true; } @@ -246,9 +246,9 @@ bool RestrictionCollector::CheckAndProcessUTurn(Restriction::Type & restrictionT // https://wiki.openstreetmap.org/wiki/Relation:restriction static auto constexpr kEps = 1e-5; bool const viaIsFirstNode = - base::AlmostEqualAbs(coords, mercator::FromLatLon(road.GetPoint(0)), kEps); + AlmostEqualAbs(coords, mercator::FromLatLon(road.GetPoint(0)), kEps); bool const viaIsLastNode = - base::AlmostEqualAbs(coords, mercator::FromLatLon(road.GetPoint(n - 1)), kEps); + AlmostEqualAbs(coords, mercator::FromLatLon(road.GetPoint(n - 1)), kEps); if (viaIsFirstNode) { diff --git a/generator/tesselator.cpp b/generator/tesselator.cpp index 89b4fd6188..04df10a7ea 100644 --- a/generator/tesselator.cpp +++ b/generator/tesselator.cpp @@ -127,7 +127,7 @@ int TesselateInterior(PolygonsT const & polys, TrianglesInfo & info) { for (int j = 0; j < 3; ++j) { - if (to.m_p[i] == from.m_p[base::NextModN(j, 3)] && to.m_p[base::NextModN(i, 3)] == from.m_p[j]) + if (to.m_p[i] == from.m_p[math::NextModN(j, 3)] && to.m_p[math::NextModN(i, 3)] == from.m_p[j]) return std::make_pair(i, j); } } @@ -143,14 +143,14 @@ int TesselateInterior(PolygonsT const & polys, TrianglesInfo & info) void TrianglesInfo::ListInfo::GetNeighbors( Triangle const & trg, Triangle const & from, int * nb) const { - int i = base::NextModN(CommonEdge(trg, from).first, 3); - int j = base::NextModN(i, 3); + int i = math::NextModN(CommonEdge(trg, from).first, 3); + int j = math::NextModN(i, 3); int ind = 0; TIterator it = m_neighbors.find(std::make_pair(trg.m_p[j], trg.m_p[i])); nb[ind++] = (it != m_neighbors.end()) ? it->second : empty_key; - it = m_neighbors.find(std::make_pair(trg.m_p[base::NextModN(j, 3)], trg.m_p[j])); + it = m_neighbors.find(std::make_pair(trg.m_p[math::NextModN(j, 3)], trg.m_p[j])); nb[ind++] = (it != m_neighbors.end()) ? it->second : empty_key; } diff --git a/generator/tesselator.hpp b/generator/tesselator.hpp index e6e2233ca8..0e4683797c 100644 --- a/generator/tesselator.hpp +++ b/generator/tesselator.hpp @@ -69,7 +69,7 @@ namespace tesselator { size_t operator()(std::pair const & p) const { - return base::Hash(p.first, p.second); + return math::Hash(p.first, p.second); } }; diff --git a/geometry/angles.cpp b/geometry/angles.cpp index ab036c9d99..f18bbe49a8 100644 --- a/geometry/angles.cpp +++ b/geometry/angles.cpp @@ -9,7 +9,7 @@ double AngleIn2PI(double ang) if (ang < 0.0) ang += period; - if (base::AlmostEqualULPs(period, ang)) + if (AlmostEqualULPs(period, ang)) return 0.0; return ang; diff --git a/geometry/area_on_earth.cpp b/geometry/area_on_earth.cpp index 6ee17b0689..ca15b3bdc9 100644 --- a/geometry/area_on_earth.cpp +++ b/geometry/area_on_earth.cpp @@ -4,6 +4,7 @@ #include "geometry/point3d.hpp" #include "base/assert.hpp" +#include "base/math.hpp" #include #include @@ -19,8 +20,8 @@ m3::PointD GetPointOnSphere(LatLon const & ll, double sphereRadius) ASSERT(LatLon::kMinLat <= ll.m_lat && ll.m_lat <= LatLon::kMaxLat, (ll)); ASSERT(LatLon::kMinLon <= ll.m_lon && ll.m_lon <= LatLon::kMaxLon, (ll)); - double const latRad = base::DegToRad(ll.m_lat); - double const lonRad = base::DegToRad(ll.m_lon); + double const latRad = math::DegToRad(ll.m_lat); + double const lonRad = math::DegToRad(ll.m_lon); double const x = sphereRadius * cos(latRad) * cos(lonRad); double const y = sphereRadius * cos(latRad) * sin(lonRad); @@ -44,9 +45,9 @@ double AreaOnEarth(LatLon const & ll1, LatLon const & ll2, LatLon const & ll3) double const triple = m3::DotProduct(a, m3::CrossProduct(b, c)); - ASSERT(base::AlmostEqualAbs(a.Length(), 1.0, 1e-5), ()); - ASSERT(base::AlmostEqualAbs(b.Length(), 1.0, 1e-5), ()); - ASSERT(base::AlmostEqualAbs(c.Length(), 1.0, 1e-5), ()); + ASSERT(::AlmostEqualAbs(a.Length(), 1.0, 1e-5), ()); + ASSERT(::AlmostEqualAbs(b.Length(), 1.0, 1e-5), ()); + ASSERT(::AlmostEqualAbs(c.Length(), 1.0, 1e-5), ()); double constexpr lengthMultiplication = 1.0; // a.Length() * b.Length() * c.Length() double const abc = m3::DotProduct(a, b); // * c.Length() == 1 diff --git a/geometry/avg_vector.hpp b/geometry/avg_vector.hpp index 31dcbcd50e..a1688e5df4 100644 --- a/geometry/avg_vector.hpp +++ b/geometry/avg_vector.hpp @@ -49,7 +49,7 @@ private: { T res = 0; for (size_t i = 0; i < Dim; ++i) - res += base::Pow2(a1[i] - a2[i]); + res += math::Pow2(a1[i] - a2[i]); return std::sqrt(res); } diff --git a/geometry/circle_on_earth.cpp b/geometry/circle_on_earth.cpp index 300aa068bf..3d734d567c 100644 --- a/geometry/circle_on_earth.cpp +++ b/geometry/circle_on_earth.cpp @@ -16,7 +16,7 @@ std::vector CreateCircleOnNorth(double radiusMeters, double angleSte double const z = ms::kEarthRadiusMeters * cos(angle); std::vector result; - double const stepRad = base::DegToRad(angleStepDegree); + double const stepRad = math::DegToRad(angleStepDegree); for (double angleRad = 0; angleRad < 2 * math::pi; angleRad += stepRad) { result.emplace_back(circleRadiusMeters * cos(angleRad), @@ -28,25 +28,25 @@ std::vector CreateCircleOnNorth(double radiusMeters, double angleSte ms::LatLon FromEarth3dToSpherical(m3::PointD const & vec) { - ASSERT(base::AlmostEqualAbs(vec.Length(), ms::kEarthRadiusMeters, 1e-5), + ASSERT(AlmostEqualAbs(vec.Length(), ms::kEarthRadiusMeters, 1e-5), (vec.Length(), ms::kEarthRadiusMeters)); double sinLatRad = vec.z / ms::kEarthRadiusMeters; - sinLatRad = base::Clamp(sinLatRad, -1.0, 1.0); + sinLatRad = math::Clamp(sinLatRad, -1.0, 1.0); double const cosLatRad = std::sqrt(1 - sinLatRad * sinLatRad); CHECK(-1.0 <= cosLatRad && cosLatRad <= 1.0, (cosLatRad)); double const latRad = asin(sinLatRad); double sinLonRad = vec.y / ms::kEarthRadiusMeters / cosLatRad; - sinLonRad = base::Clamp(sinLonRad, -1.0, 1.0); + sinLonRad = math::Clamp(sinLonRad, -1.0, 1.0); double lonRad = asin(sinLonRad); if (vec.y > 0 && vec.x < 0) lonRad = math::pi - lonRad; else if (vec.y < 0 && vec.x < 0) lonRad = -(math::pi - fabs(lonRad)); - auto const lat = base::RadToDeg(latRad); - auto const lon = base::RadToDeg(lonRad); + auto const lat = math::RadToDeg(latRad); + auto const lon = math::RadToDeg(lonRad); return {lat, lon}; } diff --git a/geometry/covering_utils.hpp b/geometry/covering_utils.hpp index de81c3ca2b..2dc57662b9 100644 --- a/geometry/covering_utils.hpp +++ b/geometry/covering_utils.hpp @@ -84,7 +84,7 @@ void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, CellIdC return; } - uint64_t const cellArea = base::Pow2(uint64_t(1 << (cellDepth - 1 - cell.Level()))); + uint64_t const cellArea = math::Pow2(uint64_t(1 << (cellDepth - 1 - cell.Level()))); CellObjectIntersection const intersection = intersect(cell); if (intersection == CELL_OBJECT_NO_INTERSECTION) @@ -101,7 +101,7 @@ void CoverObject(IntersectF const & intersect, uint64_t cellPenaltyArea, CellIdC uint64_t subdivArea = 0; for (size_t i = 0; i < subdiv.size(); ++i) - subdivArea += base::Pow2(uint64_t(1 << (cellDepth - 1 - subdiv[i].Level()))); + subdivArea += math::Pow2(uint64_t(1 << (cellDepth - 1 - subdiv[i].Level()))); ASSERT(!subdiv.empty(), (cellPenaltyArea, out, cell)); diff --git a/geometry/distance_on_sphere.cpp b/geometry/distance_on_sphere.cpp index a46162cceb..760ded13d9 100644 --- a/geometry/distance_on_sphere.cpp +++ b/geometry/distance_on_sphere.cpp @@ -9,10 +9,10 @@ namespace ms { double DistanceOnSphere(double lat1Deg, double lon1Deg, double lat2Deg, double lon2Deg) { - double const lat1 = base::DegToRad(lat1Deg); - double const lat2 = base::DegToRad(lat2Deg); + double const lat1 = math::DegToRad(lat1Deg); + double const lat2 = math::DegToRad(lat2Deg); double const dlat = sin((lat2 - lat1) * 0.5); - double const dlon = sin((base::DegToRad(lon2Deg) - base::DegToRad(lon1Deg)) * 0.5); + double const dlon = sin((math::DegToRad(lon2Deg) - math::DegToRad(lon1Deg)) * 0.5); double const y = dlat * dlat + dlon * dlon * cos(lat1) * cos(lat2); return 2.0 * atan2(sqrt(y), sqrt(std::max(0.0, 1.0 - y))); } diff --git a/geometry/geometry_tests/angle_test.cpp b/geometry/geometry_tests/angle_test.cpp index 46a3e1f22b..d5f6e47e36 100644 --- a/geometry/geometry_tests/angle_test.cpp +++ b/geometry/geometry_tests/angle_test.cpp @@ -75,16 +75,16 @@ UNIT_TEST(ShortestDistance) UNIT_TEST(TwoVectorsAngle) { double constexpr eps = 1e-10; - TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point(0, 0) /* p */, + TEST(AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point(0, 0) /* p */, m2::Point(0, 1) /* p1 */, m2::Point(1, 0)) /* p2 */, 3 * math::pi2, eps), ()); - TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point(1, 1) /* p */, + TEST(AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point(1, 1) /* p */, m2::Point(2, 2) /* p1 */, m2::Point(1, 2)) /* p2 */, math::pi4, eps), ()); - TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point(0, 0) /* p */, + TEST(AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point(0, 0) /* p */, m2::Point(1, 0) /* p1 */, m2::Point(0, -1)) /* p2 */, 3 * math::pi2, eps), ()); - TEST(base::AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point(0, 0) /* p */, + TEST(AlmostEqualAbs(ang::TwoVectorsAngle(m2::Point(0, 0) /* p */, m2::Point(1, 0) /* p1 */, m2::Point(-1, 0)) /* p2 */, math::pi, eps), ()); } diff --git a/geometry/geometry_tests/circle_on_earth_tests.cpp b/geometry/geometry_tests/circle_on_earth_tests.cpp index 2f4f5fa702..7ad9060471 100644 --- a/geometry/geometry_tests/circle_on_earth_tests.cpp +++ b/geometry/geometry_tests/circle_on_earth_tests.cpp @@ -62,7 +62,7 @@ UNIT_TEST(CircleOnEarthEquator) std::vector result; result.reserve(kN); - auto constexpr kStepRad = base::DegToRad(kAngleStepDegree); + auto constexpr kStepRad = math::DegToRad(kAngleStepDegree); double angleSumRad = 0.0; double angleRad = -math::pi2; while (angleSumRad < 2 * math::pi) diff --git a/geometry/geometry_tests/intersection_score_tests.cpp b/geometry/geometry_tests/intersection_score_tests.cpp index 0e600966d5..a518ac7c93 100644 --- a/geometry/geometry_tests/intersection_score_tests.cpp +++ b/geometry/geometry_tests/intersection_score_tests.cpp @@ -25,7 +25,7 @@ UNIT_TEST(IntersectionScore_PointsToPolygon) auto const score = geometry::GetIntersectionScoreForPoints(corners1, corners2); - TEST(base::AlmostEqualAbs(score, 0.9, 1e-10), ()); + TEST(AlmostEqualAbs(score, 0.9, 1e-10), ()); } { m2::RectD rectD = {0, 0, 10, 10}; @@ -41,7 +41,7 @@ UNIT_TEST(IntersectionScore_PointsToPolygon) auto const score = geometry::GetIntersectionScoreForPoints(corners1, corners2); - TEST(base::AlmostEqualAbs(score, 0.0, 1e-10), ()); + TEST(AlmostEqualAbs(score, 0.0, 1e-10), ()); } { m2::RectD rectD = {0, 0, 10, 10}; @@ -53,7 +53,7 @@ UNIT_TEST(IntersectionScore_PointsToPolygon) m2::AnyRectD::Corners corners2 = {m2::PointD{10.0, 10.0}, {10.0, 0.0}, {0.0, 0.0}, {0.0, 10.0}}; auto const score = geometry::GetIntersectionScoreForPoints(corners1, corners2); - TEST(base::AlmostEqualAbs(score, 1.0, 1e-10), ()); + TEST(AlmostEqualAbs(score, 1.0, 1e-10), ()); } } @@ -68,7 +68,7 @@ UNIT_TEST(IntersectionScore_TrianglesToPolygon) auto const score = geometry::GetIntersectionScoreForTriangulated(triangiulated1, triangiulated2); - TEST(base::AlmostEqualAbs(score, 0.9, 1e-10), ()); + TEST(AlmostEqualAbs(score, 0.9, 1e-10), ()); } { m2::RectD rectD = {0, 0, 10, 10}; @@ -90,6 +90,6 @@ UNIT_TEST(IntersectionScore_TrianglesToPolygon) auto const score = geometry::GetIntersectionScoreForTriangulated(triangiulated1, triangiulated2); - TEST(base::AlmostEqualAbs(score, 0.0, 1e-10), ()); + TEST(AlmostEqualAbs(score, 0.0, 1e-10), ()); } } diff --git a/geometry/geometry_tests/parametrized_segment_tests.cpp b/geometry/geometry_tests/parametrized_segment_tests.cpp index 569b9acd46..347343ca2e 100644 --- a/geometry/geometry_tests/parametrized_segment_tests.cpp +++ b/geometry/geometry_tests/parametrized_segment_tests.cpp @@ -53,17 +53,17 @@ UNIT_TEST(ParametrizedSegment2D_DegenerateSection) UNIT_TEST(ParametrizedSegment2D_ClosestPoint) { using P = m2::PointD; - + P arr[][4] = { { P(3, 4), P(0, 0), P(10, 0), P(3, 0) }, { P(3, 4), P(0, 0), P(0, 10), P(0, 4) }, - + { P(3, 5), P(2, 2), P(5, 5), P(4, 4) }, { P(5, 3), P(2, 2), P(5, 5), P(4, 4) }, { P(2, 4), P(2, 2), P(5, 5), P(3, 3) }, { P(4, 2), P(2, 2), P(5, 5), P(3, 3) }, - + { P(5, 6), P(2, 2), P(5, 5), P(5, 5) }, { P(1, 0), P(2, 2), P(5, 5), P(2, 2) } }; @@ -71,6 +71,6 @@ UNIT_TEST(ParametrizedSegment2D_ClosestPoint) for (size_t i = 0; i < ARRAY_SIZE(arr); ++i) { m2::ParametrizedSegment

segment(arr[i][1], arr[i][2]); - TEST(m2::AlmostEqualULPs(segment.ClosestPointTo(arr[i][0]), arr[i][3]), (i)); + TEST(AlmostEqualULPs(segment.ClosestPointTo(arr[i][0]), arr[i][3]), (i)); } } diff --git a/geometry/geometry_tests/point3d_tests.cpp b/geometry/geometry_tests/point3d_tests.cpp index 58f9213fb6..cef69d5ef0 100644 --- a/geometry/geometry_tests/point3d_tests.cpp +++ b/geometry/geometry_tests/point3d_tests.cpp @@ -92,7 +92,7 @@ UNIT_TEST(Point3d_RotateXYZ) TEST_ALMOST_EQUAL_ABS(rotatedFirst, m3::PointD(std::sqrt(2.0), 0.0, 1.0), 1e-10, ()); - double const angleDegree = base::RadToDeg(acos(rotatedFirst.z / rotatedFirst.Length())); + double const angleDegree = math::RadToDeg(acos(rotatedFirst.z / rotatedFirst.Length())); auto const north = rotatedFirst.RotateAroundY(-angleDegree); TEST_ALMOST_EQUAL_ABS(north, m3::PointD(0.0, 0.0, std::sqrt(3.0)), 1e-10, ()); diff --git a/geometry/geometry_tests/point_test.cpp b/geometry/geometry_tests/point_test.cpp index ebaeecfaea..4d8f88b948 100644 --- a/geometry/geometry_tests/point_test.cpp +++ b/geometry/geometry_tests/point_test.cpp @@ -66,32 +66,32 @@ UNIT_TEST(GetArrowPoints) { std::array arrPntsFlt; m2::GetArrowPoints(m2::PointF(0, 0), m2::PointF(1, 0), 1.f, 1.f, arrPntsFlt); - TEST(m2::AlmostEqualULPs(arrPntsFlt[0], m2::PointF(1.f, 1.f)), ()); - TEST(m2::AlmostEqualULPs(arrPntsFlt[1], m2::PointF(2.f, 0.f)), ()); - TEST(m2::AlmostEqualULPs(arrPntsFlt[2], m2::PointF(1.f, -1.f)), ()); + TEST(AlmostEqualULPs(arrPntsFlt[0], m2::PointF(1.f, 1.f)), ()); + TEST(AlmostEqualULPs(arrPntsFlt[1], m2::PointF(2.f, 0.f)), ()); + TEST(AlmostEqualULPs(arrPntsFlt[2], m2::PointF(1.f, -1.f)), ()); std::array arrPntsDbl; m2::GetArrowPoints(m2::PointD(-1., 2.), m2::PointD(-1., 100.), 2., 5., arrPntsDbl); - TEST(m2::AlmostEqualULPs(arrPntsDbl[0], m2::PointD(-3.f, 100.f)), ()); - TEST(m2::AlmostEqualULPs(arrPntsDbl[1], m2::PointD(-1.f, 105.f)), ()); - TEST(m2::AlmostEqualULPs(arrPntsDbl[2], m2::PointD(1.f, 100.f)), ()); + TEST(AlmostEqualULPs(arrPntsDbl[0], m2::PointD(-3.f, 100.f)), ()); + TEST(AlmostEqualULPs(arrPntsDbl[1], m2::PointD(-1.f, 105.f)), ()); + TEST(AlmostEqualULPs(arrPntsDbl[2], m2::PointD(1.f, 100.f)), ()); } UNIT_TEST(PointAtSegment) { - TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointF(0, 0), m2::PointF(1, 0), 0.5f), + TEST(AlmostEqualULPs(m2::PointAtSegment(m2::PointF(0, 0), m2::PointF(1, 0), 0.5f), m2::PointF(0.5f, 0.f)), ()); - TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointF(0, 0), m2::PointF(0, 1), 0.3f), + TEST(AlmostEqualULPs(m2::PointAtSegment(m2::PointF(0, 0), m2::PointF(0, 1), 0.3f), m2::PointF(0.f, 0.3f)), ()); - TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointD(0., 0.), m2::PointD(30., 40.), 5.), + TEST(AlmostEqualULPs(m2::PointAtSegment(m2::PointD(0., 0.), m2::PointD(30., 40.), 5.), m2::PointD(3., 4.)), ()); - TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointF(-3, -4), m2::PointF(-30, -40), 5.f), + TEST(AlmostEqualULPs(m2::PointAtSegment(m2::PointF(-3, -4), m2::PointF(-30, -40), 5.f), m2::PointF(-6.f, -8.f)), ()); - TEST(m2::AlmostEqualULPs(m2::PointAtSegment(m2::PointD(14., -48.), m2::PointD(70., -240.), 25.), + TEST(AlmostEqualULPs(m2::PointAtSegment(m2::PointD(14., -48.), m2::PointD(70., -240.), 25.), m2::PointD(21., -72.)), ()); } diff --git a/geometry/geometry_tests/polyline_tests.cpp b/geometry/geometry_tests/polyline_tests.cpp index 89c232f628..e873b1c6fa 100644 --- a/geometry/geometry_tests/polyline_tests.cpp +++ b/geometry/geometry_tests/polyline_tests.cpp @@ -33,7 +33,7 @@ UNIT_TEST(Rect_PolylineSmokeTest) auto const limitRect = poly.GetLimitRect(); TEST_ALMOST_EQUAL_ABS(limitRect.LeftBottom(), m2::PointD(0.0, 0.0), kEps, ()); - TEST(base::AlmostEqualAbs(limitRect.RightTop(), m2::PointD(1.0, 1.0), kEps), ()); + TEST(AlmostEqualAbs(limitRect.RightTop(), m2::PointD(1.0, 1.0), kEps), ()); poly.PopBack(); TEST_EQUAL(poly.GetSize(), 2, ()); diff --git a/geometry/geometry_tests/region_tests.cpp b/geometry/geometry_tests/region_tests.cpp index 45db0d9c47..523d85d992 100644 --- a/geometry/geometry_tests/region_tests.cpp +++ b/geometry/geometry_tests/region_tests.cpp @@ -328,7 +328,7 @@ UNIT_TEST(Region_GetRandomPoint) m2::ConvexHull const hull(points, 1e-9 /* eps */); auto const hullRegion = m2::Region

(hull.Points().begin(), hull.Points().end()); LOG(LINFO, (hullRegion.CalculateArea())); - TEST(base::AlmostEqualRel(region.CalculateArea(), hullRegion.CalculateArea(), 0.05), ()); + TEST(AlmostEqualRel(region.CalculateArea(), hullRegion.CalculateArea(), 0.05), ()); if (kNeedPlot) { diff --git a/geometry/geometry_tests/screen_test.cpp b/geometry/geometry_tests/screen_test.cpp index 8bdd8c9300..64f7ad2634 100644 --- a/geometry/geometry_tests/screen_test.cpp +++ b/geometry/geometry_tests/screen_test.cpp @@ -22,10 +22,10 @@ namespace b2 = screen.GtoP(b2); // check that we are in boundaries. - TEST(base::Between(0, width, base::SignedRound(b1.x)), ()); - TEST(base::Between(0, width, base::SignedRound(b2.x)), ()); - TEST(base::Between(0, height, base::SignedRound(b1.y)), ()); - TEST(base::Between(0, height, base::SignedRound(b2.y)), ()); + TEST(math::Between(0, width, math::SignedRound(b1.x)), ()); + TEST(math::Between(0, width, math::SignedRound(b2.x)), ()); + TEST(math::Between(0, height, math::SignedRound(b1.y)), ()); + TEST(math::Between(0, height, math::SignedRound(b2.y)), ()); } } diff --git a/geometry/geometry_tests/vector_test.cpp b/geometry/geometry_tests/vector_test.cpp index 6cd493acaf..bf58ff9987 100644 --- a/geometry/geometry_tests/vector_test.cpp +++ b/geometry/geometry_tests/vector_test.cpp @@ -9,7 +9,7 @@ bool EqualArrays(T (&a1)[N], T (&a2)[N]) { for (size_t i = 0; i < N; ++i) { - if (!base::AlmostEqualULPs(a1[i], a2[i])) + if (!AlmostEqualULPs(a1[i], a2[i])) return false; } return true; diff --git a/geometry/latlon.cpp b/geometry/latlon.cpp index a2a0c62fbb..29ff4b46e5 100644 --- a/geometry/latlon.cpp +++ b/geometry/latlon.cpp @@ -1,5 +1,7 @@ #include "latlon.hpp" +#include "base/math.hpp" + #include #include @@ -14,7 +16,7 @@ bool LatLon::operator<(ms::LatLon const & rhs) const bool LatLon::EqualDxDy(LatLon const & p, double eps) const { - return (base::AlmostEqualAbs(m_lat, p.m_lat, eps) && base::AlmostEqualAbs(m_lon, p.m_lon, eps)); + return (::AlmostEqualAbs(m_lat, p.m_lat, eps) && ::AlmostEqualAbs(m_lon, p.m_lon, eps)); } std::string DebugPrint(LatLon const & t) @@ -24,13 +26,10 @@ std::string DebugPrint(LatLon const & t) out << "ms::LatLon(" << t.m_lat << ", " << t.m_lon << ")"; return out.str(); } -} // namespace ms -namespace base +bool AlmostEqualAbs(LatLon const & ll1, LatLon const & ll2, double const & eps) { -bool AlmostEqualAbs(ms::LatLon const & ll1, ms::LatLon const & ll2, double const & eps) -{ - return base::AlmostEqualAbs(ll1.m_lat, ll2.m_lat, eps) && - base::AlmostEqualAbs(ll1.m_lon, ll2.m_lon, eps); + return ::AlmostEqualAbs(ll1.m_lat, ll2.m_lat, eps) && + ::AlmostEqualAbs(ll1.m_lon, ll2.m_lon, eps); } -} // namespace base +} // namespace ms diff --git a/geometry/latlon.hpp b/geometry/latlon.hpp index eff4555ca9..13637e0427 100644 --- a/geometry/latlon.hpp +++ b/geometry/latlon.hpp @@ -20,28 +20,25 @@ public: double m_lat = kInvalid; double m_lon = kInvalid; - LatLon() = default; - LatLon(double lat, double lon) : m_lat(lat), m_lon(lon) {} + constexpr LatLon() = default; + constexpr LatLon(double lat, double lon) : m_lat(lat), m_lon(lon) {} - static LatLon Invalid() { return LatLon(kInvalid, kInvalid); } - static LatLon Zero() { return LatLon(0.0, 0.0); } + static constexpr LatLon Invalid() { return LatLon(kInvalid, kInvalid); } + static constexpr LatLon Zero() { return LatLon(0.0, 0.0); } - bool IsValid() const { return m_lat != kInvalid && m_lon != kInvalid; } - bool operator==(ms::LatLon const & rhs) const; - bool operator<(ms::LatLon const & rhs) const; + bool constexpr IsValid() const { return m_lat != kInvalid && m_lon != kInvalid; } + bool operator==(LatLon const & rhs) const; + bool operator<(LatLon const & rhs) const; bool EqualDxDy(LatLon const & p, double eps) const; struct Hash { - size_t operator()(ms::LatLon const & p) const { return base::Hash(p.m_lat, p.m_lon); } + size_t operator()(ms::LatLon const & p) const { return math::Hash(p.m_lat, p.m_lon); } }; }; +bool AlmostEqualAbs(LatLon const & ll1, LatLon const & ll2, double const & eps); + std::string DebugPrint(LatLon const & t); } // namespace ms - -namespace base -{ -bool AlmostEqualAbs(ms::LatLon const & ll1, ms::LatLon const & ll2, double const & eps); -} // namespace base diff --git a/geometry/mercator.cpp b/geometry/mercator.cpp index 262240320f..9f2003ede2 100644 --- a/geometry/mercator.cpp +++ b/geometry/mercator.cpp @@ -18,7 +18,7 @@ m2::RectD MetersToXY(double lon, double lat, double lonMetersR, double latMeters double const minLat = max(-90.0, lat - latDegreeOffset); double const maxLat = min(90.0, lat + latDegreeOffset); - double const cosL = max(cos(base::DegToRad(max(fabs(minLat), fabs(maxLat)))), 0.00001); + double const cosL = max(cos(math::DegToRad(max(fabs(minLat), fabs(maxLat)))), 0.00001); ASSERT_GREATER(cosL, 0.0, ()); double const lonDegreeOffset = lonMetersR * Bounds::kDegreesInMeter / cosL; @@ -38,7 +38,7 @@ m2::PointD GetSmPoint(m2::PointD const & pt, double lonMetersR, double latMeters double const latDegreeOffset = latMetersR * Bounds::kDegreesInMeter; double const newLat = min(90.0, max(-90.0, lat + latDegreeOffset)); - double const cosL = max(cos(base::DegToRad(newLat)), 0.00001); + double const cosL = max(cos(math::DegToRad(newLat)), 0.00001); ASSERT_GREATER(cosL, 0.0, ()); double const lonDegreeOffset = lonMetersR * Bounds::kDegreesInMeter / cosL; @@ -71,13 +71,13 @@ void ClampPoint(m2::PointD & pt) double YToLat(double y) { - return base::RadToDeg(2.0 * atan(tanh(0.5 * base::DegToRad(y)))); + return math::RadToDeg(2.0 * atan(tanh(0.5 * math::DegToRad(y)))); } double LatToY(double lat) { - double const sinx = sin(base::DegToRad(base::Clamp(lat, -86.0, 86.0))); - double const res = base::RadToDeg(0.5 * log((1.0 + sinx) / (1.0 - sinx))); + double const sinx = sin(math::DegToRad(math::Clamp(lat, -86.0, 86.0))); + double const res = math::RadToDeg(0.5 * log((1.0 + sinx) / (1.0 - sinx))); return ClampY(res); } diff --git a/geometry/mercator.hpp b/geometry/mercator.hpp index 067a7be71d..d65f459f28 100644 --- a/geometry/mercator.hpp +++ b/geometry/mercator.hpp @@ -30,14 +30,14 @@ struct Bounds } }; -inline bool ValidLon(double d) { return base::Between(-180.0, 180.0, d); } -inline bool ValidLat(double d) { return base::Between(-90.0, 90.0, d); } +inline bool ValidLon(double d) { return math::Between(-180.0, 180.0, d); } +inline bool ValidLat(double d) { return math::Between(-90.0, 90.0, d); } -inline bool ValidX(double d) { return base::Between(Bounds::kMinX, Bounds::kMaxX, d); } -inline bool ValidY(double d) { return base::Between(Bounds::kMinY, Bounds::kMaxY, d); } +inline bool ValidX(double d) { return math::Between(Bounds::kMinX, Bounds::kMaxX, d); } +inline bool ValidY(double d) { return math::Between(Bounds::kMinY, Bounds::kMaxY, d); } -inline double ClampX(double d) { return base::Clamp(d, Bounds::kMinX, Bounds::kMaxX); } -inline double ClampY(double d) { return base::Clamp(d, Bounds::kMinY, Bounds::kMaxY); } +inline double ClampX(double d) { return math::Clamp(d, Bounds::kMinX, Bounds::kMaxX); } +inline double ClampY(double d) { return math::Clamp(d, Bounds::kMinY, Bounds::kMaxY); } void ClampPoint(m2::PointD & pt); diff --git a/geometry/oblate_spheroid.cpp b/geometry/oblate_spheroid.cpp index d1898bd035..1bed930bc8 100644 --- a/geometry/oblate_spheroid.cpp +++ b/geometry/oblate_spheroid.cpp @@ -32,6 +32,7 @@ double GetDistance(ms::LatLon const & point1, ms::LatLon const & point2) { using namespace base; using namespace std; + using math::DegToRad, math::Pow2; m2::PointD const p1 = {DegToRad(point1.m_lon), DegToRad(point1.m_lat)}; m2::PointD const p2 = {DegToRad(point2.m_lon), DegToRad(point2.m_lat)}; @@ -81,7 +82,7 @@ double GetDistance(ms::LatLon const & point1, ms::LatLon const & point2) // Fallback solution. if (!AlmostEqualAbs(lambda, lambdaPrev, kEps)) - return ms::DistanceOnEarth(point1, point2); + return DistanceOnEarth(point1, point2); double constexpr aSquare = kA * kA; double constexpr bSquare = kB * kB; diff --git a/geometry/parametrized_segment.hpp b/geometry/parametrized_segment.hpp index 7b62a2bf07..35d858f3e3 100644 --- a/geometry/parametrized_segment.hpp +++ b/geometry/parametrized_segment.hpp @@ -50,7 +50,7 @@ public: return (p - m_p1).SquaredLength(); // Closest point is between |m_p0| and |m_p1|. - return base::Pow2(CrossProduct(diff, m_d)); + return math::Pow2(CrossProduct(diff, m_d)); } // Returns the point of the segment that is closest to |p|. diff --git a/geometry/point2d.hpp b/geometry/point2d.hpp index 0b498eeb81..3a08575d44 100644 --- a/geometry/point2d.hpp +++ b/geometry/point2d.hpp @@ -36,7 +36,7 @@ public: return ((fabs(x - p.x) < eps) && (fabs(y - p.y) < eps)); } - T SquaredLength(Point const & p) const { return base::Pow2(x - p.x) + base::Pow2(y - p.y); } + T SquaredLength(Point const & p) const { return math::Pow2(x - p.x) + math::Pow2(y - p.y); } double Length(Point const & p) const { return std::sqrt(SquaredLength(p)); } bool IsAlmostZero() const { return AlmostEqualULPs(*this, Point(0, 0)); } @@ -158,7 +158,7 @@ public: struct Hash { - size_t operator()(m2::Point const & p) const { return base::Hash(p.x, p.y); } + size_t operator()(Point const & p) const { return math::Hash(p.x, p.y); } }; }; @@ -170,31 +170,31 @@ using PointI = Point; using PointI64 = Point; template -Point const operator-(Point const & a, Point const & b) +Point operator-(Point const & a, Point const & b) { return Point(a.x - b.x, a.y - b.y); } template -Point const operator+(Point const & a, Point const & b) +Point operator+(Point const & a, Point const & b) { return Point(a.x + b.x, a.y + b.y); } template -T const DotProduct(Point const & a, Point const & b) +T DotProduct(Point const & a, Point const & b) { return a.x * b.x + a.y * b.y; } template -T const CrossProduct(Point const & a, Point const & b) +T CrossProduct(Point const & a, Point const & b) { return a.x * b.y - a.y * b.x; } template -Point const Rotate(Point const & pt, T a) +Point Rotate(Point const & pt, T a) { Point res(pt); res.Rotate(a); @@ -202,19 +202,19 @@ Point const Rotate(Point const & pt, T a) } template -Point const Shift(Point const & pt, U const & dx, U const & dy) +Point Shift(Point const & pt, U const & dx, U const & dy) { return Point(pt.x + dx, pt.y + dy); } template -Point const Shift(Point const & pt, Point const & offset) +Point Shift(Point const & pt, Point const & offset) { return Shift(pt, offset.x, offset.y); } template -Point const Floor(Point const & pt) +Point Floor(Point const & pt) { Point res; res.x = floor(pt.x); @@ -223,7 +223,7 @@ Point const Floor(Point const & pt) } template -std::string DebugPrint(m2::Point const & p) +std::string DebugPrint(Point const & p) { std::ostringstream out; out.precision(20); @@ -232,15 +232,15 @@ std::string DebugPrint(m2::Point const & p) } template -bool AlmostEqualAbs(m2::Point const & a, m2::Point const & b, double eps) +bool AlmostEqualAbs(Point const & a, Point const & b, double eps) { - return base::AlmostEqualAbs(a.x, b.x, eps) && base::AlmostEqualAbs(a.y, b.y, eps); + return ::AlmostEqualAbs(a.x, b.x, eps) && ::AlmostEqualAbs(a.y, b.y, eps); } template -bool AlmostEqualULPs(m2::Point const & a, m2::Point const & b, unsigned int maxULPs = 256) +bool AlmostEqualULPs(Point const & a, Point const & b, unsigned int maxULPs = 256) { - return base::AlmostEqualULPs(a.x, b.x, maxULPs) && base::AlmostEqualULPs(a.y, b.y, maxULPs); + return ::AlmostEqualULPs(a.x, b.x, maxULPs) && ::AlmostEqualULPs(a.y, b.y, maxULPs); } /// Calculate three points of a triangle (p1, p2 and p3) which give an arrow that @@ -250,7 +250,7 @@ bool AlmostEqualULPs(m2::Point const & a, m2::Point const & b, unsigned in template > void GetArrowPoints(PointT const & b, PointT const & e, T w, T l, std::array, 3> & arr) { - ASSERT(!m2::AlmostEqualULPs(b, e), ()); + ASSERT(!AlmostEqualULPs(b, e), ()); PointT const beVec = e - b; PointT beNormalizedVec = beVec.Normalize(); @@ -268,12 +268,12 @@ template Point PointAtSegment(Point const & p1, Point const & p2, T shiftFromP1) { Point p12 = p2 - p1; - shiftFromP1 = base::Clamp(shiftFromP1, static_cast(0.0), static_cast(p12.Length())); + shiftFromP1 = math::Clamp(shiftFromP1, static_cast(0.0), static_cast(p12.Length())); return p1 + p12.Normalize() * shiftFromP1; } template -TArchive & operator>>(TArchive & ar, m2::Point & pt) +TArchive & operator>>(TArchive & ar, Point & pt) { ar >> pt.x; ar >> pt.y; @@ -281,7 +281,7 @@ TArchive & operator>>(TArchive & ar, m2::Point & pt) } template -TArchive & operator<<(TArchive & ar, m2::Point const & pt) +TArchive & operator<<(TArchive & ar, Point const & pt) { ar << pt.x; ar << pt.y; @@ -296,18 +296,3 @@ bool operator<(Point const & l, Point const & r) return l.y < r.y; } } // namespace m2 - -namespace base -{ -template -bool AlmostEqualULPs(m2::Point const & p1, m2::Point const & p2, unsigned int maxULPs = 256) -{ - return m2::AlmostEqualULPs(p1, p2, maxULPs); -} - -template -bool AlmostEqualAbs(m2::Point const & p1, m2::Point const & p2, double eps) -{ - return m2::AlmostEqualAbs(p1, p2, eps); -} -} // namespace base diff --git a/geometry/point3d.hpp b/geometry/point3d.hpp index bbd4fefe20..f8fc286a63 100644 --- a/geometry/point3d.hpp +++ b/geometry/point3d.hpp @@ -31,7 +31,7 @@ public: template Point Point::RotateAroundX(double angleDegree) const { - double const angleRad = base::DegToRad(angleDegree); + double const angleRad = math::DegToRad(angleDegree); Point res; res.x = x; res.y = y * cos(angleRad) - z * sin(angleRad); @@ -42,7 +42,7 @@ Point Point::RotateAroundX(double angleDegree) const template Point Point::RotateAroundY(double angleDegree) const { - double const angleRad = base::DegToRad(angleDegree); + double const angleRad = math::DegToRad(angleDegree); Point res; res.x = x * cos(angleRad) + z * sin(angleRad); res.y = y; @@ -53,7 +53,7 @@ Point Point::RotateAroundY(double angleDegree) const template Point Point::RotateAroundZ(double angleDegree) const { - double const angleRad = base::DegToRad(angleDegree); + double const angleRad = math::DegToRad(angleDegree); Point res; res.x = x * cos(angleRad) - y * sin(angleRad); res.y = x * sin(angleRad) + y * cos(angleRad); @@ -93,14 +93,11 @@ std::string DebugPrint(Point const & p) out << "m3::Point<" << typeid(T).name() << ">(" << p.x << ", " << p.y << ", " << p.z << ")"; return out.str(); } -} // namespace m3 -namespace base -{ template -bool AlmostEqualAbs(m3::Point const & p1, m3::Point const & p2, double const & eps) +bool AlmostEqualAbs(Point const & p1, Point const & p2, double const & eps) { - return base::AlmostEqualAbs(p1.x, p2.x, eps) && base::AlmostEqualAbs(p1.y, p2.y, eps) && - base::AlmostEqualAbs(p1.z, p2.z, eps); + return ::AlmostEqualAbs(p1.x, p2.x, eps) && ::AlmostEqualAbs(p1.y, p2.y, eps) && + ::AlmostEqualAbs(p1.z, p2.z, eps); } -} // namespace base +} // namespace m3 diff --git a/geometry/polygon.hpp b/geometry/polygon.hpp index 10fcf1c366..6228fa1151 100644 --- a/geometry/polygon.hpp +++ b/geometry/polygon.hpp @@ -16,17 +16,17 @@ bool FindSingleStripForIndex(size_t i, size_t n, IsVisibleF isVisible) { // Searching for a strip only in a single direction, because the opposite direction // is traversed from the last vertex of the possible strip. - size_t a = base::PrevModN(i, n); - size_t b = base::NextModN(i, n); + size_t a = math::PrevModN(i, n); + size_t b = math::NextModN(i, n); for (size_t j = 2; j < n; ++j) { ASSERT_NOT_EQUAL(a, b, ()); if (!isVisible(a, b)) return false; if (j & 1) - a = base::PrevModN(a, n); + a = math::PrevModN(a, n); else - b = base::NextModN(b, n); + b = math::NextModN(b, n); } ASSERT_EQUAL(a, b, ()); diff --git a/geometry/rect2d.hpp b/geometry/rect2d.hpp index 3c2287499c..cb72b68ae6 100644 --- a/geometry/rect2d.hpp +++ b/geometry/rect2d.hpp @@ -195,8 +195,8 @@ public: void SetSizesToIncludePoint(Point const & pt) { Point const c = Center(); - T const dx = base::Abs(pt.x - c.x); - T const dy = base::Abs(pt.y - c.y); + T const dx = math::Abs(pt.x - c.x); + T const dy = math::Abs(pt.y - c.y); m_minX = c.x - dx; m_minY = c.y - dy; diff --git a/geometry/region2d.hpp b/geometry/region2d.hpp index 40154c97f7..255ce84add 100644 --- a/geometry/region2d.hpp +++ b/geometry/region2d.hpp @@ -27,8 +27,8 @@ struct DefEqualFloat { static_assert(std::is_floating_point::value, ""); - return base::AlmostEqualAbs(p1.x, p2.x, static_cast(kPrecision)) && - base::AlmostEqualAbs(p1.y, p2.y, static_cast(kPrecision)); + return ::AlmostEqualAbs(p1.x, p2.x, static_cast(kPrecision)) && + ::AlmostEqualAbs(p1.y, p2.y, static_cast(kPrecision)); } template @@ -36,7 +36,7 @@ struct DefEqualFloat { static_assert(std::is_floating_point::value, ""); - return base::AlmostEqualAbs(val, 0.0, kPrecision * kPrecision); + return ::AlmostEqualAbs(val, 0.0, kPrecision * kPrecision); } // Determines if value of a val lays between a p1 and a p2 values with some precision. bool IsAlmostBetween(double val, double p1, double p2) const @@ -322,7 +322,7 @@ public: area += CrossProduct(prev, curr); prev = curr; } - area = base::Abs(area) / 2; + area = math::Abs(area) / 2; return area; } diff --git a/geometry/screenbase.cpp b/geometry/screenbase.cpp index a79cfec33e..2eaaac0b60 100644 --- a/geometry/screenbase.cpp +++ b/geometry/screenbase.cpp @@ -218,11 +218,11 @@ void ScreenBase::SetAngle(double angle) UpdateDependentParameters(); } -int ScreenBase::GetWidth() const { return base::SignedRound(m_PixelRect.SizeX()); } +int ScreenBase::GetWidth() const { return math::SignedRound(m_PixelRect.SizeX()); } -int ScreenBase::GetHeight() const { return base::SignedRound(m_PixelRect.SizeY()); } +int ScreenBase::GetHeight() const { return math::SignedRound(m_PixelRect.SizeY()); } -ScreenBase::MatrixT const ScreenBase::CalcTransform(m2::PointD const & oldPt1, +ScreenBase::MatrixT ScreenBase::CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, m2::PointD const & newPt1, m2::PointD const & newPt2, bool allowRotate) diff --git a/geometry/screenbase.hpp b/geometry/screenbase.hpp index d0418031ee..bfcaba80ba 100644 --- a/geometry/screenbase.hpp +++ b/geometry/screenbase.hpp @@ -61,7 +61,7 @@ public: void PtoG(double & x, double & y) const { - double tempX = x; + double const tempX = x; x = tempX * m_PtoG(0, 0) + y * m_PtoG(1, 0) + m_PtoG(2, 0); y = tempX * m_PtoG(0, 1) + y * m_PtoG(1, 1) + m_PtoG(2, 1); } @@ -122,7 +122,7 @@ public: /// Compute arbitrary pixel transformation, that translates the (oldPt1, oldPt2) -> (newPt1, /// newPt2) - static MatrixT const CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, + static MatrixT CalcTransform(m2::PointD const & oldPt1, m2::PointD const & oldPt2, m2::PointD const & newPt1, m2::PointD const & newPt2, bool allowRotate); diff --git a/indexer/cell_id.hpp b/indexer/cell_id.hpp index 20b96567a3..a3f519a112 100644 --- a/indexer/cell_id.hpp +++ b/indexer/cell_id.hpp @@ -68,10 +68,10 @@ public: #if 0 // DEBUG double minX, minY, maxX, maxY; GetCellBounds(id1, minX, minY, maxX, maxY); - ASSERT(base::Between(minX, maxX, x1), (x1, minX, maxX)); - ASSERT(base::Between(minX, maxX, x2), (x2, minX, maxX)); - ASSERT(base::Between(minY, maxY, y1), (y1, minY, maxY)); - ASSERT(base::Between(minY, maxY, y2), (y2, minY, maxY)); + ASSERT(math::Between(minX, maxX, x1), (x1, minX, maxX)); + ASSERT(math::Between(minX, maxX, x2), (x2, minX, maxX)); + ASSERT(math::Between(minY, maxY, y1), (y1, minY, maxY)); + ASSERT(math::Between(minY, maxY, y2), (y2, minY, maxY)); #endif return id1; } diff --git a/indexer/feature_impl.cpp b/indexer/feature_impl.cpp index 8cebd6a47d..adf65b7add 100644 --- a/indexer/feature_impl.cpp +++ b/indexer/feature_impl.cpp @@ -7,7 +7,7 @@ namespace feature uint8_t PopulationToRank(uint64_t p) { - return static_cast(std::min(0xFF, base::SignedRound(log(double(p)) / log(1.1)))); + return static_cast(std::min(0xFF, math::SignedRound(log(double(p)) / log(1.1)))); } uint64_t RankToPopulation(uint8_t r) diff --git a/indexer/ftypes_matcher.cpp b/indexer/ftypes_matcher.cpp index 5f65f0caec..9236b30d93 100644 --- a/indexer/ftypes_matcher.cpp +++ b/indexer/ftypes_matcher.cpp @@ -900,7 +900,7 @@ double GetRadiusByPopulationForRouting(uint64_t p, LocalityType localityType) uint64_t GetPopulationByRadius(double r) { - return base::SignedRound(pow(r / 550.0, 3.6)); + return math::SignedRound(pow(r / 550.0, 3.6)); } } // namespace ftypes diff --git a/indexer/indexer_tests/trie_test.cpp b/indexer/indexer_tests/trie_test.cpp index b772912a31..9eb545cd3b 100644 --- a/indexer/indexer_tests/trie_test.cpp +++ b/indexer/indexer_tests/trie_test.cpp @@ -163,7 +163,7 @@ UNIT_TEST(TrieBuilder_Build) vector possibleStrings(1, string{}); for (int len = 1; len <= kMaxLen; ++len) { - for (uint32_t i = 0, p = base::PowUint(kBase, len); i < p; ++i) + for (uint32_t i = 0, p = math::PowUint(kBase, len); i < p; ++i) { string s(len, 'A'); uint32_t t = i; diff --git a/indexer/scales.cpp b/indexer/scales.cpp index 25983b065e..1255b90ef1 100644 --- a/indexer/scales.cpp +++ b/indexer/scales.cpp @@ -33,12 +33,12 @@ namespace scales int GetScaleLevel(double ratio) { - return base::SignedRound(GetScaleLevelD(ratio)); + return math::SignedRound(GetScaleLevelD(ratio)); } int GetScaleLevel(m2::RectD const & r) { - return base::SignedRound(GetScaleLevelD(r)); + return math::SignedRound(GetScaleLevelD(r)); } namespace diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm index bfea45c39b..674fd77408 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideButtons/MWMSideButtonsView.mm @@ -30,7 +30,7 @@ CGFloat const kButtonsBottomOffset = 6; - (void)layoutSubviews { CGFloat spacing = self.availableHeight - self.zoomOut.maxY - self.location.height; - spacing = base::Clamp(spacing, kLocationButtonSpacingMin, kLocationButtonSpacingMax); + spacing = math::Clamp(spacing, kLocationButtonSpacingMin, kLocationButtonSpacingMax); self.location.minY = self.zoomOut.maxY + spacing; self.bounds = {{}, {self.zoomOut.width, self.location.maxY}}; diff --git a/iphone/Maps/Core/Location/location_util.h b/iphone/Maps/Core/Location/location_util.h index a30a2524e3..d8752b3540 100644 --- a/iphone/Maps/Core/Location/location_util.h +++ b/iphone/Maps/Core/Location/location_util.h @@ -32,9 +32,9 @@ static location::CompassInfo compassInfoFromHeading(CLHeading * h) { location::CompassInfo info; if (h.trueHeading >= 0.0) - info.m_bearing = base::DegToRad(h.trueHeading); + info.m_bearing = math::DegToRad(h.trueHeading); else if (h.headingAccuracy >= 0.0) - info.m_bearing = base::DegToRad(h.magneticHeading); + info.m_bearing = math::DegToRad(h.magneticHeading); return info; } diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index a40b96e72a..6359f04f0e 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -851,7 +851,7 @@ void BookmarkManager::UpdateElevationMyPosition(kml::TrackId const & trackId) auto trackSelectionMark = GetMarkForEdit(markId); double const kEpsMeters = 1e-2; - if (!base::AlmostEqualAbs(trackSelectionMark->GetMyPositionDistance(), + if (!AlmostEqualAbs(trackSelectionMark->GetMyPositionDistance(), myPositionDistance, kEpsMeters)) { trackSelectionMark->SetMyPositionDistance(myPositionDistance); diff --git a/map/chart_generator.cpp b/map/chart_generator.cpp index 71cc1b7b1a..86d68d7821 100644 --- a/map/chart_generator.cpp +++ b/map/chart_generator.cpp @@ -145,7 +145,7 @@ bool NormalizeChartData(vector const & distanceDataM, ASSERT_LESS(0, nextPointIdx, ("distFormStartM is greater than 0 but nextPointIdx == 0.")); size_t const prevPointIdx = nextPointIdx - 1; - if (base::AlmostEqualAbs(distanceDataM[prevPointIdx], distanceDataM[nextPointIdx], kEpsilon)) + if (AlmostEqualAbs(distanceDataM[prevPointIdx], distanceDataM[nextPointIdx], kEpsilon)) return static_cast(altitudeDataM[prevPointIdx]); double const k = (altitudeDataM[nextPointIdx] - altitudeDataM[prevPointIdx]) / diff --git a/map/extrapolation/extrapolator.cpp b/map/extrapolation/extrapolator.cpp index 3f3fc2ada2..415cb289aa 100644 --- a/map/extrapolation/extrapolator.cpp +++ b/map/extrapolation/extrapolator.cpp @@ -63,9 +63,9 @@ location::GpsInfo LinearExtrapolation(location::GpsInfo const & gpsInfo1, result.m_timestamp += static_cast(timeAfterPoint2Ms) / 1000.0; result.m_longitude = - base::Clamp(e.Extrapolate(gpsInfo1.m_longitude, gpsInfo2.m_longitude), -180.0, 180.0); + math::Clamp(e.Extrapolate(gpsInfo1.m_longitude, gpsInfo2.m_longitude), -180.0, 180.0); result.m_latitude = - base::Clamp(e.Extrapolate(gpsInfo1.m_latitude, gpsInfo2.m_latitude), -90.0, 90.0); + math::Clamp(e.Extrapolate(gpsInfo1.m_latitude, gpsInfo2.m_latitude), -90.0, 90.0); result.m_altitude = e.Extrapolate(gpsInfo1.m_altitude, gpsInfo2.m_altitude); // @TODO(bykoianko) Now |result.m_bearing| == |gpsInfo2.m_bearing|. diff --git a/map/extrapolation_benchmark/extrapolation_benchmark.cpp b/map/extrapolation_benchmark/extrapolation_benchmark.cpp index 3120f83642..f581a25efb 100644 --- a/map/extrapolation_benchmark/extrapolation_benchmark.cpp +++ b/map/extrapolation_benchmark/extrapolation_benchmark.cpp @@ -317,7 +317,7 @@ int main(int argc, char * argv[]) ("Cumulative moving average, variance and standard deviation for each extrapolation:")); for (size_t i = 0; i < extrapolationNumber; ++i) { - double const variance = squareMes.Get()[i].Get() - base::Pow2(mes.Get()[i].Get()); + double const variance = squareMes.Get()[i].Get() - math::Pow2(mes.Get()[i].Get()); LOG(LINFO, ("Extrapolation", i + 1, ",", Extrapolator::kExtrapolationPeriodMs * (i + 1), "seconds after point two. Cumulative moving average =", mes.Get()[i].Get(), "meters.", diff --git a/map/framework.cpp b/map/framework.cpp index dc68173bbb..efdd22c79b 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2335,7 +2335,7 @@ void Framework::PredictLocation(double & lat, double & lon, double accuracy, double bearing, double speed, double elapsedSeconds) { double offsetInM = speed * elapsedSeconds; - double angle = base::DegToRad(90.0 - bearing); + double angle = math::DegToRad(90.0 - bearing); m2::PointD mercatorPt = mercator::MetersToXY(lon, lat, accuracy).Center(); mercatorPt = mercator::GetSmPoint(mercatorPt, offsetInM * cos(angle), offsetInM * sin(angle)); diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp index 16f488911a..4204544178 100644 --- a/map/map_tests/bookmarks_test.cpp +++ b/map/map_tests/bookmarks_test.cpp @@ -170,8 +170,8 @@ void CheckBookmarks(BookmarkManager const & bmManager, kml::MarkGroupId groupId) m2::PointD org = bm->GetPivot(); double constexpr kEps = 1e-6; - TEST(base::AlmostEqualAbs(mercator::XToLon(org.x), 27.566765, kEps), ()); - TEST(base::AlmostEqualAbs(mercator::YToLat(org.y), 53.900047, kEps), ()); + TEST(AlmostEqualAbs(mercator::XToLon(org.x), 27.566765, kEps), ()); + TEST(AlmostEqualAbs(mercator::YToLat(org.y), 53.900047, kEps), ()); TEST_EQUAL(kml::GetDefaultStr(bm->GetName()), "From: Минск, Минская область, Беларусь", ()); TEST_EQUAL(bm->GetColor(), kml::PredefinedColor::Blue, ()); TEST(bm->GetDescription().empty(), ()); @@ -179,8 +179,8 @@ void CheckBookmarks(BookmarkManager const & bmManager, kml::MarkGroupId groupId) bm = bmManager.GetBookmark(*it++); org = bm->GetPivot(); - TEST(base::AlmostEqualAbs(mercator::XToLon(org.x), 27.551532, kEps), ()); - TEST(base::AlmostEqualAbs(mercator::YToLat(org.y), 53.89306, kEps), ()); + TEST(AlmostEqualAbs(mercator::XToLon(org.x), 27.551532, kEps), ()); + TEST(AlmostEqualAbs(mercator::YToLat(org.y), 53.89306, kEps), ()); TEST_EQUAL(kml::GetDefaultStr(bm->GetName()), "", ()); TEST_EQUAL(bm->GetDescription(), "Amps & ", ()); TEST_EQUAL(kml::ToSecondsSinceEpoch(bm->GetTimeStamp()), 0, ()); @@ -377,7 +377,7 @@ UNIT_TEST(Bookmarks_Getting) fm.ShowRect(m2::RectD(0, 0, 80, 40)); // This is not correct because Framework::OnSize doesn't work until SetRenderPolicy is called. - //TEST(m2::AlmostEqualULPs(m2::PointD(400, 200), pixC), (pixC)); + //TEST(AlmostEqualULPs(m2::PointD(400, 200), pixC), (pixC)); BookmarkManager & bmManager = fm.GetBookmarkManager(); bmManager.EnableTestMode(true); @@ -1058,7 +1058,7 @@ char const * kmlString3 = return false; if (b1.GetScale() != b2.GetScale()) return false; - if (!base::AlmostEqualAbs(b1.GetPivot(), b2.GetPivot(), 1e-6 /* eps*/)) + if (!AlmostEqualAbs(b1.GetPivot(), b2.GetPivot(), 1e-6 /* eps*/)) return false; // do not check timestamp diff --git a/map/map_tests/chart_generator_tests.cpp b/map/map_tests/chart_generator_tests.cpp index 36a302e915..88054ef349 100644 --- a/map/map_tests/chart_generator_tests.cpp +++ b/map/map_tests/chart_generator_tests.cpp @@ -8,14 +8,15 @@ #include #include -using namespace std; +namespace chart_generator_tests +{ +using std::vector; +using maps::kAltitudeChartBPP; namespace { double constexpr kEpsilon = 0.00001; -using namespace maps; - bool AlmostEqualAbs(vector const & v1, vector const & v2) { if (v1.size() != v2.size()) @@ -23,7 +24,7 @@ bool AlmostEqualAbs(vector const & v1, vector const & v2) for (size_t i = 0; i < v1.size(); ++i) { - if (!base::AlmostEqualAbs(v1[i], v2[i], kEpsilon)) + if (!::AlmostEqualAbs(v1[i], v2[i], kEpsilon)) return false; } return true; @@ -50,6 +51,7 @@ void TestAngleColors(size_t width, size_t height, vector const & frameB TEST(IsColor(frameBuffer, kAltitudeChartBPP * height * width - kAltitudeChartBPP /* startColorIdx */, expectedR, expectedG, expectedB, expectedA), ()); } +} // namespace UNIT_TEST(ScaleChartData_Test) { @@ -261,4 +263,4 @@ UNIT_TEST(GenerateChart_Test) 230 /* expectedG */, 140 /* expectedB */, 255 /* expectedA */), ()); } -} // namespace +} // namespace chart_generator_tests diff --git a/map/map_tests/extrapolator_tests.cpp b/map/map_tests/extrapolator_tests.cpp index 0ec2f84939..887d413a2e 100644 --- a/map/map_tests/extrapolator_tests.cpp +++ b/map/map_tests/extrapolator_tests.cpp @@ -15,14 +15,14 @@ void TestGpsInfo(GpsInfo const & tested, GpsInfo const & expected) { double constexpr kEpsilon = 1e-5; TEST_EQUAL(tested.m_source, expected.m_source, ()); - TEST(base::AlmostEqualAbs(tested.m_latitude, expected.m_latitude, kEpsilon), ()); - TEST(base::AlmostEqualAbs(tested.m_longitude, expected.m_longitude, kEpsilon), ()); - TEST(base::AlmostEqualAbs(tested.m_horizontalAccuracy, expected.m_horizontalAccuracy, kEpsilon), + TEST(AlmostEqualAbs(tested.m_latitude, expected.m_latitude, kEpsilon), ()); + TEST(AlmostEqualAbs(tested.m_longitude, expected.m_longitude, kEpsilon), ()); + TEST(AlmostEqualAbs(tested.m_horizontalAccuracy, expected.m_horizontalAccuracy, kEpsilon), ()); - TEST(base::AlmostEqualAbs(tested.m_altitude, expected.m_altitude, kEpsilon), ()); - TEST(base::AlmostEqualAbs(tested.m_verticalAccuracy, expected.m_verticalAccuracy, kEpsilon), ()); - TEST(base::AlmostEqualAbs(tested.m_bearing, expected.m_bearing, kEpsilon), ()); - TEST(base::AlmostEqualAbs(tested.m_speed, expected.m_speed, kEpsilon), ()); + TEST(AlmostEqualAbs(tested.m_altitude, expected.m_altitude, kEpsilon), ()); + TEST(AlmostEqualAbs(tested.m_verticalAccuracy, expected.m_verticalAccuracy, kEpsilon), ()); + TEST(AlmostEqualAbs(tested.m_bearing, expected.m_bearing, kEpsilon), ()); + TEST(AlmostEqualAbs(tested.m_speed, expected.m_speed, kEpsilon), ()); } GpsInfo GetGpsInfo(double timestampS, double lat, double lon, double altitude, double speed) diff --git a/map/map_tests/mwm_url_tests.cpp b/map/map_tests/mwm_url_tests.cpp index 401fcf5925..7231e72c16 100644 --- a/map/map_tests/mwm_url_tests.cpp +++ b/map/map_tests/mwm_url_tests.cpp @@ -538,8 +538,8 @@ void generateRandomTest(uint32_t numberOfPoints, size_t stringLength) MapPoint const & p = api.GetMapPoints()[i]; TEST_EQUAL(p.m_name, vect[i].m_name, ()); TEST_EQUAL(p.m_id, vect[i].m_id, ()); - TEST(base::AlmostEqualULPs(p.m_lat, vect[i].m_lat), ()); - TEST(base::AlmostEqualULPs(p.m_lon, vect[i].m_lon), ()); + TEST(AlmostEqualULPs(p.m_lat, vect[i].m_lat), ()); + TEST(AlmostEqualULPs(p.m_lon, vect[i].m_lon), ()); } } diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index fab7dd21e1..606e5e2fd0 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -289,7 +289,7 @@ drape_ptr CreateDrapeSubroute(vector const & segment // To prevent visual artefacts, in the case when all head segments are real // m_headFakeDistance must be less than 0.0. auto const headLen = (firstReal > 0) ? segments[firstReal - 1].GetDistFromBeginningMerc() - baseDistance : 0.0; - if (base::AlmostEqualAbs(headLen, 0.0, kEps)) + if (AlmostEqualAbs(headLen, 0.0, kEps)) subroute->m_headFakeDistance = -kBias; else subroute->m_headFakeDistance = headLen; @@ -298,7 +298,7 @@ drape_ptr CreateDrapeSubroute(vector const & segment // m_tailFakeDistance must be greater than the length of the subroute. auto const subrouteLen = segments.back().GetDistFromBeginningMerc() - baseDistance; auto const tailLen = segments[lastReal].GetDistFromBeginningMerc() - baseDistance; - if (base::AlmostEqualAbs(tailLen, subrouteLen, kEps)) + if (AlmostEqualAbs(tailLen, subrouteLen, kEps)) subroute->m_tailFakeDistance = subrouteLen + kBias; else subroute->m_tailFakeDistance = tailLen; @@ -1242,7 +1242,7 @@ void RoutingManager::DistanceAltitude::Simplify(double altitudeDeviation) // eps, distFn, AccumulateSkipSmallTrg(distFn, out, eps)); // 2. Default square distance from segment. - SimplifyDefault(IterT(*this, true), IterT(*this, false), base::Pow2(altitudeDeviation), out); + SimplifyDefault(IterT(*this, true), IterT(*this, false), math::Pow2(altitudeDeviation), out); size_t const count = out.size(); m_distances.resize(count); diff --git a/map/track.cpp b/map/track.cpp index b44153c1d4..b0dfd368f2 100644 --- a/map/track.cpp +++ b/map/track.cpp @@ -17,13 +17,13 @@ bool GetTrackPoint(std::vector const & points, CHECK_EQUAL(points.size(), lengths.size(), ()); double const kEpsMeters = 1e-2; - if (base::AlmostEqualAbs(distanceInMeters, lengths.front(), kEpsMeters)) + if (AlmostEqualAbs(distanceInMeters, lengths.front(), kEpsMeters)) { pt = points.front().GetPoint(); return true; } - if (base::AlmostEqualAbs(distanceInMeters, lengths.back(), kEpsMeters)) + if (AlmostEqualAbs(distanceInMeters, lengths.back(), kEpsMeters)) { pt = points.back().GetPoint(); return true; diff --git a/openlr/candidate_paths_getter.cpp b/openlr/candidate_paths_getter.cpp index 7e1cf3d728..06b39668fa 100644 --- a/openlr/candidate_paths_getter.cpp +++ b/openlr/candidate_paths_getter.cpp @@ -30,10 +30,10 @@ double const kAnglesInBucket = 360.0 / kNumBuckets; uint32_t Bearing(m2::PointD const & a, m2::PointD const & b) { - auto const angle = location::AngleToBearing(base::RadToDeg(ang::AngleTo(a, b))); + auto const angle = location::AngleToBearing(math::RadToDeg(ang::AngleTo(a, b))); CHECK_LESS_OR_EQUAL(angle, 360, ("Angle should be less than or equal to 360.")); CHECK_GREATER_OR_EQUAL(angle, 0, ("Angle should be greater than or equal to 0")); - return base::Clamp(angle / kAnglesInBucket, 0.0, 255.0); + return math::Clamp(angle / kAnglesInBucket, 0.0, 255.0); } } // namespace cpg diff --git a/openlr/openlr_decoder.cpp b/openlr/openlr_decoder.cpp index 65dcd59ac8..7fffe394b8 100644 --- a/openlr/openlr_decoder.cpp +++ b/openlr/openlr_decoder.cpp @@ -402,10 +402,10 @@ size_t constexpr GetOptimalBatchSize() { // This code computes the most optimal (in the sense of cache lines // occupancy) batch size. - size_t constexpr a = base::LCM(sizeof(LinearSegment), kCacheLineSize) / sizeof(LinearSegment); + size_t constexpr a = math::LCM(sizeof(LinearSegment), kCacheLineSize) / sizeof(LinearSegment); size_t constexpr b = - base::LCM(sizeof(IRoadGraph::EdgeVector), kCacheLineSize) / sizeof(IRoadGraph::EdgeVector); - return base::LCM(a, b); + math::LCM(sizeof(IRoadGraph::EdgeVector), kCacheLineSize) / sizeof(IRoadGraph::EdgeVector); + return math::LCM(a, b); } } // namespace diff --git a/openlr/openlr_model_xml.cpp b/openlr/openlr_model_xml.cpp index c634531e9c..7eb0f74dda 100644 --- a/openlr/openlr_model_xml.cpp +++ b/openlr/openlr_model_xml.cpp @@ -105,8 +105,8 @@ bool FirstCoordinateFromXML(pugi::xml_node const & node, ms::LatLon & latLon) if (!GetLatLon(node.child("olr:coordinate"), lat, lon)) return false; - latLon.m_lat = ((lat - base::Sign(lat) * 0.5) * 360) / (1 << 24); - latLon.m_lon = ((lon - base::Sign(lon) * 0.5) * 360) / (1 << 24); + latLon.m_lat = ((lat - math::Sign(lat) * 0.5) * 360) / (1 << 24); + latLon.m_lon = ((lon - math::Sign(lon) * 0.5) * 360) / (1 << 24); return true; } diff --git a/openlr/router.cpp b/openlr/router.cpp index 4e01d3bb7f..a97060f750 100644 --- a/openlr/router.cpp +++ b/openlr/router.cpp @@ -39,10 +39,10 @@ double const kAnglesInBucket = 360.0 / kNumBuckets; uint32_t Bearing(m2::PointD const & a, m2::PointD const & b) { - auto const angle = location::AngleToBearing(base::RadToDeg(ang::AngleTo(a, b))); + auto const angle = location::AngleToBearing(math::RadToDeg(ang::AngleTo(a, b))); CHECK_LESS_OR_EQUAL(angle, 360, ("Angle should be less than or equal to 360.")); CHECK_GREATER_OR_EQUAL(angle, 0, ("Angle should be greater than or equal to 0")); - return base::Clamp(angle / kAnglesInBucket, 0.0, 255.0); + return math::Clamp(angle / kAnglesInBucket, 0.0, 255.0); } } // namespace @@ -61,7 +61,7 @@ void Router::Vertex::Score::AddBearingPenalty(int expected, int actual) ASSERT_GREATER_OR_EQUAL(actual, 0, ()); int const diff = abs(expected - actual); - double angle = base::DegToRad(std::min(diff, kNumBuckets - diff) * kAnglesInBucket); + double angle = math::DegToRad(std::min(diff, kNumBuckets - diff) * kAnglesInBucket); m_penalty += kBearingErrorCoeff * angle * kBearingDist; } @@ -568,8 +568,8 @@ double Router::GetCoverage(m2::PointD const & u, m2::PointD const & v, It b, It double const sp = DotProduct(uv, s - u) / sqlen; double const tp = DotProduct(uv, t - u) / sqlen; - double const start = base::Clamp(std::min(sp, tp), 0.0, 1.0); - double const finish = base::Clamp(std::max(sp, tp), 0.0, 1.0); + double const start = math::Clamp(std::min(sp, tp), 0.0, 1.0); + double const finish = math::Clamp(std::max(sp, tp), 0.0, 1.0); covs.emplace_back(start, finish); } @@ -627,7 +627,7 @@ double Router::GetMatchingScore(m2::PointD const & u, m2::PointD const & v, It b cov += mercator::DistanceOnEarth(s, t); } - return len == 0 ? 0 : base::Clamp(cov / len, 0.0, 1.0); + return len == 0 ? 0 : math::Clamp(cov / len, 0.0, 1.0); } template diff --git a/openlr/score_candidate_paths_getter.cpp b/openlr/score_candidate_paths_getter.cpp index 92985a3413..a17471c832 100644 --- a/openlr/score_candidate_paths_getter.cpp +++ b/openlr/score_candidate_paths_getter.cpp @@ -36,12 +36,12 @@ double constexpr kAnglesInBucket = 360.0 / kNumBuckets; double ToAngleInDeg(uint32_t angleInBuckets) { CHECK_LESS_OR_EQUAL(angleInBuckets, 255, ()); - return base::Clamp(kAnglesInBucket * static_cast(angleInBuckets), 0.0, 360.0); + return math::Clamp(kAnglesInBucket * static_cast(angleInBuckets), 0.0, 360.0); } uint32_t BearingInDeg(m2::PointD const & a, m2::PointD const & b) { - auto const angle = location::AngleToBearing(base::RadToDeg(ang::AngleTo(a, b))); + auto const angle = location::AngleToBearing(math::RadToDeg(ang::AngleTo(a, b))); CHECK(0.0 <= angle && angle <= 360.0, (angle)); return angle; } diff --git a/platform/distance.cpp b/platform/distance.cpp index 59fcdb416b..e1ad57529f 100644 --- a/platform/distance.cpp +++ b/platform/distance.cpp @@ -66,7 +66,7 @@ double WithPrecision(double value, uint8_t precision) if (precision == 0) return std::round(value); - double const factor = base::PowUint(10.0, precision); + double const factor = math::PowUint(10.0, precision); return std::round(value * factor) / factor; } } // namespace diff --git a/platform/measurement_utils.cpp b/platform/measurement_utils.cpp index d53e493b68..59f301e0d1 100644 --- a/platform/measurement_utils.cpp +++ b/platform/measurement_utils.cpp @@ -114,7 +114,7 @@ std::string FormatLatLonAsDMSImpl(double value, char positive, char negative, in // Seconds d = d * 60.0; if (dac == 0) - d = SignedRound(d); + d = math::SignedRound(d); d = std::modf(d, &i); sstream << std::setw(2) << i; @@ -125,7 +125,7 @@ std::string FormatLatLonAsDMSImpl(double value, char positive, char negative, in sstream << "″"; // This condition is too heavy for production purposes (but more correct). - //if (base::SignedRound(value * 3600.0 * pow(10, dac)) != 0) + //if (math::SignedRound(value * 3600.0 * pow(10, dac)) != 0) if (!AlmostEqualULPs(value, 0.0)) { char postfix = positive; @@ -225,7 +225,7 @@ std::string FormatOsmLink(double lat, double lon, int zoom) for (int i = 0; i < (zoom + 8) % 3; ++i) osmUrl += "-"; - // ?m tells OSM to display a marker + // ?m tells OSM to display a marker return osmUrl + "?m"; } diff --git a/platform/platform_tests/measurement_tests.cpp b/platform/platform_tests/measurement_tests.cpp index 11ab0c9ab9..072b7eb617 100644 --- a/platform/platform_tests/measurement_tests.cpp +++ b/platform/platform_tests/measurement_tests.cpp @@ -132,17 +132,17 @@ UNIT_TEST(OSMDistanceToMetersString) UNIT_TEST(UnitsConversion) { double const kEps = 1e-5; - TEST(base::AlmostEqualAbs(MilesToMeters(MetersToMiles(1000.0)), 1000.0, kEps), ()); - TEST(base::AlmostEqualAbs(MilesToMeters(1.0), 1609.344, kEps), ()); + TEST(AlmostEqualAbs(MilesToMeters(MetersToMiles(1000.0)), 1000.0, kEps), ()); + TEST(AlmostEqualAbs(MilesToMeters(1.0), 1609.344, kEps), ()); - TEST(base::AlmostEqualAbs(MiphToKmph(KmphToMiph(100.0)), 100.0, kEps), ()); - TEST(base::AlmostEqualAbs(MiphToKmph(100.0), 160.9344, kEps), (MiphToKmph(100.0))); + TEST(AlmostEqualAbs(MiphToKmph(KmphToMiph(100.0)), 100.0, kEps), ()); + TEST(AlmostEqualAbs(MiphToKmph(100.0), 160.9344, kEps), (MiphToKmph(100.0))); - TEST(base::AlmostEqualAbs(ToSpeedKmPH(100.0, Units::Imperial), 160.9344, kEps), ()); - TEST(base::AlmostEqualAbs(ToSpeedKmPH(100.0, Units::Metric), 100.0, kEps), ()); + TEST(AlmostEqualAbs(ToSpeedKmPH(100.0, Units::Imperial), 160.9344, kEps), ()); + TEST(AlmostEqualAbs(ToSpeedKmPH(100.0, Units::Metric), 100.0, kEps), ()); - TEST(base::AlmostEqualAbs(KmphToMps(3.6), 1.0, kEps), ()); - TEST(base::AlmostEqualAbs(MpsToKmph(1.0), 3.6, kEps), ()); + TEST(AlmostEqualAbs(KmphToMps(3.6), 1.0, kEps), ()); + TEST(AlmostEqualAbs(MpsToKmph(1.0), 3.6, kEps), ()); } UNIT_TEST(ToStringPrecisionLocale) diff --git a/platform/utm_mgrs_utils.cpp b/platform/utm_mgrs_utils.cpp index e657f35794..b1271b2553 100644 --- a/platform/utm_mgrs_utils.cpp +++ b/platform/utm_mgrs_utils.cpp @@ -101,7 +101,7 @@ UTMPoint LatLonToUtm(double lat, double lon) { using std::sin, std::cos, std::sqrt; - double const latRad = base::DegToRad(lat); + double const latRad = math::DegToRad(lat); double const latSin = sin(latRad); double const latCos = cos(latRad); @@ -113,9 +113,9 @@ UTMPoint LatLonToUtm(double lat, double lon) auto const zoneLetter = LatitudeToZoneLetter(lat); ASSERT(zoneLetter, (lat)); - double const lonRad = base::DegToRad(lon); + double const lonRad = math::DegToRad(lon); double const centralLon = ZoneNumberToCentralLon(zoneNumber); - double const centralLonRad = base::DegToRad(centralLon); + double const centralLonRad = math::DegToRad(centralLon); double const n = R / sqrt(1.0 - E * latSin * latSin); double const c = E_P2 * latCos * latCos; @@ -299,9 +299,9 @@ std::optional UTMtoLatLon(int easting, int northing, int zoneNumber, d3 / 6.0 * (1.0 + 2.0 * p_tan2 + c) + d5 / 120.0 * (5.0 - 2.0 * c + 28.0 * p_tan2 - 3.0 * c2 + 8.0 * E_P2 + 24.0 * p_tan4)) / p_cos; - longitude = NormalizeAngle(longitude + base::DegToRad(static_cast(ZoneNumberToCentralLon(zoneNumber)))); + longitude = NormalizeAngle(longitude + math::DegToRad(static_cast(ZoneNumberToCentralLon(zoneNumber)))); - return ms::LatLon(base::RadToDeg(latitude), base::RadToDeg(longitude)); + return ms::LatLon(math::RadToDeg(latitude), math::RadToDeg(longitude)); } namespace diff --git a/poly_borders/borders_data.cpp b/poly_borders/borders_data.cpp index 6f37b32dd5..90189fe2d2 100644 --- a/poly_borders/borders_data.cpp +++ b/poly_borders/borders_data.cpp @@ -79,7 +79,7 @@ bool NeedReplace(std::vector const & curSubpolygon, if (areaDiff > kMaxAreaDiffMetersSquared) return false; - if (base::AlmostEqualAbs(areaDiff, 0.0, BordersData::kEqualityEpsilon)) + if (AlmostEqualAbs(areaDiff, 0.0, BordersData::kEqualityEpsilon)) return false; // We know that |curSize| is always greater than 1, because we construct it such way, but we know @@ -238,7 +238,7 @@ size_t BordersData::RemoveDuplicatePoints() size_t count = 0; auto const pointsAreEqual = [](auto const & p1, auto const & p2) { - return base::AlmostEqualAbs(p1.m_point, p2.m_point, kEqualityEpsilon); + return AlmostEqualAbs(p1.m_point, p2.m_point, kEqualityEpsilon); }; for (auto & polygon : m_bordersPolygons) @@ -283,7 +283,7 @@ void BordersData::MarkPoint(size_t curBorderId, size_t curPointId) { auto & anotherMarkedPoint = anotherPolygon.m_points[anotherPointId]; - if (base::AlmostEqualAbs(anotherMarkedPoint.m_point, curMarkedPoint.m_point, kEqualityEpsilon)) + if (AlmostEqualAbs(anotherMarkedPoint.m_point, curMarkedPoint.m_point, kEqualityEpsilon)) { anotherMarkedPoint.m_marked = true; curMarkedPoint.m_marked = true; diff --git a/poly_borders/poly_borders_tests/remove_empty_spaces_tests.cpp b/poly_borders/poly_borders_tests/remove_empty_spaces_tests.cpp index 5633772002..24d8969fcc 100644 --- a/poly_borders/poly_borders_tests/remove_empty_spaces_tests.cpp +++ b/poly_borders/poly_borders_tests/remove_empty_spaces_tests.cpp @@ -41,7 +41,7 @@ bool ConsistsOf(Polygon const & polygon, vector const & points) for (size_t i = 0; i < polygon.m_points.size(); ++i) { static double constexpr kEps = 1e-5; - if (base::AlmostEqualAbs(point, polygon.m_points[i].m_point, kEps) && + if (AlmostEqualAbs(point, polygon.m_points[i].m_point, kEps) && used.count(i) == 0) { used.emplace(i); diff --git a/qt/qt_common/qtoglcontext.cpp b/qt/qt_common/qtoglcontext.cpp index 90c0b1b8d1..ea503b9ebe 100644 --- a/qt/qt_common/qtoglcontext.cpp +++ b/qt/qt_common/qtoglcontext.cpp @@ -62,8 +62,8 @@ void QtRenderOGLContext::Resize(int w, int h) // This function can't be called inside BeginRendering - EndRendering. std::lock_guard lock(m_frameMutex); - auto const nw = static_cast(base::NextPowOf2(static_cast(w))); - auto const nh = static_cast(base::NextPowOf2(static_cast(h))); + auto const nw = static_cast(math::NextPowOf2(static_cast(w))); + auto const nh = static_cast(math::NextPowOf2(static_cast(h))); if (nw <= m_width && nh <= m_height && m_backFrame != nullptr) { diff --git a/qt/qt_common/scale_slider.cpp b/qt/qt_common/scale_slider.cpp index acc5885c99..ef283b58da 100644 --- a/qt/qt_common/scale_slider.cpp +++ b/qt/qt_common/scale_slider.cpp @@ -67,7 +67,7 @@ void ScaleSlider::SetPosWithBlockedSignals(double pos) { bool const blocked = signalsBlocked(); blockSignals(true); - setSliderPosition(base::SignedRound(pos * m_factor)); + setSliderPosition(math::SignedRound(pos * m_factor)); blockSignals(blocked); } diff --git a/routing/base/astar_progress.cpp b/routing/base/astar_progress.cpp index 7512d4b8d5..7778ab2a02 100644 --- a/routing/base/astar_progress.cpp +++ b/routing/base/astar_progress.cpp @@ -48,7 +48,7 @@ double AStarSubProgress::UpdateProgress(ms::LatLon const & current, ms::LatLon c toUpdate = std::min(toUpdate, dist); double part = 2.0 - (m_forwardDistance + m_backwardDistance) / m_fullDistance; - part = base::Clamp(part, 0.0, 1.0); + part = math::Clamp(part, 0.0, 1.0); double const newProgress = m_contributionCoef * part; m_currentProgress = std::max(newProgress, m_currentProgress); @@ -108,7 +108,7 @@ double AStarProgress::UpdateProgress(ms::LatLon const & current, ms::LatLon cons m_lastPercentValue = std::max(m_lastPercentValue, newProgress); ASSERT(m_lastPercentValue < kMaxPercent || - base::AlmostEqualAbs(m_lastPercentValue, kMaxPercent, 1e-5 /* eps */), + AlmostEqualAbs(m_lastPercentValue, kMaxPercent, 1e-5 /* eps */), (m_lastPercentValue, kMaxPercent)); m_lastPercentValue = std::min(m_lastPercentValue, kMaxPercent); diff --git a/routing/car_directions.cpp b/routing/car_directions.cpp index aebbd08c06..e58e3e1841 100644 --- a/routing/car_directions.cpp +++ b/routing/car_directions.cpp @@ -576,7 +576,7 @@ size_t CheckUTurnOnRoute(IRoutingResult const & result, size_t const outgoingSeg auto angle = ang::TwoVectorsAngle(m2::PointD::Zero(), v1, v2); - if (!base::AlmostEqualAbs(angle, math::pi, kUTurnHeadingSensitivity)) + if (!AlmostEqualAbs(angle, math::pi, kUTurnHeadingSensitivity)) return 0; // Determine turn direction. diff --git a/routing/cross_mwm_index_graph.hpp b/routing/cross_mwm_index_graph.hpp index 3a2c0291bb..8841ca6e22 100644 --- a/routing/cross_mwm_index_graph.hpp +++ b/routing/cross_mwm_index_graph.hpp @@ -227,7 +227,7 @@ private: for (uint32_t i = 0; i < geo1.size(); ++i) { - if (!base::AlmostEqualAbs(geo1[i], geo2[i], kMwmPointAccuracy)) + if (!AlmostEqualAbs(geo1[i], geo2[i], kMwmPointAccuracy)) return false; } diff --git a/routing/directions_engine.cpp b/routing/directions_engine.cpp index d94beaac15..332516784e 100644 --- a/routing/directions_engine.cpp +++ b/routing/directions_engine.cpp @@ -127,7 +127,7 @@ void DirectionsEngine::GetSegmentRangeAndAdjacentEdges(IRoadGraph::EdgeListT con { ASSERT_LESS(mercator::DistanceOnEarth(junctionPoint, edge.GetStartJunction().GetPoint()), turns::kFeaturesNearTurnMeters, ()); - angle = base::RadToDeg(turns::PiMinusTwoVectorsAngle(junctionPoint, ingoingPoint, + angle = math::RadToDeg(turns::PiMinusTwoVectorsAngle(junctionPoint, ingoingPoint, edge.GetEndJunction().GetPoint())); } else diff --git a/routing/fake_ending.cpp b/routing/fake_ending.cpp index 4ddacaf8c9..55eb406433 100644 --- a/routing/fake_ending.cpp +++ b/routing/fake_ending.cpp @@ -30,7 +30,7 @@ LatLonWithAltitude CalcProjectionToSegment(LatLonWithAltitude const & begin, auto const projectedLatLon = mercator::ToLatLon(projectedPoint); double constexpr kEpsMeters = 2.0; - if (base::AlmostEqualAbs(distBeginToEnd, 0.0, kEpsMeters)) + if (AlmostEqualAbs(distBeginToEnd, 0.0, kEpsMeters)) return LatLonWithAltitude(projectedLatLon, begin.GetAltitude()); auto const distBeginToProjection = diff --git a/routing/features_road_graph.cpp b/routing/features_road_graph.cpp index 2fa96e2b5d..e2881d5998 100644 --- a/routing/features_road_graph.cpp +++ b/routing/features_road_graph.cpp @@ -202,7 +202,7 @@ void FeaturesRoadGraphBase::GetJunctionTypes(geometry::PointWithAltitude const & m_dataSource.ForEachStreet([&](FeatureType & ft) { if (types.Empty() && ft.GetGeomType() == feature::GeomType::Point && - base::AlmostEqualAbs(ft.GetCenter(), cross, kMwmPointAccuracy)) + AlmostEqualAbs(ft.GetCenter(), cross, kMwmPointAccuracy)) { types = feature::TypesHolder(ft); } diff --git a/routing/geometry.cpp b/routing/geometry.cpp index 7cb8aa9e59..632ad700a6 100644 --- a/routing/geometry.cpp +++ b/routing/geometry.cpp @@ -224,7 +224,7 @@ void RoadGeometry::Load(VehicleModelInterface const & vehicleModel, FeatureType auto const roadLenKm = GetRoadLengthM() / 1000.0; double const durationH = CalcFerryDurationHours(durationMeta, roadLenKm); - CHECK(!base::AlmostEqualAbs(durationH, 0.0, 1e-5), (durationH)); + CHECK(!AlmostEqualAbs(durationH, 0.0, 1e-5), (durationH)); if (roadLenKm != 0.0) { diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 3de70fffac..6c8789e547 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -606,7 +606,7 @@ RouterResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoints, vector subroute; double contributionCoef = kAlmostZeroContribution; - if (!base::AlmostEqualAbs(checkpointsLength, 0.0, 1e-5)) + if (!AlmostEqualAbs(checkpointsLength, 0.0, 1e-5)) { contributionCoef = mercator::DistanceOnEarth(startCheckpoint, finishCheckpoint) / checkpointsLength; diff --git a/routing/road_graph.hpp b/routing/road_graph.hpp index 0e5df4edc2..5ec023fb58 100644 --- a/routing/road_graph.hpp +++ b/routing/road_graph.hpp @@ -209,7 +209,7 @@ public: { for (size_t i = 0; i < junctions.size(); ++i) { - if (!base::AlmostEqualAbs(m_cross.GetPoint(), junctions[i].GetPoint(), kMwmPointAccuracy)) + if (!AlmostEqualAbs(m_cross.GetPoint(), junctions[i].GetPoint(), kMwmPointAccuracy)) continue; if (i + 1 < junctions.size()) diff --git a/routing/route.cpp b/routing/route.cpp index 3bfd7d096f..237202e157 100644 --- a/routing/route.cpp +++ b/routing/route.cpp @@ -396,8 +396,8 @@ double Route::GetPolySegAngle(size_t ind) const { p2 = m_poly.GetPolyline().GetPoint(i); } - while (m2::AlmostEqualULPs(p1, p2) && ++i < polySz); - return (i == polySz) ? 0 : base::RadToDeg(ang::AngleTo(p1, p2)); + while (AlmostEqualULPs(p1, p2) && ++i < polySz); + return (i == polySz) ? 0 : math::RadToDeg(ang::AngleTo(p1, p2)); } bool Route::MatchLocationToRoute(location::GpsInfo & location, diff --git a/routing/route.hpp b/routing/route.hpp index adb4e143d3..78702f0810 100644 --- a/routing/route.hpp +++ b/routing/route.hpp @@ -50,7 +50,7 @@ public: bool EqualCoef(SpeedCamera const & rhs) const { - return base::AlmostEqualAbs(m_coef, rhs.m_coef, 1.0E-5); + return AlmostEqualAbs(m_coef, rhs.m_coef, 1.0E-5); } bool operator<(SpeedCamera const & rhs) const diff --git a/routing/route_weight.hpp b/routing/route_weight.hpp index 93ddadedc5..3ae9a29bcf 100644 --- a/routing/route_weight.hpp +++ b/routing/route_weight.hpp @@ -67,8 +67,8 @@ public: return m_numPassThroughChanges == rhs.m_numPassThroughChanges && m_numAccessChanges == rhs.m_numAccessChanges && m_numAccessConditionalPenalties == rhs.m_numAccessConditionalPenalties && - base::AlmostEqualAbs(m_weight, rhs.m_weight, epsilon) && - base::AlmostEqualAbs(m_transitTime, rhs.m_transitTime, epsilon); + AlmostEqualAbs(m_weight, rhs.m_weight, epsilon) && + AlmostEqualAbs(m_transitTime, rhs.m_transitTime, epsilon); } friend std::ostream & operator<<(std::ostream & os, RouteWeight const & routeWeight); diff --git a/routing/routing_benchmarks/helpers.cpp b/routing/routing_benchmarks/helpers.cpp index ed9696c2e4..51f4450555 100644 --- a/routing/routing_benchmarks/helpers.cpp +++ b/routing/routing_benchmarks/helpers.cpp @@ -98,7 +98,7 @@ void RoutingTest::TestRouters(m2::PointD const & startPos, m2::PointD const & fi } double constexpr kEpsilon = 1e-6; - TEST(base::AlmostEqualAbs(routeFoundByAstar.GetTotalDistanceMeters(), + TEST(AlmostEqualAbs(routeFoundByAstar.GetTotalDistanceMeters(), routeFoundByAstarBidirectional.GetTotalDistanceMeters(), kEpsilon), ()); } @@ -160,8 +160,8 @@ void TestRouter(routing::IRouter & router, m2::PointD const & startPos, TEST(route.IsValid(), ()); m2::PolylineD const & poly = route.GetPoly(); TEST_GREATER(poly.GetSize(), 0, ()); - TEST(base::AlmostEqualAbs(poly.Front(), startPos, kMwmPointAccuracy), ()); - TEST(base::AlmostEqualAbs(poly.Back(), finalPos, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(poly.Front(), startPos, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(poly.Back(), finalPos, kMwmPointAccuracy), ()); LOG(LINFO, ("Route polyline size:", route.GetPoly().GetSize())); LOG(LINFO, ("Route distance, meters:", route.GetTotalDistanceMeters())); LOG(LINFO, ("Elapsed, seconds:", elapsedSec)); diff --git a/routing/routing_integration_tests/get_altitude_test.cpp b/routing/routing_integration_tests/get_altitude_test.cpp index 8030bafd82..654ccb5425 100644 --- a/routing/routing_integration_tests/get_altitude_test.cpp +++ b/routing/routing_integration_tests/get_altitude_test.cpp @@ -63,7 +63,7 @@ void TestAltitudeOfAllMwmFeatures(string const & countryId, for (auto const altitude : altitudes) { - TEST_EQUAL(base::Clamp(altitude, altitudeLowerBoundMeters, altitudeUpperBoundMeters), altitude, + TEST_EQUAL(math::Clamp(altitude, altitudeLowerBoundMeters, altitudeUpperBoundMeters), altitude, ("Unexpected altitude. MWM:", countryId, ", feature id:", id, ", altitudes:", altitudes)); } }); diff --git a/routing/routing_integration_tests/routing_test_tools.cpp b/routing/routing_integration_tests/routing_test_tools.cpp index 7acc88c38d..d4c2639ba7 100644 --- a/routing/routing_integration_tests/routing_test_tools.cpp +++ b/routing/routing_integration_tests/routing_test_tools.cpp @@ -204,7 +204,7 @@ void TestRouteLength(Route const & route, double expectedRouteMeters, double rel { double const delta = max(expectedRouteMeters * relativeError, kErrorMeters); double const routeMeters = route.GetTotalDistanceMeters(); - TEST(base::AlmostEqualAbs(routeMeters, expectedRouteMeters, delta), + TEST(AlmostEqualAbs(routeMeters, expectedRouteMeters, delta), ("Route length test failed. Expected:", expectedRouteMeters, "have:", routeMeters, "delta:", delta)); } @@ -213,7 +213,7 @@ void TestRouteTime(Route const & route, double expectedRouteSeconds, double rela { double const delta = max(expectedRouteSeconds * relativeError, kErrorSeconds); double const routeSeconds = route.GetTotalTimeSec(); - TEST(base::AlmostEqualAbs(routeSeconds, expectedRouteSeconds, delta), + TEST(AlmostEqualAbs(routeSeconds, expectedRouteSeconds, delta), ("Route time test failed. Expected:", expectedRouteSeconds, "have:", routeSeconds, "delta:", delta)); } @@ -222,7 +222,7 @@ void TestRoutePointsNumber(Route const & route, size_t expectedPointsNumber, dou { CHECK_GREATER_OR_EQUAL(relativeError, 0.0, ()); size_t const routePoints = route.GetPoly().GetSize(); - TEST(base::AlmostEqualRel(static_cast(routePoints), + TEST(AlmostEqualRel(static_cast(routePoints), static_cast(expectedPointsNumber), relativeError), ("Route points test failed. Expected:", expectedPointsNumber, "have:", routePoints, "relative error:", relativeError)); diff --git a/routing/routing_quality/routing_quality_tool/benchmark_stat.cpp b/routing/routing_quality/routing_quality_tool/benchmark_stat.cpp index 5b16fc2b07..4650b1eb86 100644 --- a/routing/routing_quality/routing_quality_tool/benchmark_stat.cpp +++ b/routing/routing_quality/routing_quality_tool/benchmark_stat.cpp @@ -35,8 +35,8 @@ void LogIfNotConsistent(RoutesBuilder::Result const & oldRes, RoutesBuilder::Res auto const & oldRoute = oldRes.m_routes.back(); auto const & newRoute = newRes.m_routes.back(); - bool const sameETA = base::AlmostEqualAbs(oldRoute.m_eta, newRoute.m_eta, 1.0); - bool const sameDistance = base::AlmostEqualAbs(oldRoute.m_distance, newRoute.m_distance, 1.0); + bool const sameETA = AlmostEqualAbs(oldRoute.m_eta, newRoute.m_eta, 1.0); + bool const sameDistance = AlmostEqualAbs(oldRoute.m_distance, newRoute.m_distance, 1.0); if (!sameETA || !sameDistance) { LOG(LINFO, ("old ETA:", oldRoute.m_eta, "old distance:", oldRoute.m_distance, "new ETA:", @@ -100,7 +100,7 @@ std::vector GetBoostPercents(BenchmarkResults const & oldResults, { auto const oldTime = oldResults.GetBuildTimes()[i]; auto const newTime = newResults.GetBuildTimes()[i]; - if (base::AlmostEqualAbs(oldTime, newTime, 1e-2)) + if (AlmostEqualAbs(oldTime, newTime, 1e-2)) continue; auto const diffPercent = (oldTime - newTime) / oldTime * 100.0; diff --git a/routing/routing_quality/routing_quality_tool/utils.hpp b/routing/routing_quality/routing_quality_tool/utils.hpp index 8ef8899daf..ff7f127b93 100644 --- a/routing/routing_quality/routing_quality_tool/utils.hpp +++ b/routing/routing_quality/routing_quality_tool/utils.hpp @@ -72,8 +72,8 @@ bool AreRoutesWithSameEnds(routing::routes_builder::RoutesBuilder::Result const auto const & anotherFinish = anotherResult.GetFinishPoint(); double constexpr kEps = 1e-10; - return base::AlmostEqualAbs(start, anotherStart, kEps) && - base::AlmostEqualAbs(finish, anotherFinish, kEps); + return AlmostEqualAbs(start, anotherStart, kEps) && + AlmostEqualAbs(finish, anotherFinish, kEps); } template diff --git a/routing/routing_session.cpp b/routing/routing_session.cpp index 89ea50a9de..d889fc1a28 100644 --- a/routing/routing_session.cpp +++ b/routing/routing_session.cpp @@ -315,7 +315,7 @@ SessionState RoutingSession::OnLocationPositionChanged(GpsInfo const & info) auto const & lastGoodPoint = m_route->GetFollowedPolyline().GetCurrentIter().m_pt; double const dist = mercator::DistanceOnEarth(lastGoodPoint, mercator::FromLatLon(info.m_latitude, info.m_longitude)); - if (base::AlmostEqualAbs(dist, m_lastDistance, kRunawayDistanceSensitivityMeters)) + if (AlmostEqualAbs(dist, m_lastDistance, kRunawayDistanceSensitivityMeters)) return m_state; if (!info.HasSpeed() || info.m_speed < m_routingSettings.m_minSpeedForRouteRebuildMpS) @@ -550,7 +550,7 @@ void RoutingSession::MatchLocationToRoadGraph(location::GpsInfo & location) m2::PointD const direction = m_positionAccumulator.GetDirection(); static auto constexpr kEps = 1e-5; - if (base::AlmostEqualAbs(direction, m2::PointD::Zero(), kEps)) + if (AlmostEqualAbs(direction, m2::PointD::Zero(), kEps)) return; EdgeProj proj; @@ -572,10 +572,10 @@ void RoutingSession::MatchLocationToRoadGraph(location::GpsInfo & location) { if (m_route->GetCurrentRoutingSettings().m_matchRoute) { - if (!base::AlmostEqualAbs(m_proj.m_point, proj.m_point, kEps)) + if (!AlmostEqualAbs(m_proj.m_point, proj.m_point, kEps)) { location.m_bearing = - location::AngleToBearing(base::RadToDeg(ang::AngleTo(m_proj.m_point, proj.m_point))); + location::AngleToBearing(math::RadToDeg(ang::AngleTo(m_proj.m_point, proj.m_point))); } } diff --git a/routing/routing_tests/astar_router_test.cpp b/routing/routing_tests/astar_router_test.cpp index 381ae76d44..44a09fbc42 100644 --- a/routing/routing_tests/astar_router_test.cpp +++ b/routing/routing_tests/astar_router_test.cpp @@ -261,7 +261,7 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad1) geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 3)), geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}), ()); - TEST(base::AlmostEqualAbs(result.m_distance, 800451., 1.), ("Distance error:", result.m_distance)); + TEST(AlmostEqualAbs(result.m_distance, 800451., 1.), ("Distance error:", result.m_distance)); } UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad2) @@ -294,7 +294,7 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad2) geometry::MakePointWithAltitudeForTesting(m2::PointD(6, 2)), geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}), ()); - TEST(base::AlmostEqualAbs(result.m_distance, 781458., 1.), ("Distance error:", result.m_distance)); + TEST(AlmostEqualAbs(result.m_distance, 781458., 1.), ("Distance error:", result.m_distance)); } UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad3) @@ -328,6 +328,6 @@ UNIT_TEST(AStarRouter_SimpleGraph_PickTheFasterRoad3) geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 1)), geometry::MakePointWithAltitudeForTesting(m2::PointD(10, 2))}), ()); - TEST(base::AlmostEqualAbs(result.m_distance, 814412., 1.), ("Distance error:", result.m_distance)); + TEST(AlmostEqualAbs(result.m_distance, 814412., 1.), ("Distance error:", result.m_distance)); } } // namespace astar_router_test diff --git a/routing/routing_tests/checkpoint_predictor_test.cpp b/routing/routing_tests/checkpoint_predictor_test.cpp index ba911cc73d..dec4c76087 100644 --- a/routing/routing_tests/checkpoint_predictor_test.cpp +++ b/routing/routing_tests/checkpoint_predictor_test.cpp @@ -13,7 +13,7 @@ namespace checkpoint_predictor_test void TestAlmostEqual(double v1, double v2) { double constexpr kEpsMeters = 1.0; - TEST(base::AlmostEqualAbs(v1, v2, kEpsMeters), (v1, v2)); + TEST(AlmostEqualAbs(v1, v2, kEpsMeters), (v1, v2)); } using routing::CheckpointPredictor; @@ -22,7 +22,7 @@ class CheckpointPredictorTest { public: CheckpointPredictorTest() : m_predictor({0.0, 0.0} /* start */, {4.0, 0.0} /* finish */) {} - + size_t PredictPosition(std::vector const & intermediatePoints, m2::PointD const & point) const { return m_predictor.PredictPosition(intermediatePoints, point); diff --git a/routing/routing_tests/cross_border_graph_tests.cpp b/routing/routing_tests/cross_border_graph_tests.cpp index 5f05670f2d..864fd543f5 100644 --- a/routing/routing_tests/cross_border_graph_tests.cpp +++ b/routing/routing_tests/cross_border_graph_tests.cpp @@ -100,10 +100,10 @@ void TestEqualSegments(CrossBorderSegments const & s1, CrossBorderSegments const static double constexpr epsCoord = 1e-5; - TEST(base::AlmostEqualAbs(data1.m_start.m_point.GetLatLon(), data2.m_start.m_point.GetLatLon(), + TEST(AlmostEqualAbs(data1.m_start.m_point.GetLatLon(), data2.m_start.m_point.GetLatLon(), epsCoord), ()); - TEST(base::AlmostEqualAbs(data1.m_end.m_point.GetLatLon(), data2.m_end.m_point.GetLatLon(), + TEST(AlmostEqualAbs(data1.m_end.m_point.GetLatLon(), data2.m_end.m_point.GetLatLon(), epsCoord), ()); TEST_EQUAL(static_cast(std::ceil(data1.m_weight)), diff --git a/routing/routing_tests/index_graph_test.cpp b/routing/routing_tests/index_graph_test.cpp index 4aee50a2f7..0f66575cad 100644 --- a/routing/routing_tests/index_graph_test.cpp +++ b/routing/routing_tests/index_graph_test.cpp @@ -71,7 +71,7 @@ void TestRoute(FakeEnding const & start, FakeEnding const & finish, size_t expec if (expectedWeight != kUnknownWeight) { double constexpr kEpsilon = 0.01; - TEST(base::AlmostEqualRel(timeSec, expectedWeight, kEpsilon), + TEST(AlmostEqualRel(timeSec, expectedWeight, kEpsilon), ("Expected weight:", expectedWeight, "got:", timeSec)); } diff --git a/routing/routing_tests/index_graph_tools.cpp b/routing/routing_tests/index_graph_tools.cpp index de1addf9f7..bb81a8f9cd 100644 --- a/routing/routing_tests/index_graph_tools.cpp +++ b/routing/routing_tests/index_graph_tools.cpp @@ -88,7 +88,7 @@ void NoUTurnRestrictionTest::TestRouteGeom(Segment const & start, Segment const { static auto constexpr kEps = 1e-3; auto const point = m_graph->GetWorldGraph().GetPoint(routingResult.m_path[i], true /* forward */); - if (!base::AlmostEqualAbs(mercator::FromLatLon(point), expectedRouteGeom[i], kEps)) + if (!AlmostEqualAbs(mercator::FromLatLon(point), expectedRouteGeom[i], kEps)) { TEST(false, ("Coords missmated at index:", i, "expected:", expectedRouteGeom[i], "received:", point)); @@ -528,7 +528,7 @@ void TestRouteGeometry(IndexGraphStarter & starter, for (size_t i = 0; i < geom.size(); ++i) { static double constexpr kEps = 1e-8; - if (!base::AlmostEqualAbs(geom[i], expectedRouteGeom[i], kEps)) + if (!AlmostEqualAbs(geom[i], expectedRouteGeom[i], kEps)) { for (size_t j = 0; j < geom.size(); ++j) LOG(LINFO, (j, "=>", geom[j], "vs", expectedRouteGeom[j])); @@ -588,7 +588,7 @@ void TestRestrictions(double expectedLength, } static auto constexpr kEps = 1e-3; - TEST(base::AlmostEqualAbs(expectedLength, length, kEps), + TEST(AlmostEqualAbs(expectedLength, length, kEps), ("Length expected:", expectedLength, "has:", length)); } @@ -604,7 +604,7 @@ void TestTopologyGraph(TestIndexGraphTopology const & graph, TestIndexGraphTopol if (!pathFound) return; - TEST(base::AlmostEqualAbs(pathWeight, expectedWeight, kEpsilon), + TEST(AlmostEqualAbs(pathWeight, expectedWeight, kEpsilon), (pathWeight, expectedWeight, pathEdges)); TEST_EQUAL(pathEdges, expectedEdges, ()); } diff --git a/routing/routing_tests/position_accumulator_tests.cpp b/routing/routing_tests/position_accumulator_tests.cpp index 459f84c85a..da3c5c05ef 100644 --- a/routing/routing_tests/position_accumulator_tests.cpp +++ b/routing/routing_tests/position_accumulator_tests.cpp @@ -20,8 +20,8 @@ UNIT_CLASS_TEST(PositionAccumulator, Smoke) PushNextPoint({0.00005, 0.0}); PushNextPoint({0.0001, 0.0}); TEST_EQUAL(GetPointsForTesting().size(), 2, ()); - TEST(m2::AlmostEqualAbs(GetDirection(), m2::PointD(0.0001, 0.0), kEps), (GetDirection())); - TEST(base::AlmostEqualAbs(GetTrackLengthMForTesting(), 11.13, kEpsMeters), + TEST(AlmostEqualAbs(GetDirection(), m2::PointD(0.0001, 0.0), kEps), (GetDirection())); + TEST(AlmostEqualAbs(GetTrackLengthMForTesting(), 11.13, kEpsMeters), (GetTrackLengthMForTesting())); } @@ -36,9 +36,9 @@ UNIT_CLASS_TEST(PositionAccumulator, GoodSegment) for (signed i = -15; i <= 0; ++i) PushNextPoint({kStepShortButValid * i, 0.0}); TEST_EQUAL(GetPointsForTesting().size(), 2, ()); - TEST(m2::AlmostEqualAbs(GetDirection(), m2::PointD(9 * kStepShortButValid, 0.0), kEps), + TEST(AlmostEqualAbs(GetDirection(), m2::PointD(9 * kStepShortButValid, 0.0), kEps), (GetDirection())); - TEST(base::AlmostEqualAbs(GetTrackLengthMForTesting(), 10.02, kEpsMeters), + TEST(AlmostEqualAbs(GetTrackLengthMForTesting(), 10.02, kEpsMeters), (GetTrackLengthMForTesting())); double constexpr kStepGood = 0.0001; @@ -46,8 +46,8 @@ UNIT_CLASS_TEST(PositionAccumulator, GoodSegment) PushNextPoint({kStepGood * i, 0.0}); TEST_EQUAL(GetPointsForTesting().size(), 8, ()); - TEST(m2::AlmostEqualAbs(GetDirection(), m2::PointD(0.0007, 0.0), kEps), (GetDirection())); - TEST(base::AlmostEqualAbs(GetTrackLengthMForTesting(), 77.92, kEpsMeters), + TEST(AlmostEqualAbs(GetDirection(), m2::PointD(0.0007, 0.0), kEps), (GetDirection())); + TEST(AlmostEqualAbs(GetTrackLengthMForTesting(), 77.92, kEpsMeters), (GetTrackLengthMForTesting())); } @@ -60,7 +60,7 @@ UNIT_CLASS_TEST(PositionAccumulator, RemovingOutdated) PushNextPoint({kStep * i, 0.0}); TEST_EQUAL(GetPointsForTesting().size(), 8, ()); - TEST(m2::AlmostEqualAbs(GetDirection(), m2::PointD(0.0007, 0.0), kEps), (GetDirection())); + TEST(AlmostEqualAbs(GetDirection(), m2::PointD(0.0007, 0.0), kEps), (GetDirection())); } // Test on adding segments longer than |PositionAccumulator::kMaxValidSegmentLengthM| @@ -77,9 +77,9 @@ UNIT_CLASS_TEST(PositionAccumulator, LongSegment) // |PositionAccumulator::kMinValidSegmentLengthM|, so the point is added. PushNextPoint({0.0012, 0.0}); TEST_EQUAL(GetPointsForTesting().size(), 2, ()); - TEST(m2::AlmostEqualAbs(GetDirection(), m2::PointD(0.0002, 0.0), kEps), (GetDirection())); + TEST(AlmostEqualAbs(GetDirection(), m2::PointD(0.0002, 0.0), kEps), (GetDirection())); PushNextPoint({0.00201, 0.0}); // Longer than |PositionAccumulator::kMaxValidSegmentLengthM|. TEST_EQUAL(GetPointsForTesting().size(), 1, ()); - TEST(m2::AlmostEqualAbs(GetDirection(), m2::PointD(0.0, 0.0), kEps), (GetDirection())); + TEST(AlmostEqualAbs(GetDirection(), m2::PointD(0.0, 0.0), kEps), (GetDirection())); } } // namespace position_accumulator_tests diff --git a/routing/routing_tests/routing_session_test.cpp b/routing/routing_tests/routing_session_test.cpp index 6a4927667f..153316d2ed 100644 --- a/routing/routing_tests/routing_session_test.cpp +++ b/routing/routing_tests/routing_session_test.cpp @@ -531,25 +531,25 @@ UNIT_CLASS_TEST(AsyncGuiThreadTestWithRoutingSession, TestFollowRoutePercentTest info.m_longitude = 0.; info.m_latitude = 1.; m_session->OnLocationPositionChanged(info); - TEST(base::AlmostEqualAbs(m_session->GetCompletionPercent(), 0., 0.5), + TEST(AlmostEqualAbs(m_session->GetCompletionPercent(), 0., 0.5), (m_session->GetCompletionPercent())); info.m_longitude = 0.; info.m_latitude = 2.; m_session->OnLocationPositionChanged(info); - TEST(base::AlmostEqualAbs(m_session->GetCompletionPercent(), 33.3, 0.5), + TEST(AlmostEqualAbs(m_session->GetCompletionPercent(), 33.3, 0.5), (m_session->GetCompletionPercent())); info.m_longitude = 0.; info.m_latitude = 3.; m_session->OnLocationPositionChanged(info); - TEST(base::AlmostEqualAbs(m_session->GetCompletionPercent(), 66.6, 0.5), + TEST(AlmostEqualAbs(m_session->GetCompletionPercent(), 66.6, 0.5), (m_session->GetCompletionPercent())); info.m_longitude = 0.; info.m_latitude = 3.99; m_session->OnLocationPositionChanged(info); - TEST(base::AlmostEqualAbs(m_session->GetCompletionPercent(), 100., 0.5), + TEST(AlmostEqualAbs(m_session->GetCompletionPercent(), 100., 0.5), (m_session->GetCompletionPercent())); checkTimedSignal.Signal(); }); diff --git a/routing/routing_tests/speed_cameras_tests.cpp b/routing/routing_tests/speed_cameras_tests.cpp index e181bb50ad..c4c8306b00 100644 --- a/routing/routing_tests/speed_cameras_tests.cpp +++ b/routing/routing_tests/speed_cameras_tests.cpp @@ -115,7 +115,7 @@ bool TestSerDesSpeedCamera(std::vector const & speedCameras auto const & way = metadata.m_ways.back(); auto const res = DeserializeSpeedCamera(src, prevFeatureId); TEST_EQUAL(res.first, SegmentCoord(way.m_featureId, way.m_segmentId), ()); - TEST(base::AlmostEqualAbs(res.second.m_coef, way.m_coef, 1e-5), ()); + TEST(AlmostEqualAbs(res.second.m_coef, way.m_coef, 1e-5), ()); TEST_EQUAL(res.second.m_maxSpeedKmPH, metadata.m_maxSpeedKmPH, ()); } } diff --git a/routing/routing_tests/turns_sound_test.cpp b/routing/routing_tests/turns_sound_test.cpp index 764200f36b..efc84310ef 100644 --- a/routing/routing_tests/turns_sound_test.cpp +++ b/routing/routing_tests/turns_sound_test.cpp @@ -26,11 +26,11 @@ UNIT_TEST(TurnNotificationSettings_MetersTest) measurement_utils::Units::Metric /* lengthUnits */); TEST(settings.IsValid(), ()); - TEST(base::AlmostEqualAbs( + TEST(AlmostEqualAbs( settings.ConvertMetersPerSecondToUnitsPerSecond(20.), 20., kEps), ()); - TEST(base::AlmostEqualAbs( + TEST(AlmostEqualAbs( settings.ConvertMetersPerSecondToUnitsPerSecond(0.), 0., kEps), ()); - TEST(base::AlmostEqualAbs(settings.ConvertUnitsToMeters(300. /* distanceInUnits */), 300., kEps), ()); + TEST(AlmostEqualAbs(settings.ConvertUnitsToMeters(300. /* distanceInUnits */), 300., kEps), ()); TEST_EQUAL(settings.RoundByPresetSoundedDistancesUnits(300 /* distanceInUnits */), 300, ()); TEST_EQUAL(settings.RoundByPresetSoundedDistancesUnits(0 /* distanceInUnits */), 100, ()); @@ -57,11 +57,11 @@ UNIT_TEST(TurnNotificationSettings_FeetTest) measurement_utils::Units::Imperial /* lengthUnits */); TEST(settings.IsValid(), ()); - TEST(base::AlmostEqualAbs( + TEST(AlmostEqualAbs( settings.ConvertMetersPerSecondToUnitsPerSecond(20.), 65., kEps), ()); - TEST(base::AlmostEqualAbs( + TEST(AlmostEqualAbs( settings.ConvertMetersPerSecondToUnitsPerSecond(0.), 0., kEps), ()); - TEST(base::AlmostEqualAbs(settings.ConvertUnitsToMeters(300. /* distanceInUnits */), 91., kEps), ()); + TEST(AlmostEqualAbs(settings.ConvertUnitsToMeters(300. /* distanceInUnits */), 91., kEps), ()); TEST_EQUAL(settings.RoundByPresetSoundedDistancesUnits(500 /* distanceInUnits */), 600, ()); TEST_EQUAL(settings.RoundByPresetSoundedDistancesUnits(0 /* distanceInUnits */), 200, ()); } diff --git a/routing/turn_candidate.hpp b/routing/turn_candidate.hpp index 44af1c338f..57dd2131b7 100644 --- a/routing/turn_candidate.hpp +++ b/routing/turn_candidate.hpp @@ -44,7 +44,7 @@ struct TurnCandidate bool IsAlmostEqual(TurnCandidate const & rhs) const { double constexpr kEpsilon = 0.01; - return base::AlmostEqualAbs(m_angle, rhs.m_angle, kEpsilon) && m_segment == rhs.m_segment && + return AlmostEqualAbs(m_angle, rhs.m_angle, kEpsilon) && m_segment == rhs.m_segment && m_highwayClass == rhs.m_highwayClass && m_isLink == rhs.m_isLink; } }; diff --git a/routing/turns_generator.cpp b/routing/turns_generator.cpp index 7cb6a86611..d8f4ea5c14 100644 --- a/routing/turns_generator.cpp +++ b/routing/turns_generator.cpp @@ -264,7 +264,7 @@ double CalcTurnAngle(IRoutingResult const & result, vehicleSettings.m_minOutgoingDistMeters, true /* forward */); m2::PointD const junctionPoint = result.GetSegments()[outgoingSegmentIndex].m_path.front().GetPoint(); - return base::RadToDeg(PiMinusTwoVectorsAngle(junctionPoint, ingoingPoint, outgoingPoint)); + return math::RadToDeg(PiMinusTwoVectorsAngle(junctionPoint, ingoingPoint, outgoingPoint)); } void CorrectCandidatesSegmentByOutgoing(TurnInfo const & turnInfo, Segment const & firstOutgoingSeg, @@ -282,7 +282,7 @@ void CorrectCandidatesSegmentByOutgoing(TurnInfo const & turnInfo, Segment const // firstOutgoingSeg not found. Try to match by angle. auto const DoesAngleMatch = [&turnAngle](TurnCandidate const & candidate) { - return (base::AlmostEqualAbs(candidate.m_angle, turnAngle, 0.001) || + return (AlmostEqualAbs(candidate.m_angle, turnAngle, 0.001) || fabs(candidate.m_angle) + fabs(turnAngle) > 359.999); }; auto it = find_if(candidates.begin(), candidates.end(), DoesAngleMatch); diff --git a/routing/turns_generator_utils.cpp b/routing/turns_generator_utils.cpp index 5ce66a1b02..9b12a0c691 100644 --- a/routing/turns_generator_utils.cpp +++ b/routing/turns_generator_utils.cpp @@ -192,7 +192,7 @@ double CalcOneSegmentTurnAngle(TurnInfo const & turnInfo) ASSERT_GREATER_OR_EQUAL(turnInfo.m_ingoing->m_path.size(), 2, ()); ASSERT_GREATER_OR_EQUAL(turnInfo.m_outgoing->m_path.size(), 2, ()); - return base::RadToDeg(PiMinusTwoVectorsAngle(turnInfo.m_ingoing->m_path.back().GetPoint(), + return math::RadToDeg(PiMinusTwoVectorsAngle(turnInfo.m_ingoing->m_path.back().GetPoint(), turnInfo.m_ingoing->m_path[turnInfo.m_ingoing->m_path.size() - 2].GetPoint(), turnInfo.m_outgoing->m_path[1].GetPoint())); } @@ -203,7 +203,7 @@ double CalcPathTurnAngle(LoadedPathSegment const & segment, size_t const pathInd ASSERT_GREATER(pathIndex, 0, ()); ASSERT_LESS(pathIndex, segment.m_path.size() - 1, ()); - return base::RadToDeg(PiMinusTwoVectorsAngle(segment.m_path[pathIndex].GetPoint(), + return math::RadToDeg(PiMinusTwoVectorsAngle(segment.m_path[pathIndex].GetPoint(), segment.m_path[pathIndex - 1].GetPoint(), segment.m_path[pathIndex + 1].GetPoint())); } diff --git a/routing/turns_sound_settings.cpp b/routing/turns_sound_settings.cpp index 16e1dafc64..ab2a8bff4e 100644 --- a/routing/turns_sound_settings.cpp +++ b/routing/turns_sound_settings.cpp @@ -36,7 +36,7 @@ uint32_t Settings::ComputeTurnDistanceM(double speedMetersPerSecond) const ASSERT(IsValid(), ()); double const turnNotificationDistanceM = m_timeSeconds * speedMetersPerSecond; - return static_cast(base::Clamp(turnNotificationDistanceM, + return static_cast(math::Clamp(turnNotificationDistanceM, ConvertUnitsToMeters(m_minDistanceUnits), ConvertUnitsToMeters(m_maxDistanceUnits))); } @@ -107,7 +107,7 @@ uint32_t Settings::ComputeDistToPronounceDistM(double speedMetersPerSecond, bool uint32_t const startBeforeMeters = static_cast(speedMetersPerSecond * startBeforeSeconds); - return base::Clamp(startBeforeMeters, minStartBeforeMeters, maxStartBeforeMeters); + return math::Clamp(startBeforeMeters, minStartBeforeMeters, maxStartBeforeMeters); } string DebugPrint(Notification const & notification) diff --git a/routing_common/routing_common_tests/vehicle_model_test.cpp b/routing_common/routing_common_tests/vehicle_model_test.cpp index 8045187c16..148690ce7d 100644 --- a/routing_common/routing_common_tests/vehicle_model_test.cpp +++ b/routing_common/routing_common_tests/vehicle_model_test.cpp @@ -452,8 +452,8 @@ UNIT_TEST(VehicleModel_MultiplicationOperatorTest) SpeedKMpH const lResult = speed * factor; SpeedKMpH const rResult = factor * speed; TEST_EQUAL(lResult, rResult, ()); - TEST(base::AlmostEqualULPs(lResult.m_weight, 90.0), ()); - TEST(base::AlmostEqualULPs(lResult.m_eta, 110.0), ()); + TEST(AlmostEqualULPs(lResult.m_weight, 90.0), ()); + TEST(AlmostEqualULPs(lResult.m_eta, 110.0), ()); } UNIT_TEST(VehicleModel_CarModelValidation) diff --git a/search/house_detector.cpp b/search/house_detector.cpp index 1aa60ea88b..d7e4652648 100644 --- a/search/house_detector.cpp +++ b/search/house_detector.cpp @@ -779,7 +779,7 @@ HouseDetector::StreetPtr HouseDetector::FindConnection(Street const * st, bool b StreetPtr resStreet(0, false); double resDistance = numeric_limits::max(); - double const minSqDistance = base::Pow2(m_metersToMercator * STREET_CONNECTION_LENGTH_M); + double const minSqDistance = math::Pow2(m_metersToMercator * STREET_CONNECTION_LENGTH_M); for (size_t i = 0; i < m_end2st.size(); ++i) { diff --git a/search/search_integration_tests/postcode_points_tests.cpp b/search/search_integration_tests/postcode_points_tests.cpp index 7c264be125..c7c4a11eef 100644 --- a/search/search_integration_tests/postcode_points_tests.cpp +++ b/search/search_integration_tests/postcode_points_tests.cpp @@ -64,28 +64,28 @@ UNIT_CLASS_TEST(PostcodePointsTest, SmokeUK) vector points; p.Get(NormalizeAndSimplifyString("aa11 0bb"), points); TEST_EQUAL(points.size(), 1, ()); - TEST(base::AlmostEqualAbs(points[0], mercator::FromLatLon(1.0, 1.0), kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(points[0], mercator::FromLatLon(1.0, 1.0), kMwmPointAccuracy), ()); } { vector points; p.Get(NormalizeAndSimplifyString("aa11 1bb"), points); TEST_EQUAL(points.size(), 1, ()); - TEST(base::AlmostEqualAbs(points[0], mercator::FromLatLon(2.0, 2.0), kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(points[0], mercator::FromLatLon(2.0, 2.0), kMwmPointAccuracy), ()); } { vector points; p.Get(NormalizeAndSimplifyString("aa11 2bb"), points); TEST_EQUAL(points.size(), 1, ()); - TEST(base::AlmostEqualAbs(points[0], mercator::FromLatLon(3.0, 3.0), kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(points[0], mercator::FromLatLon(3.0, 3.0), kMwmPointAccuracy), ()); } { vector points; p.Get(NormalizeAndSimplifyString("aa11"), points); TEST_EQUAL(points.size(), 3, ()); sort(points.begin(), points.end()); - TEST(base::AlmostEqualAbs(points[0], mercator::FromLatLon(1.0, 1.0), kMwmPointAccuracy), ()); - TEST(base::AlmostEqualAbs(points[1], mercator::FromLatLon(2.0, 2.0), kMwmPointAccuracy), ()); - TEST(base::AlmostEqualAbs(points[2], mercator::FromLatLon(3.0, 3.0), kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(points[0], mercator::FromLatLon(1.0, 1.0), kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(points[1], mercator::FromLatLon(2.0, 2.0), kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(points[2], mercator::FromLatLon(3.0, 3.0), kMwmPointAccuracy), ()); } } @@ -122,7 +122,7 @@ UNIT_CLASS_TEST(PostcodePointsTest, SmokeUS) vector points; p.Get(NormalizeAndSimplifyString("00601"), points); TEST_EQUAL(points.size(), 1, ()); - TEST(base::AlmostEqualAbs(points[0], mercator::FromLatLon(18.18027, -66.75266), kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(points[0], mercator::FromLatLon(18.18027, -66.75266), kMwmPointAccuracy), ()); } } @@ -161,7 +161,7 @@ UNIT_CLASS_TEST(PostcodePointsTest, SearchPostcode) TEST(result.HasPoint(), ()); auto const actual = result.GetFeatureCenter(); - TEST(base::AlmostEqualAbs(expected, actual, kMwmPointAccuracy), ()); + TEST(AlmostEqualAbs(expected, actual, kMwmPointAccuracy), ()); }; test("BA6 7JP", mercator::FromLatLon(5.0, 4.0)); diff --git a/search/search_integration_tests/pre_ranker_test.cpp b/search/search_integration_tests/pre_ranker_test.cpp index 01a38d4f4a..a9500ee436 100644 --- a/search/search_integration_tests/pre_ranker_test.cpp +++ b/search/search_integration_tests/pre_ranker_test.cpp @@ -163,7 +163,7 @@ UNIT_CLASS_TEST(PreRankerTest, Smoke) TEST_LESS(index, pois.size(), ()); TEST(!checked[index], (index)); - TEST(base::AlmostEqualAbs(distances[index], results[i].GetDistance(), 1.0 /* 1 meter epsilon */), + TEST(AlmostEqualAbs(distances[index], results[i].GetDistance(), 1.0 /* 1 meter epsilon */), (distances[index], results[i].GetDistance())); checked[index] = true; } diff --git a/search/search_quality/search_quality_tool/search_quality_tool.cpp b/search/search_quality/search_quality_tool/search_quality_tool.cpp index f8774c901f..02ef643b98 100644 --- a/search/search_quality/search_quality_tool/search_quality_tool.cpp +++ b/search/search_quality/search_quality_tool/search_quality_tool.cpp @@ -178,7 +178,7 @@ void CalcStatistics(vector const & a, double & avg, double & maximum, do avg /= n; for (double const x : a) - var += base::Pow2(x - avg); + var += math::Pow2(x - avg); if (a.size() > 1) var /= n - 1; stdDev = sqrt(var); @@ -206,7 +206,7 @@ int FindResult(DataSource & dataSource, string const & mwmName, uint32_t const f { auto const & r = results[i]; if (r.HasPoint() && - base::AlmostEqualAbs(r.GetFeatureCenter(), mercator::FromLatLon(lat, lon), kEps)) + AlmostEqualAbs(r.GetFeatureCenter(), mercator::FromLatLon(lat, lon), kEps)) { double const dist = mercator::DistanceOnEarth(r.GetFeatureCenter(), mercator::FromLatLon(lat, lon)); diff --git a/search/search_tests/latlon_match_test.cpp b/search/search_tests/latlon_match_test.cpp index c807312ff1..2f871b752d 100644 --- a/search/search_tests/latlon_match_test.cpp +++ b/search/search_tests/latlon_match_test.cpp @@ -13,7 +13,7 @@ double const kEps = 1e-12; void TestAlmostEqual(double actual, double expected) { - TEST(base::AlmostEqualAbsOrRel(actual, expected, kEps), (actual, expected)); + TEST(AlmostEqualAbsOrRel(actual, expected, kEps), (actual, expected)); } UNIT_TEST(LatLon_Match_Smoke) diff --git a/search/search_tests/utm_mgrs_coords_match_test.cpp b/search/search_tests/utm_mgrs_coords_match_test.cpp index 49ba78f6f1..01082d3285 100644 --- a/search/search_tests/utm_mgrs_coords_match_test.cpp +++ b/search/search_tests/utm_mgrs_coords_match_test.cpp @@ -16,10 +16,10 @@ void TestAlmostEqual(std::optional const & maybeLatLon, double expec static double constexpr kEps = 1e-5; auto const actualLat = maybeLatLon->m_lat; - TEST(base::AlmostEqualAbsOrRel(actualLat, expectedLat, kEps), ("Lat is not close", actualLat, expectedLat)); + TEST(AlmostEqualAbsOrRel(actualLat, expectedLat, kEps), ("Lat is not close", actualLat, expectedLat)); auto const actualLon = maybeLatLon->m_lon; - TEST(base::AlmostEqualAbsOrRel(actualLon, expectedLon, kEps), ("Lon is not close", actualLon, expectedLon)); + TEST(AlmostEqualAbsOrRel(actualLon, expectedLon, kEps), ("Lon is not close", actualLon, expectedLon)); } UNIT_TEST(MatchUTMCoords) diff --git a/search/street_vicinity_loader.cpp b/search/street_vicinity_loader.cpp index db3a0f0d24..0e672cec9d 100644 --- a/search/street_vicinity_loader.cpp +++ b/search/street_vicinity_loader.cpp @@ -26,7 +26,7 @@ void StreetVicinityLoader::SetContext(MwmContext * context) m_context = context; auto const scaleRange = m_context->m_value.GetHeader().GetScaleRange(); - m_scale = base::Clamp(m_scale, scaleRange.first, scaleRange.second); + m_scale = math::Clamp(m_scale, scaleRange.first, scaleRange.second); } void StreetVicinityLoader::OnQueryFinished() { m_cache.ClearIfNeeded(); } diff --git a/search/utm_mgrs_coords_match.cpp b/search/utm_mgrs_coords_match.cpp index 2535feb2f6..79408d69b9 100644 --- a/search/utm_mgrs_coords_match.cpp +++ b/search/utm_mgrs_coords_match.cpp @@ -192,7 +192,7 @@ std::optional MatchMGRSCoords(std::string const & query) if (eastingStr.size() < 5) { uint64_t const decShift = 5 - eastingStr.size(); - easting *= base::PowUint(10, decShift); + easting *= math::PowUint(10, decShift); } if (!strings::to_int32(northingStr, northing)) @@ -200,7 +200,7 @@ std::optional MatchMGRSCoords(std::string const & query) if (northingStr.size() < 5) { uint64_t const decShift = 5 - northingStr.size(); - northing *= base::PowUint(10, decShift); + northing *= math::PowUint(10, decShift); } return utm_mgrs_utils::MGRStoLatLon(easting, northing, zoneCode, zoneLetter, squareCode); diff --git a/storage/storage_tests/helpers.cpp b/storage/storage_tests/helpers.cpp index bae64a3e5b..649f3e30a8 100644 --- a/storage/storage_tests/helpers.cpp +++ b/storage/storage_tests/helpers.cpp @@ -18,9 +18,9 @@ std::unique_ptr CreateCountryInfoGetter() bool AlmostEqualRectsAbs(const m2::RectD & r1, const m2::RectD & r2) { double constexpr kEpsilon = 1e-2; - return base::AlmostEqualAbs(r1.maxX(), r2.maxX(), kEpsilon) - && base::AlmostEqualAbs(r1.maxY(), r2.maxY(), kEpsilon) - && base::AlmostEqualAbs(r1.minX(), r2.minX(), kEpsilon) - && base::AlmostEqualAbs(r1.minY(), r2.minY(), kEpsilon); + return AlmostEqualAbs(r1.maxX(), r2.maxX(), kEpsilon) + && AlmostEqualAbs(r1.maxY(), r2.maxY(), kEpsilon) + && AlmostEqualAbs(r1.minX(), r2.minX(), kEpsilon) + && AlmostEqualAbs(r1.minY(), r2.minY(), kEpsilon); } } // namespace storage diff --git a/testing/testing.hpp b/testing/testing.hpp index b0c0edf24a..bf04fa942e 100644 --- a/testing/testing.hpp +++ b/testing/testing.hpp @@ -159,12 +159,12 @@ CommandLineOptions const & GetTestingOptions(); #define TEST_ALMOST_EQUAL_ULPS(X, Y, msg) \ do \ { \ - if (::base::AlmostEqualULPs(X, Y)) \ + if (AlmostEqualULPs(X, Y)) \ { \ } \ else \ { \ - ::base::OnTestFailed(SRC(), ::base::Message("TEST(base::AlmostEqualULPs(" #X ", " #Y ")", \ + ::base::OnTestFailed(SRC(), ::base::Message("TEST(AlmostEqualULPs(" #X ", " #Y ")", \ ::base::Message(X, Y), ::base::Message msg)); \ } \ } while (0) @@ -172,12 +172,12 @@ CommandLineOptions const & GetTestingOptions(); #define TEST_NOT_ALMOST_EQUAL_ULPS(X, Y, msg) \ do \ { \ - if (!::base::AlmostEqualULPs(X, Y)) \ + if (!AlmostEqualULPs(X, Y)) \ { \ } \ else \ { \ - ::base::OnTestFailed(SRC(), ::base::Message("TEST(!base::AlmostEqualULPs(" #X ", " #Y ")", \ + ::base::OnTestFailed(SRC(), ::base::Message("TEST(!AlmostEqualULPs(" #X ", " #Y ")", \ ::base::Message(X, Y), ::base::Message msg)); \ } \ } while (0) @@ -185,13 +185,13 @@ CommandLineOptions const & GetTestingOptions(); #define TEST_ALMOST_EQUAL_ABS(X, Y, eps, msg) \ do \ { \ - if (::base::AlmostEqualAbs(X, Y, eps)) \ + if (AlmostEqualAbs(X, Y, eps)) \ { \ } \ else \ { \ ::base::OnTestFailed(SRC(), \ - ::base::Message("TEST(!base::AlmostEqualAbs(" #X ", " #Y ", " #eps ")", \ + ::base::Message("TEST(!AlmostEqualAbs(" #X ", " #Y ", " #eps ")", \ ::base::Message(X, Y, eps), ::base::Message msg)); \ } \ } while (0) diff --git a/track_analyzing/track_analyzer/cmd_balance_csv.cpp b/track_analyzing/track_analyzer/cmd_balance_csv.cpp index 3e46d3ca78..90bec22a1f 100644 --- a/track_analyzing/track_analyzer/cmd_balance_csv.cpp +++ b/track_analyzing/track_analyzer/cmd_balance_csv.cpp @@ -78,7 +78,7 @@ MwmToDataPoints CalcsMatchedDataPointsToKeepDistribution( CHECK(!matchedDataPoints.empty(), ()); CHECK(AreKeysEqual(matchedDataPoints, distributionFractions), ("Mwms in |matchedDataPoints| and in |distributionFractions| should have the same set of keys.")); - CHECK(base::AlmostEqualAbs(ValueSum(distributionFractions), 1.0, kSumFractionEps), + CHECK(AlmostEqualAbs(ValueSum(distributionFractions), 1.0, kSumFractionEps), (ValueSum(distributionFractions))); auto const matchedFractions = GetMwmToDataPointFraction(matchedDataPoints); diff --git a/tracking/tracking_tests/protocol_test.cpp b/tracking/tracking_tests/protocol_test.cpp index 15c9aa7872..888f2403a5 100644 --- a/tracking/tracking_tests/protocol_test.cpp +++ b/tracking/tracking_tests/protocol_test.cpp @@ -104,9 +104,9 @@ void DecodeDataPacketVersionTest(Container const & points, Protocol::PacketType { TEST_EQUAL(points[i].m_timestamp, result[i].m_timestamp, (points[i].m_timestamp, result[i].m_timestamp)); - TEST(base::AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps), + TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lat, result[i].m_latLon.m_lat, kEps), (points[i].m_latLon.m_lat, result[i].m_latLon.m_lat)); - TEST(base::AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps), + TEST(AlmostEqualAbsOrRel(points[i].m_latLon.m_lon, result[i].m_latLon.m_lon, kEps), (points[i].m_latLon.m_lon, result[i].m_latLon.m_lon)); } } diff --git a/tracking/tracking_tests/reporter_test.cpp b/tracking/tracking_tests/reporter_test.cpp index e6a3f8af08..283ed721e5 100644 --- a/tracking/tracking_tests/reporter_test.cpp +++ b/tracking/tracking_tests/reporter_test.cpp @@ -73,8 +73,8 @@ void TransferLocation(Reporter & reporter, TestSocket & testSocket, double times TEST_EQUAL(points.size(), 1, ()); auto const & point = points[0]; TEST_EQUAL(point.m_timestamp, timestamp, ()); - TEST(base::AlmostEqualAbs(point.m_latLon.m_lat, latidute, 0.001), ()); - TEST(base::AlmostEqualAbs(point.m_latLon.m_lon, longtitude, 0.001), ()); + TEST(AlmostEqualAbs(point.m_latLon.m_lat, latidute, 0.001), ()); + TEST(AlmostEqualAbs(point.m_latLon.m_lon, longtitude, 0.001), ()); } } diff --git a/traffic/pytraffic/bindings.cpp b/traffic/pytraffic/bindings.cpp index 8695d9e107..49ac6a03cb 100644 --- a/traffic/pytraffic/bindings.cpp +++ b/traffic/pytraffic/bindings.cpp @@ -60,15 +60,15 @@ traffic::TrafficInfo::Coloring TransformToSpeedGroups(SegmentMapping const & seg double const ws = kv.second.m_weightedSpeed; double const wrs = kv.second.m_weightedRefSpeed; double const w = kv.second.m_weight; - if (base::AlmostEqualAbs(w, 0.0, kEps)) + if (AlmostEqualAbs(w, 0.0, kEps)) { LOG(LWARNING, ("A traffic segment has zero weight.")); continue; } double const u = ws / w; double const v = wrs / w; - bool const uz = base::AlmostEqualAbs(u, 0.0, kEps); - bool const vz = base::AlmostEqualAbs(v, 0.0, kEps); + bool const uz = AlmostEqualAbs(u, 0.0, kEps); + bool const vz = AlmostEqualAbs(v, 0.0, kEps); if (uz && vz) { result[kv.first] = traffic::SpeedGroup::TempBlock; @@ -81,7 +81,7 @@ traffic::TrafficInfo::Coloring TransformToSpeedGroups(SegmentMapping const & seg else { double p = 100.0 * u / v; - p = base::Clamp(p, 0.0, 100.0); + p = math::Clamp(p, 0.0, 100.0); result[kv.first] = traffic::GetSpeedGroupByPercentage(p); } } diff --git a/traffic/speed_groups.cpp b/traffic/speed_groups.cpp index 080bcff3f8..25498813ea 100644 --- a/traffic/speed_groups.cpp +++ b/traffic/speed_groups.cpp @@ -8,7 +8,7 @@ uint32_t const kSpeedGroupThresholdPercentage[] = {8, 16, 33, 58, 83, 100, 100, SpeedGroup GetSpeedGroupByPercentage(double p) { - p = base::Clamp(p, 0.0, 100.0); + p = math::Clamp(p, 0.0, 100.0); SpeedGroup res = SpeedGroup::Unknown; for (int i = static_cast(SpeedGroup::Count) - 1; i >= 0; --i) { diff --git a/transit/transit_tests/transit_tools.hpp b/transit/transit_tests/transit_tools.hpp index 3865cba401..f32d51bed5 100644 --- a/transit/transit_tests/transit_tools.hpp +++ b/transit/transit_tests/transit_tools.hpp @@ -69,7 +69,7 @@ inline bool Equal(Stop const & s1, Stop const & s2) std::make_tuple(s2.GetId(), s2.GetFeatureId(), s2.GetOsmId(), s2.GetTitle(), s2.GetTimeTable(), s2.GetTransferIds(), s2.GetBestPedestrianSegments())) && - base::AlmostEqualAbs(s1.GetPoint(), s2.GetPoint(), kPointsEqualEpsilon); + AlmostEqualAbs(s1.GetPoint(), s2.GetPoint(), kPointsEqualEpsilon); } inline bool Equal(Gate const & g1, Gate const & g2) @@ -78,7 +78,7 @@ inline bool Equal(Gate const & g1, Gate const & g2) g1.IsExit(), g1.GetStopsWithWeight(), g1.GetBestPedestrianSegments()) == std::make_tuple(g2.GetId(), g2.GetFeatureId(), g2.GetOsmId(), g2.IsEntrance(), g2.IsExit(), g2.GetStopsWithWeight(), g2.GetBestPedestrianSegments())) && - base::AlmostEqualAbs(g1.GetPoint(), g2.GetPoint(), kPointsEqualEpsilon); + AlmostEqualAbs(g1.GetPoint(), g2.GetPoint(), kPointsEqualEpsilon); } inline bool Equal(Edge const & e1, Edge const & e2) @@ -93,7 +93,7 @@ inline bool Equal(Transfer const & t1, Transfer const & t2) { return (std::make_tuple(t1.GetId(), t1.GetStopIds()) == std::make_tuple(t2.GetId(), t2.GetStopIds())) && - base::AlmostEqualAbs(t1.GetPoint(), t2.GetPoint(), kPointsEqualEpsilon); + AlmostEqualAbs(t1.GetPoint(), t2.GetPoint(), kPointsEqualEpsilon); } inline bool Equal(Shape const & s1, Shape const & s2) diff --git a/transit/transit_types.cpp b/transit/transit_types.cpp index 6f5298ba84..7b52d270f8 100644 --- a/transit/transit_types.cpp +++ b/transit/transit_types.cpp @@ -139,7 +139,7 @@ bool Stop::IsEqualForTesting(Stop const & stop) const double constexpr kPointsEqualEpsilon = 1e-6; return m_id == stop.m_id && m_featureIdentifiers == stop.m_featureIdentifiers && m_transferId == stop.m_transferId && m_lineIds == stop.m_lineIds && - base::AlmostEqualAbs(m_point, stop.m_point, kPointsEqualEpsilon) && + AlmostEqualAbs(m_point, stop.m_point, kPointsEqualEpsilon) && m_titleAnchors == stop.m_titleAnchors; } @@ -200,7 +200,7 @@ bool Gate::IsEqualForTesting(Gate const & gate) const { return m_featureIdentifiers == gate.m_featureIdentifiers && m_entrance == gate.m_entrance && m_exit == gate.m_exit && m_weight == gate.m_weight && m_stopIds == gate.m_stopIds && - base::AlmostEqualAbs(m_point, gate.m_point, kPointsEqualEpsilon); + AlmostEqualAbs(m_point, gate.m_point, kPointsEqualEpsilon); } bool Gate::IsValid() const @@ -311,7 +311,7 @@ Transfer::Transfer(StopId id, m2::PointD const & point, std::vector cons bool Transfer::IsEqualForTesting(Transfer const & transfer) const { return m_id == transfer.m_id && - base::AlmostEqualAbs(m_point, transfer.m_point, kPointsEqualEpsilon) && + AlmostEqualAbs(m_point, transfer.m_point, kPointsEqualEpsilon) && m_stopIds == transfer.m_stopIds && m_titleAnchors == transfer.m_titleAnchors; } @@ -356,7 +356,7 @@ bool Shape::IsEqualForTesting(Shape const & shape) const for (size_t i = 0; i < m_polyline.size(); ++i) { - if (!base::AlmostEqualAbs(m_polyline[i], shape.m_polyline[i], kPointsEqualEpsilon)) + if (!AlmostEqualAbs(m_polyline[i], shape.m_polyline[i], kPointsEqualEpsilon)) return false; } return true; diff --git a/transit/world_feed/feed_helpers.cpp b/transit/world_feed/feed_helpers.cpp index 56e04e7192..c50d82053e 100644 --- a/transit/world_feed/feed_helpers.cpp +++ b/transit/world_feed/feed_helpers.cpp @@ -68,12 +68,12 @@ ProjectionData GetProjection(std::vector const & polyline, size_t in CHECK_GREATER_OR_EQUAL(next, 0, ()); CHECK_LESS(static_cast(next), polyline.size(), ()); - if (base::AlmostEqualAbs(proj.m_point, polyline[index], kEps)) + if (AlmostEqualAbs(proj.m_point, polyline[index], kEps)) { projData.m_indexOnShape = index; projData.m_needsInsertion = false; } - else if (base::AlmostEqualAbs(proj.m_point, polyline[next], kEps)) + else if (AlmostEqualAbs(proj.m_point, polyline[next], kEps)) { projData.m_indexOnShape = next; projData.m_needsInsertion = false; @@ -360,7 +360,7 @@ std::pair FindIntersections(std::vector for (size_t k = 0; k < len; ++k) { - if (!base::AlmostEqualAbs(line1[i + k], line2[j + k], eps)) + if (!AlmostEqualAbs(line1[i + k], line2[j + k], eps)) break; ++intersection; } @@ -464,7 +464,7 @@ std::vector GetMinDistIndexes(std::vector const & shape, { double dist = mercator::DistanceOnEarth(shape[i], point); - if (base::AlmostEqualAbs(dist, minDist, kEps)) + if (AlmostEqualAbs(dist, minDist, kEps)) { indexes.push_back(i); continue; diff --git a/transit/world_feed/subway_converter.cpp b/transit/world_feed/subway_converter.cpp index a80f1eff52..5ddd4ebcda 100644 --- a/transit/world_feed/subway_converter.cpp +++ b/transit/world_feed/subway_converter.cpp @@ -595,7 +595,7 @@ bool Equal(LineGeometry const & line1, LineGeometry const & line2) for (size_t i = 0; i < line1.size(); ++i) { - if (!base::AlmostEqualAbs(line1[i], line2[i], kEps)) + if (!AlmostEqualAbs(line1[i], line2[i], kEps)) return false; } @@ -644,7 +644,7 @@ void SubwayConverter::CalculateLinePriorities(std::vector const for (auto const & [parallelLineId, parallelFirstPoint] : linePart.m_commonLines) { bool const codirectional = - base::AlmostEqualAbs(linePart.m_firstPoint, parallelFirstPoint, kEps); + AlmostEqualAbs(linePart.m_firstPoint, parallelFirstPoint, kEps); startPointState.parallelLineStates[parallelLineId] = LineSegmentInfo(LineSegmentState::Start, codirectional); @@ -813,10 +813,10 @@ void SubwayConverter::PrepareLinesMetadata() auto const & [startPoint2, endPoint2] = GetSegmentEdgesOnPolyline(polyline2, segments2[k]); - CHECK((base::AlmostEqualAbs(startPoint1, startPoint2, kEps) && - base::AlmostEqualAbs(endPoint1, endPoint2, kEps)) || - (base::AlmostEqualAbs(startPoint1, endPoint2, kEps) && - base::AlmostEqualAbs(endPoint1, startPoint2, kEps)), ()); + CHECK((AlmostEqualAbs(startPoint1, startPoint2, kEps) && + AlmostEqualAbs(endPoint1, endPoint2, kEps)) || + (AlmostEqualAbs(startPoint1, endPoint2, kEps) && + AlmostEqualAbs(endPoint1, startPoint2, kEps)), ()); ShiftSegmentOnShape(segments1[k], shapeLink1); ShiftSegmentOnShape(segments2[k], shapeLink2); diff --git a/transit/world_feed/world_feed_tests/world_feed_tests.cpp b/transit/world_feed/world_feed_tests/world_feed_tests.cpp index 256e2023ee..f7a0cd8fcb 100644 --- a/transit/world_feed/world_feed_tests/world_feed_tests.cpp +++ b/transit/world_feed/world_feed_tests/world_feed_tests.cpp @@ -386,27 +386,27 @@ UNIT_TEST(Transit_GTFS_ProjectStopToLine_NearCircle) TEST_EQUAL(ResT(17, true), PrepareNearestPointOnTrack(point_A, std::nullopt, shape.size() - 1/* prevIndex */, Direction::Backward, shape), ()); - TEST(base::AlmostEqualAbs(coordA, shape[17], kEps), (coordA, shape[17])); + TEST(AlmostEqualAbs(coordA, shape[17], kEps), (coordA, shape[17])); TEST_EQUAL(ResT(16, false), PrepareNearestPointOnTrack(point_B, std::nullopt, 17 /* prevIndex */, Direction::Backward, shape), ()); - TEST(base::AlmostEqualAbs(coordB, shape[16], kEps), (coordA, shape[17])); + TEST(AlmostEqualAbs(coordB, shape[16], kEps), (coordA, shape[17])); TEST_EQUAL(ResT(10, true), PrepareNearestPointOnTrack(point_C, std::nullopt, 16 /* prevIndex */, Direction::Backward, shape), ()); - TEST(base::AlmostEqualAbs(coordC, shape[10], kEps), (coordA, shape[17])); + TEST(AlmostEqualAbs(coordC, shape[10], kEps), (coordA, shape[17])); TEST_EQUAL(ResT(8, false), PrepareNearestPointOnTrack(point_D, std::nullopt, 10 /* prevIndex */, Direction::Backward, shape), ()); - TEST(base::AlmostEqualAbs(coordD, shape[8], kEps), (coordA, shape[17])); + TEST(AlmostEqualAbs(coordD, shape[8], kEps), (coordA, shape[17])); TEST_EQUAL(ResT(7, true), PrepareNearestPointOnTrack(point_E, std::nullopt, 8 /* prevIndex */, Direction::Backward, shape), ()); - TEST(base::AlmostEqualAbs(coordE, shape[7], kEps), (coordA, shape[17])); + TEST(AlmostEqualAbs(coordE, shape[7], kEps), (coordA, shape[17])); // point_F has different position because we do not insert before point 0. TEST_EQUAL(ResT(2, true), -- 2.45.3