diff options
25 files changed, 272 insertions, 72 deletions
diff --git a/.gitignore b/.gitignore index 6dda52618d..c1f2a30f5c 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,10 @@ data/stats data/*/*.bftsegbits data/*/*.bftsegnodes data/*/*.offsets +# metrics +data/metric/* +# notifications +data/notifications/* # benchmark results data/benchmarks/*.trace diff --git a/android/jni/com/mapswithme/maps/metrics/UserActionsLogger.cpp b/android/jni/com/mapswithme/maps/metrics/UserActionsLogger.cpp index b080349095..6609131559 100644 --- a/android/jni/com/mapswithme/maps/metrics/UserActionsLogger.cpp +++ b/android/jni/com/mapswithme/maps/metrics/UserActionsLogger.cpp @@ -1,10 +1,30 @@ #include <jni.h> #include <android/jni/com/mapswithme/maps/Framework.hpp> + #include "com/mapswithme/core/jni_helper.hpp" #include "com/mapswithme/platform/Platform.hpp" + +#include "map/utils.hpp" + #include "metrics/eye.hpp" #include "metrics/eye_info.hpp" +namespace +{ +void RegisterEventIfPossible(eye::MapObject::Event::Type const type) +{ + place_page::Info & info = g_framework->GetPlacePageInfo(); + + auto const userPos = g_framework->NativeFramework()->GetCurrentPosition(); + if (userPos) + { + eye::MapObject const mapObject = utils::MakeEyeMapObject(info); + if (!mapObject.IsEmpty()) + eye::Eye::Event::MapObjectEvent(mapObject, type, userPos.get()); + } +} +} // namespace + extern "C" { JNIEXPORT void JNICALL Java_com_mapswithme_maps_metrics_UserActionsLogger_nativeTipClicked( @@ -42,4 +62,22 @@ Java_com_mapswithme_maps_metrics_UserActionsLogger_nativeDiscoveryItemClicked(JN auto const & event = static_cast<eye::Discovery::Event>(eventType); eye::Eye::Event::DiscoveryItemClicked(event); } + +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_metrics_UserActionsLogger_nativeAddToBookmark(JNIEnv *, jclass) +{ + RegisterEventIfPossible(eye::MapObject::Event::Type::AddToBookmark); +} + +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_metrics_UserActionsLogger_nativeUgcEditorOpened(JNIEnv *, jclass) +{ + RegisterEventIfPossible(eye::MapObject::Event::Type::UgcEditorOpened); +} + +JNIEXPORT void JNICALL +Java_com_mapswithme_maps_metrics_UserActionsLogger_nativeUgcSaved(JNIEnv *, jclass) +{ + RegisterEventIfPossible(eye::MapObject::Event::Type::UgcSaved); +} } diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java index 318ed2a133..3e888aefea 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java @@ -6,6 +6,7 @@ import android.support.annotation.NonNull; import com.mapswithme.maps.PrivateVariables; import com.mapswithme.maps.R; +import com.mapswithme.maps.metrics.UserActionsLogger; import com.mapswithme.util.statistics.Statistics; import java.io.File; @@ -98,6 +99,7 @@ public enum BookmarkManager public Bookmark addNewBookmark(double lat, double lon) { final Bookmark bookmark = nativeAddBookmarkToLastEditedCategory(lat, lon); + UserActionsLogger.logAddToBookmarkEvent(); Statistics.INSTANCE.trackBookmarkCreated(); return bookmark; } diff --git a/android/src/com/mapswithme/maps/metrics/UserActionsLogger.java b/android/src/com/mapswithme/maps/metrics/UserActionsLogger.java index af6ec0d962..191ce79f7e 100644 --- a/android/src/com/mapswithme/maps/metrics/UserActionsLogger.java +++ b/android/src/com/mapswithme/maps/metrics/UserActionsLogger.java @@ -33,9 +33,27 @@ public class UserActionsLogger nativeDiscoveryItemClicked(event.ordinal()); } + public static void logAddToBookmarkEvent() + { + nativeAddToBookmark(); + } + + public static void logUgcEditorOpened() + { + nativeUgcEditorOpened(); + } + + public static void logUgcSaved() + { + nativeUgcSaved(); + } + private static native void nativeTipClicked(int type, int event); private static native void nativeBookingFilterUsed(); private static native void nativeBookmarksCatalogShown(); private static native void nativeDiscoveryShown(); private static native void nativeDiscoveryItemClicked(int event); + private static native void nativeAddToBookmark(); + private static native void nativeUgcEditorOpened(); + private static native void nativeUgcSaved(); } diff --git a/android/src/com/mapswithme/maps/ugc/UGCEditorActivity.java b/android/src/com/mapswithme/maps/ugc/UGCEditorActivity.java index 74e6fd9000..b6abb004c4 100644 --- a/android/src/com/mapswithme/maps/ugc/UGCEditorActivity.java +++ b/android/src/com/mapswithme/maps/ugc/UGCEditorActivity.java @@ -8,6 +8,7 @@ import android.support.annotation.StyleRes; import android.support.v4.app.Fragment; import com.mapswithme.maps.base.BaseMwmFragmentActivity; +import com.mapswithme.maps.metrics.UserActionsLogger; import com.mapswithme.util.ThemeUtils; import com.mapswithme.util.statistics.Statistics; @@ -16,6 +17,7 @@ public class UGCEditorActivity extends BaseMwmFragmentActivity public static void start(@NonNull Activity activity, @NonNull EditParams params) { Statistics.INSTANCE.trackUGCStart(false /* isEdit */, params.isFromPP()); + UserActionsLogger.logUgcEditorOpened(); final Intent i = new Intent(activity, UGCEditorActivity.class); Bundle args = new Bundle(); args.putParcelable(UGCEditorFragment.ARG_FEATURE_ID, params.getFeatureId()); diff --git a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java index 8b6c9dd988..f7e62a6eef 100644 --- a/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java +++ b/android/src/com/mapswithme/maps/ugc/UGCEditorFragment.java @@ -15,6 +15,7 @@ import com.mapswithme.maps.R; import com.mapswithme.maps.auth.BaseMwmAuthorizationFragment; import com.mapswithme.maps.background.Notifier; import com.mapswithme.maps.bookmarks.data.FeatureId; +import com.mapswithme.maps.metrics.UserActionsLogger; import com.mapswithme.maps.widget.ToolbarController; import com.mapswithme.util.ConnectionState; import com.mapswithme.util.Language; @@ -162,6 +163,7 @@ public class UGCEditorFragment extends BaseMwmAuthorizationFragment "; lon = " + getArguments().getDouble(ARG_LON)); } UGC.setUGCUpdate(featureId, update); + UserActionsLogger.logUgcSaved(); Statistics.INSTANCE.trackEvent(Statistics.EventName.UGC_REVIEW_SUCCESS); } } diff --git a/defines.hpp b/defines.hpp index a99faf0149..a3c3625b7b 100644 --- a/defines.hpp +++ b/defines.hpp @@ -115,3 +115,4 @@ #define BOOKING_EXCLUDED_FILE "booking_excluded.txt" auto constexpr kInvalidRatingValue = 0.0f; +auto constexpr kMwmPointAccuracy = 1e-5; diff --git a/indexer/feature_utils.cpp b/indexer/feature_utils.cpp index fc24df3ea0..b073749ca7 100644 --- a/indexer/feature_utils.cpp +++ b/indexer/feature_utils.cpp @@ -155,10 +155,8 @@ void GetReadableNameImpl(feature::RegionData const & regionData, StringUtf8Multi namespace feature { - namespace impl { - class FeatureEstimator { template <size_t N> diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h index e12e5ce114..6b7a20ce7e 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.h +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.h @@ -159,6 +159,8 @@ using NewSectionsAreReady = void (^)(NSRange const & range, MWMPlacePageData * d // ready callback will be called from main queue. - (instancetype)initWithPlacePageInfo:(place_page::Info const &)info; +- (place_page::Info const &)getRawData; + - (void)fillSections; - (void)updateBookmarkStatus:(BOOL)isBookmark; diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm index dc6e0c4fa1..79977d7ee6 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageData.mm @@ -70,6 +70,8 @@ NSString * const kUserDefaultsLatLonAsDMSKey = @"UserDefaultsLatLonAsDMS"; return self; } +- (place_page::Info const &)getRawData { return m_info; } + #pragma mark - Filling sections - (void)fillSections diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index b78463dc71..2cb5884836 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -23,6 +23,7 @@ #include "Framework.h" #include "map/bookmark.hpp" +#include "map/utils.hpp" #include "geometry/distance_on_sphere.hpp" @@ -65,7 +66,18 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName) } [Statistics logEvent:eventName withParameters:stat atLocation:[MWMLocationManager lastLocation]]; +} + +void RegisterEventIfPossible(eye::MapObject::Event::Type const type, place_page::Info const & info) +{ + auto const userPos = GetFramework().GetCurrentPosition(); + if (userPos) + { + eye::MapObject const mapObject = utils::MakeEyeMapObject(info); + if (!mapObject.IsEmpty()) + eye::Eye::Event::MapObjectEvent(mapObject, type, userPos.get()); } +} } // namespace @interface MWMPlacePageManager ()<MWMFrameworkStorageObserver, MWMPlacePageLayoutDelegate, @@ -436,6 +448,7 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName) auto data = self.data; if (!data) return; + RegisterEventIfPossible(eye::MapObject::Event::Type::AddToBookmark, data.getRawData); [Statistics logEvent:kStatBookmarkCreated]; [data updateBookmarkStatus:YES]; [self.layout reloadBookmarkSection:YES]; @@ -591,6 +604,7 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName) maxValue:5.0f]]; auto title = data.title; + RegisterEventIfPossible(eye::MapObject::Event::Type::UgcEditorOpened, data.getRawData); [Statistics logEvent:kStatUGCReviewStart withParameters:@{ kStatIsAuthenticated: @([MWMAuthorizationViewModel isAuthenticated]), @@ -609,6 +623,9 @@ void logSponsoredEvent(MWMPlacePageData * data, NSString * eventName) NSAssert(false, @""); return; } + RegisterEventIfPossible( + eye::MapObject::Event::Type::UgcSaved, + data.getRawData); [data setUGCUpdateFrom:model]; }]; [[MapViewController sharedController].navigationController pushViewController:ugcVC animated:YES]; diff --git a/map/CMakeLists.txt b/map/CMakeLists.txt index 28063efbc4..ca3be83014 100644 --- a/map/CMakeLists.txt +++ b/map/CMakeLists.txt @@ -119,6 +119,8 @@ set( user_mark_layer.hpp user_mark.cpp user_mark.hpp + utils.cpp + utils.hpp viewport_search_params.hpp viewport_search_callback.cpp viewport_search_callback.hpp diff --git a/map/framework.cpp b/map/framework.cpp index 7f21a7ebac..d79bd8035c 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -8,6 +8,7 @@ #include "map/gps_tracker.hpp" #include "map/taxi_delegate.hpp" #include "map/user_mark.hpp" +#include "map/utils.hpp" #include "map/viewport_search_params.hpp" #include "defines.hpp" @@ -185,6 +186,34 @@ string MakeSearchBookingUrl(booking::Api const & bookingApi, search::CityFinder return bookingApi.GetSearchUrl(city, name); } + +void OnRouteStartBuild(DataSource const & dataSource, + std::vector<RouteMarkData> const & routePoints, m2::PointD const & userPos) +{ + using eye::MapObject; + + if (routePoints.size() < 2) + return; + + for (auto const & pt : routePoints) + { + if (pt.m_isMyPosition || pt.m_pointType == RouteMarkType::Start) + continue; + + m2::RectD rect(MercatorBounds::ClampX(pt.m_position.x - kMwmPointAccuracy), + MercatorBounds::ClampY(pt.m_position.y - kMwmPointAccuracy), + MercatorBounds::ClampX(pt.m_position.x + kMwmPointAccuracy), + MercatorBounds::ClampY(pt.m_position.y + kMwmPointAccuracy)); + + dataSource.ForEachInRect([&userPos](FeatureType & ft) + { + auto const mapObject = utils::MakeEyeMapObject(ft); + if (!mapObject.IsEmpty()) + eye::Eye::Event::MapObjectEvent(mapObject, MapObject::Event::Type::RouteToCreated, userPos); + }, + rect, scales::GetUpperScale()); + } +} } // namespace pair<MwmSet::MwmId, MwmSet::RegResult> Framework::RegisterMap( @@ -458,6 +487,12 @@ Framework::Framework(FrameworkParams const & params) m_user.AddSubscriber(m_bmManager->GetUserSubscriber()); m_routingManager.SetTransitManager(&m_transitManager); + m_routingManager.SetRouteStartBuildListener([this](std::vector<RouteMarkData> const & points) + { + auto const userPos = GetCurrentPosition(); + if (userPos) + OnRouteStartBuild(m_model.GetDataSource(), points, userPos.get()); + }); InitCityFinder(); InitDiscoveryManager(); @@ -2401,6 +2436,18 @@ df::SelectionShape::ESelectedObject Framework::OnTapEventImpl(TapEvent const & t if (showMapSelection) { GetBookmarkManager().SelectionMark().SetPtOrg(outInfo.GetMercator()); + + auto const userPos = GetCurrentPosition(); + if (userPos) + { + eye::MapObject const mapObject = utils::MakeEyeMapObject(outInfo); + if (!mapObject.IsEmpty()) + { + eye::Eye::Event::MapObjectEvent(mapObject, eye::MapObject::Event::Type::Open, + userPos.get()); + } + } + return df::SelectionShape::OBJECT_POI; } diff --git a/map/notifications/notification_manager.cpp b/map/notifications/notification_manager.cpp index 2b1916fb41..98c37b3f05 100644 --- a/map/notifications/notification_manager.cpp +++ b/map/notifications/notification_manager.cpp @@ -20,11 +20,6 @@ auto constexpr kCandidatesExpirePeriod = std::chrono::hours(24 * 30); auto constexpr kPeriodBetweenNotifications = std::chrono::hours(24 * 7); auto constexpr kMinTimeSinceLastEventForUgcRate = std::chrono::hours(24); -std::array<std::string, 7> const kUgcRateSupportedTypes = {"amenity-bar", "amenity-cafe", - "amenity-pub", "amenity-restaurant", - "amenity-fast_food", "amenity-biergarden", - "shop-bakery"}; - double constexpr kMinDistanceToTriggerUgcRateInMeters = 50000.0; // 50 km uint32_t constexpr kOpenCountForPlannedTripTrigger = 2; @@ -194,16 +189,6 @@ bool NotificationManager::Save() void NotificationManager::ProcessUgcRateCandidates(eye::MapObject const & poi) { - if (poi.GetReadableName().empty()) - return; - - { - auto const it = std::find(kUgcRateSupportedTypes.cbegin(), kUgcRateSupportedTypes.cend(), - poi.GetBestType()); - if (it == kUgcRateSupportedTypes.cend()) - return; - } - CHECK_GREATER(poi.GetEvents().size(), 0, ()); auto it = m_queue.m_candidates.begin(); diff --git a/map/place_page_info.cpp b/map/place_page_info.cpp index 5a7948b9e7..ad42265fef 100644 --- a/map/place_page_info.cpp +++ b/map/place_page_info.cpp @@ -54,6 +54,7 @@ void Info::SetFromFeatureType(FeatureType & ft) GetPrefferedNames(primaryName, secondaryName); m_sortedTypes = m_types; m_sortedTypes.SortBySpec(); + m_primaryFeatureName = primaryName; if (IsBookmark()) { m_uiTitle = GetBookmarkName(); diff --git a/map/place_page_info.hpp b/map/place_page_info.hpp index d9472a275d..acfb1d8262 100644 --- a/map/place_page_info.hpp +++ b/map/place_page_info.hpp @@ -219,6 +219,7 @@ public: void SetPopularity(uint8_t popularity) { m_popularity = popularity; } uint8_t GetPopularity() const { return m_popularity; } + std::string const & GetPrimaryFeatureName() const { return m_primaryFeatureName; }; private: std::string FormatSubtitle(bool withType) const; @@ -309,6 +310,8 @@ private: boost::optional<ftypes::IsHotelChecker::Type> m_hotelType; uint8_t m_popularity = 0; + + std::string m_primaryFeatureName; }; namespace rating diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index a04f091069..f51fff052b 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -868,6 +868,8 @@ void RoutingManager::BuildRoute(uint32_t timeoutSec) GetPlatform().GetMarketingService().SendPushWooshTag(tag); } + CallRouteBuildStart(routePoints); + if (IsRoutingActive()) CloseRouting(false /* remove route points */); @@ -939,6 +941,11 @@ void RoutingManager::CallRouteBuilded(RouterResultCode code, m_routingBuildingCallback(code, absentCountries); } +void RoutingManager::CallRouteBuildStart(std::vector<RouteMarkData> const & points) +{ + m_routingStartBuildCallback(points); +} + void RoutingManager::MatchLocationToRoute(location::GpsInfo & location, location::RouteMatchingInfo & routeMatchingInfo) const { diff --git a/map/routing_manager.hpp b/map/routing_manager.hpp index 90644138a2..db121babc6 100644 --- a/map/routing_manager.hpp +++ b/map/routing_manager.hpp @@ -93,6 +93,8 @@ public: using RouteBuildingCallback = std::function<void(routing::RouterResultCode, storage::TCountriesVec const &)>; + using RouteStartBuildCallback = std::function<void(std::vector<RouteMarkData> const & points)>; + enum class Recommendation { // It can be recommended if location is found almost immediately @@ -131,6 +133,10 @@ public: { m_routingBuildingCallback = buildingCallback; } + void SetRouteStartBuildListener(RouteStartBuildCallback const & startBuildCallback) + { + m_routingStartBuildCallback = startBuildCallback; + } /// See warning above. void SetRouteProgressListener(routing::ProgressCallback const & progressCallback) { @@ -209,6 +215,7 @@ public: void OnRemoveRoute(routing::RouterResultCode code); void OnRoutePointPassed(RouteMarkType type, size_t intermediateIndex); void OnLocationUpdate(location::GpsInfo const & info); + void CallRouteBuildStart(std::vector<RouteMarkData> const & points); void SetAllowSendingPoints(bool isAllowed) { m_trackingReporter.SetAllowSendingPoints(isAllowed); @@ -291,8 +298,9 @@ private: void OnExtrapolatedLocationUpdate(location::GpsInfo const & info); - RouteBuildingCallback m_routingBuildingCallback = nullptr; - RouteRecommendCallback m_routeRecommendCallback = nullptr; + RouteBuildingCallback m_routingBuildingCallback; + RouteRecommendCallback m_routeRecommendCallback; + RouteStartBuildCallback m_routingStartBuildCallback; Callbacks m_callbacks; df::DrapeEngineSafePtr m_drapeEngine; routing::RouterType m_currentRouterType = routing::RouterType::Count; diff --git a/map/utils.cpp b/map/utils.cpp new file mode 100644 index 0000000000..bdd9152b53 --- /dev/null +++ b/map/utils.cpp @@ -0,0 +1,52 @@ +#include "map/utils.hpp" + +#include "map/place_page_info.hpp" + +#include "indexer/feature.hpp" +#include "indexer/feature_algo.hpp" + +namespace utils +{ +eye::MapObject MakeEyeMapObject(place_page::Info const & info) +{ + if (!info.IsFeature()) + return {}; + + auto types = info.GetTypes(); + if (types.Empty()) + return {}; + + types.SortBySpec(); + + eye::MapObject mapObject; + mapObject.SetBestType(classif().GetReadableObjectName(types.GetBestType())); + mapObject.SetPos(info.GetMercator()); + mapObject.SetDefaultName(info.GetDefaultName()); + mapObject.SetReadableName(info.GetPrimaryFeatureName()); + + return mapObject; +} + +eye::MapObject MakeEyeMapObject(FeatureType & ft) +{ + feature::TypesHolder types(ft); + if (types.Empty()) + return {}; + + types.SortBySpec(); + + eye::MapObject mapObject; + mapObject.SetBestType(classif().GetReadableObjectName(types.GetBestType())); + mapObject.SetPos(feature::GetCenter(ft)); + + string name; + if (ft.GetName(StringUtf8Multilang::kDefaultCode, name)) + mapObject.SetDefaultName(name); + + name.clear(); + ft.GetReadableName(name); + mapObject.SetReadableName(name); + + return mapObject; +} +} // namespace utils diff --git a/map/utils.hpp b/map/utils.hpp new file mode 100644 index 0000000000..5dc3fcf8c8 --- /dev/null +++ b/map/utils.hpp @@ -0,0 +1,20 @@ +#pragma once + +#include "metrics/eye_info.hpp" + +namespace place_page +{ +class Info; +} +namespace eye +{ +class MapObject; +} + +class FeatureType; + +namespace utils +{ +eye::MapObject MakeEyeMapObject(place_page::Info const & info); +eye::MapObject MakeEyeMapObject(FeatureType & ft); +} // namespace utils diff --git a/metrics/eye.cpp b/metrics/eye.cpp index a889b44ff8..eda6f08ca2 100644 --- a/metrics/eye.cpp +++ b/metrics/eye.cpp @@ -21,6 +21,11 @@ namespace // Three months. auto constexpr kMapObjectEventsExpirePeriod = std::chrono::hours(24 * 30 * 3); +std::array<std::string, 7> const kMapEventSupportedTypes = {"amenity-bar", "amenity-cafe", + "amenity-pub", "amenity-restaurant", + "amenity-fast_food", "amenity-biergarden", + "shop-bakery"}; + void Load(Info & info) { Storage::Migrate(); @@ -422,47 +427,22 @@ void Eye::Event::LayerShown(Layer::Type type) } // static -void Eye::Event::PlacePageOpened(MapObject const & mapObject, m2::PointD const & userPos) -{ - GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] - { - Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::Open, userPos); - }); -} - -// static -void Eye::Event::UgcEditorOpened(MapObject const & mapObject, m2::PointD const & userPos) -{ - GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] - { - Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::UgcEditorOpened, userPos); - }); -} - -// static -void Eye::Event::UgcSaved(MapObject const & mapObject, m2::PointD const & userPos) +void Eye::Event::MapObjectEvent(MapObject const & mapObject, MapObject::Event::Type type, + m2::PointD const & userPos) { - GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] - { - Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::UgcSaved, userPos); - }); -} + if (mapObject.GetReadableName().empty()) + return; -// static -void Eye::Event::AddToBookmarkClicked(MapObject const & mapObject, m2::PointD const & userPos) -{ - GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] { - Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::AddToBookmark, userPos); - }); -} + auto const it = std::find(kMapEventSupportedTypes.cbegin(), kMapEventSupportedTypes.cend(), + mapObject.GetBestType()); + if (it == kMapEventSupportedTypes.cend()) + return; + } -// static -void Eye::Event::RouteCreatedToObject(MapObject const & mapObject, m2::PointD const & userPos) -{ - GetPlatform().RunTask(Platform::Thread::File, [mapObject, userPos] + GetPlatform().RunTask(Platform::Thread::File, [type, mapObject, userPos] { - Instance().RegisterMapObjectEvent(mapObject, MapObject::Event::Type::RouteToCreated, userPos); + Instance().RegisterMapObjectEvent(mapObject, type, userPos); }); } } // namespace eye diff --git a/metrics/eye.hpp b/metrics/eye.hpp index fe22baf7bd..cc9abb803f 100644 --- a/metrics/eye.hpp +++ b/metrics/eye.hpp @@ -45,11 +45,8 @@ public: static void DiscoveryShown(); static void DiscoveryItemClicked(Discovery::Event event); static void LayerShown(Layer::Type type); - static void PlacePageOpened(MapObject const & mapObject, m2::PointD const & userPos); - static void UgcEditorOpened(MapObject const & mapObject, m2::PointD const & userPos); - static void UgcSaved(MapObject const & mapObject, m2::PointD const & userPos); - static void AddToBookmarkClicked(MapObject const & mapObject, m2::PointD const & userPos); - static void RouteCreatedToObject(MapObject const & mapObject, m2::PointD const & userPos); + static void MapObjectEvent(MapObject const & mapObject, MapObject::Event::Type type, + m2::PointD const & userPos); }; static Eye & Instance(); diff --git a/metrics/eye_info.hpp b/metrics/eye_info.hpp index 49dde1983f..8221a2f00f 100644 --- a/metrics/eye_info.hpp +++ b/metrics/eye_info.hpp @@ -14,6 +14,8 @@ #include <type_traits> #include <vector> +#include "defines.hpp" + namespace eye { namespace traits @@ -189,10 +191,10 @@ public: : m_bestType(bestType) , m_pos(pos) , m_readableName(readableName) - , m_limitRect(MercatorBounds::ClampX(pos.x - kPointAccuracy), - MercatorBounds::ClampY(pos.y - kPointAccuracy), - MercatorBounds::ClampX(pos.x + kPointAccuracy), - MercatorBounds::ClampY(pos.y + kPointAccuracy)) + , m_limitRect(MercatorBounds::ClampX(pos.x - kMwmPointAccuracy), + MercatorBounds::ClampY(pos.y - kMwmPointAccuracy), + MercatorBounds::ClampX(pos.x + kMwmPointAccuracy), + MercatorBounds::ClampY(pos.y + kMwmPointAccuracy)) { } @@ -206,8 +208,8 @@ public: bool AlmostEquals(MapObject const & rhs) const { - return GetPos().EqualDxDy(rhs.GetPos(), kPointAccuracy) && GetBestType() == rhs.GetBestType() && - GetDefaultName() == rhs.GetDefaultName(); + return GetPos().EqualDxDy(rhs.GetPos(), kMwmPointAccuracy) && + GetBestType() == rhs.GetBestType() && GetDefaultName() == rhs.GetDefaultName(); } std::string const & GetBestType() const { return m_bestType; } @@ -219,10 +221,10 @@ public: void SetPos(m2::PointD const & pos) { m_pos = pos; - m_limitRect = {MercatorBounds::ClampX(pos.x - kPointAccuracy), - MercatorBounds::ClampY(pos.y - kPointAccuracy), - MercatorBounds::ClampX(pos.x + kPointAccuracy), - MercatorBounds::ClampY(pos.y + kPointAccuracy)}; + m_limitRect = {MercatorBounds::ClampX(pos.x - kMwmPointAccuracy), + MercatorBounds::ClampY(pos.y - kMwmPointAccuracy), + MercatorBounds::ClampX(pos.x + kMwmPointAccuracy), + MercatorBounds::ClampY(pos.y + kMwmPointAccuracy)}; } std::string const & GetDefaultName() const { return m_defaultName; } @@ -239,13 +241,15 @@ public: m2::RectD GetLimitRect() const { return m_limitRect; } + bool IsEmpty() const { return m_bestType.empty(); } + DECLARE_VISITOR(visitor(m_bestType, "type"), visitor(m_pos, "pos"), visitor(m_readableName, "readable_name"), visitor(m_defaultName, "default_name"), visitor(m_events, "events")); private: // We are use 1e-5 eps because of points in mwm have this accuracy. - static double constexpr kPointAccuracy = 1e-5; + static double constexpr kMwmPointAccuracy = 1e-5; std::string m_bestType; m2::PointD m_pos; diff --git a/metrics/eye_storage.cpp b/metrics/eye_storage.cpp index eb00b003ca..ccea8b4ec8 100644 --- a/metrics/eye_storage.cpp +++ b/metrics/eye_storage.cpp @@ -83,7 +83,7 @@ std::string Storage::GetInfoFilePath() // static std::string Storage::GetPoiEventsFilePath() { - return base::JoinPath(GetEyeDir(), "pevents"); + return base::JoinPath(GetEyeDir(), "events"); } diff --git a/xcode/map/map.xcodeproj/project.pbxproj b/xcode/map/map.xcodeproj/project.pbxproj index 2c9df751a1..d927b0e25d 100644 --- a/xcode/map/map.xcodeproj/project.pbxproj +++ b/xcode/map/map.xcodeproj/project.pbxproj @@ -87,6 +87,8 @@ 3DD1166C21888AAD007A2ED4 /* notification_queue_serdes.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3DD1166521888AAC007A2ED4 /* notification_queue_serdes.hpp */; }; 3DD122BB2135708900EDFB53 /* libmetrics_tests_support.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DD122BA2135708900EDFB53 /* libmetrics_tests_support.a */; }; 3DD122BD2135708900EDFB53 /* libmetrics.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DD122BC2135708900EDFB53 /* libmetrics.a */; }; + 3DF54F80219DD21000D12E37 /* utils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3DF54F7E219DD21000D12E37 /* utils.cpp */; }; + 3DF54F81219DD21000D12E37 /* utils.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 3DF54F7F219DD21000D12E37 /* utils.hpp */; }; 451E692921494C2700764A97 /* purchase.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 451E692721494C2600764A97 /* purchase.hpp */; }; 451E692A21494C2700764A97 /* purchase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 451E692821494C2700764A97 /* purchase.cpp */; }; 45201E931CE4AC90008A4842 /* api_mark_point.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 45201E921CE4AC90008A4842 /* api_mark_point.cpp */; }; @@ -320,6 +322,8 @@ 3DD1166521888AAC007A2ED4 /* notification_queue_serdes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = notification_queue_serdes.hpp; sourceTree = "<group>"; }; 3DD122BA2135708900EDFB53 /* libmetrics_tests_support.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libmetrics_tests_support.a; sourceTree = BUILT_PRODUCTS_DIR; }; 3DD122BC2135708900EDFB53 /* libmetrics.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libmetrics.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 3DF54F7E219DD21000D12E37 /* utils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utils.cpp; sourceTree = "<group>"; }; + 3DF54F7F219DD21000D12E37 /* utils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = utils.hpp; sourceTree = "<group>"; }; 451E692721494C2600764A97 /* purchase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = purchase.hpp; sourceTree = "<group>"; }; 451E692821494C2700764A97 /* purchase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = purchase.cpp; sourceTree = "<group>"; }; 45201E921CE4AC90008A4842 /* api_mark_point.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = api_mark_point.cpp; sourceTree = "<group>"; }; @@ -759,6 +763,8 @@ 675345BD1A4054AD00A0A8C3 /* map */ = { isa = PBXGroup; children = ( + 3DF54F7E219DD21000D12E37 /* utils.cpp */, + 3DF54F7F219DD21000D12E37 /* utils.hpp */, 3DD1165E21888AAC007A2ED4 /* notifications */, 675345CB1A4054E800A0A8C3 /* address_finder.cpp */, 45201E921CE4AC90008A4842 /* api_mark_point.cpp */, @@ -955,6 +961,7 @@ 45580ABF1E2CBD5E00CD535D /* benchmark_tools.hpp in Headers */, 456E1B3B1F9A3C2A009C32E1 /* search_mark.hpp in Headers */, BBD9E2C71EE9D01900DF189A /* routing_mark.hpp in Headers */, + 3DF54F81219DD21000D12E37 /* utils.hpp in Headers */, 342D833B1D5233E8000D8AEA /* displacement_mode_manager.hpp in Headers */, F6B283041C1B03320081957A /* gps_track_collection.hpp in Headers */, ); @@ -1157,6 +1164,7 @@ BBA014B220754997007402E4 /* user_mark_id_storage.cpp in Sources */, 6753464A1A4054E800A0A8C3 /* bookmark.cpp in Sources */, 45580ABE1E2CBD5E00CD535D /* benchmark_tools.cpp in Sources */, + 3DF54F80219DD21000D12E37 /* utils.cpp in Sources */, 3DA5723220C195ED007BDE27 /* everywhere_search_callback.cpp in Sources */, BBD9E2C61EE9D01900DF189A /* routing_mark.cpp in Sources */, ); |