From 45e86d8ccb51defaf1f20d1fa42226589ad06746 Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Mon, 30 Jan 2017 15:25:36 +0300 Subject: [PATCH] [router] Review fixes. --- .../Views/RoutePreview/MWMTaxiPreviewDataSource.mm | 4 ++-- iphone/Maps/Classes/MapsAppDelegate.mm | 4 ++-- iphone/Maps/Core/Routing/MWMRoutePoint.h | 8 ++++---- iphone/Maps/Core/Routing/MWMRouter.mm | 12 ++++++------ iphone/Maps/Core/Routing/MWMRouterSavedState.mm | 2 +- iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm | 2 +- iphone/Maps/UI/Search/MWMSearchManager.mm | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.mm b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.mm index c259a97457..1c9b0b351f 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.mm +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/MWMTaxiPreviewDataSource.mm @@ -104,8 +104,8 @@ using namespace uber; { NSAssert(completion && failure, @"Completion and failure blocks must be not nil!"); m_products.clear(); - m_from = latlonMWMRoutePoint(from); - m_to = latlonMWMRoutePoint(to); + m_from = routePointLatLon(from); + m_to = routePointLatLon(to); auto cv = self.collectionView; cv.hidden = YES; cv.pageControl.hidden = YES; diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 7fcd24b318..31b2c25c66 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -225,8 +225,8 @@ using namespace osm_auth_ios; auto const points = parsedData.m_points; auto const & p1 = points[0]; auto const & p2 = points[1]; - [[MWMRouter router] buildFromPoint:makeMWMRoutePoint(p1.m_org, @(p1.m_name.c_str())) - toPoint:makeMWMRoutePoint(p2.m_org, @(p2.m_name.c_str())) + [[MWMRouter router] buildFromPoint:routePoint(p1.m_org, @(p1.m_name.c_str())) + toPoint:routePoint(p2.m_org, @(p2.m_name.c_str())) bestRouter:NO]; [self showMap]; [self.mapViewController showAPIBar]; diff --git a/iphone/Maps/Core/Routing/MWMRoutePoint.h b/iphone/Maps/Core/Routing/MWMRoutePoint.h index 280c4706df..747ac63855 100644 --- a/iphone/Maps/Core/Routing/MWMRoutePoint.h +++ b/iphone/Maps/Core/Routing/MWMRoutePoint.h @@ -4,23 +4,23 @@ #include "geometry/mercator.hpp" #include "geometry/point2d.hpp" -static inline MWMRoutePoint * makeMWMRoutePoint(m2::PointD const & point, NSString * name) +static inline MWMRoutePoint * routePoint(m2::PointD const & point, NSString * name) { return [[MWMRoutePoint alloc] initWithX:point.x y:point.y name:name isMyPosition:false]; } -static inline MWMRoutePoint * makeMWMRoutePoint(m2::PointD const & point) +static inline MWMRoutePoint * routePoint(m2::PointD const & point) { return [[MWMRoutePoint alloc] initWithX:point.x y:point.y]; } -static inline MWMRoutePoint * makeMWMRoutePointZero() { return [[MWMRoutePoint alloc] init]; } +static inline MWMRoutePoint * zeroRoutePoint() { return [[MWMRoutePoint alloc] init]; } static inline m2::PointD mercatorMWMRoutePoint(MWMRoutePoint * point) { return m2::PointD(point.x, point.y); } -static inline ms::LatLon latlonMWMRoutePoint(MWMRoutePoint * point) +static inline ms::LatLon routePointLatLon(MWMRoutePoint * point) { return MercatorBounds::ToLatLon(mercatorMWMRoutePoint(point)); } diff --git a/iphone/Maps/Core/Routing/MWMRouter.mm b/iphone/Maps/Core/Routing/MWMRouter.mm index 7cdc635884..52978afa1a 100644 --- a/iphone/Maps/Core/Routing/MWMRouter.mm +++ b/iphone/Maps/Core/Routing/MWMRouter.mm @@ -34,7 +34,7 @@ char const * kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeI MWMRoutePoint * lastLocationPoint() { CLLocation * lastLocation = [MWMLocationManager lastLocation]; - return lastLocation ? makeMWMRoutePoint(lastLocation.mercator) : makeMWMRoutePointZero(); + return lastLocation ? routePoint(lastLocation.mercator) : zeroRoutePoint(); } bool isMarkerPoint(MWMRoutePoint * point) { return point.isValid && !point.isMyPosition; } @@ -76,8 +76,8 @@ bool isMarkerPoint(MWMRoutePoint * point) { return point.isValid && !point.isMyP auto taxiDataSource = [MWMNavigationDashboardManager manager].taxiDataSource; auto eventName = taxiDataSource.isTaxiInstalled ? kStatRoutingTaxiOrder : kStatRoutingTaxiInstall; - auto const sLatLon = latlonMWMRoutePoint(router.startPoint); - auto const fLatLon = latlonMWMRoutePoint(router.finishPoint); + auto const sLatLon = routePointLatLon(router.startPoint); + auto const fLatLon = routePointLatLon(router.finishPoint); [Statistics logEvent:eventName withParameters:@{ @@ -114,7 +114,7 @@ bool isMarkerPoint(MWMRoutePoint * point) { return point.isValid && !point.isMyP - (void)resetPoints { self.startPoint = lastLocationPoint(); - self.finishPoint = makeMWMRoutePointZero(); + self.finishPoint = zeroRoutePoint(); } - (void)setType:(MWMRouterType)type @@ -459,7 +459,7 @@ bool isMarkerPoint(MWMRoutePoint * point) { return point.isValid && !point.isMyP return; _startPoint = startPoint; if (startPoint == self.finishPoint) - self.finishPoint = makeMWMRoutePointZero(); + self.finishPoint = zeroRoutePoint(); [[MWMNavigationDashboardManager manager].routePreview reloadData]; } @@ -469,7 +469,7 @@ bool isMarkerPoint(MWMRoutePoint * point) { return point.isValid && !point.isMyP return; _finishPoint = finishPoint; if (finishPoint == self.startPoint) - self.startPoint = makeMWMRoutePointZero(); + self.startPoint = zeroRoutePoint(); [[MWMNavigationDashboardManager manager].routePreview reloadData]; } diff --git a/iphone/Maps/Core/Routing/MWMRouterSavedState.mm b/iphone/Maps/Core/Routing/MWMRouterSavedState.mm index 2109ff7ee8..451559dff0 100644 --- a/iphone/Maps/Core/Routing/MWMRouterSavedState.mm +++ b/iphone/Maps/Core/Routing/MWMRouterSavedState.mm @@ -37,7 +37,7 @@ static NSString * const kETAKey = @"eta"; if (endPointData && eta) { [endPointData getBytes:&point length:size]; - _restorePoint = makeMWMRoutePoint(point, @"Destination"); + _restorePoint = routePoint(point, @"Destination"); if ([eta compare:[NSDate date]] == NSOrderedDescending) _forceStateChange = MWMRouterForceStateChange::Rebuild; } diff --git a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm index 9b8e20bf17..ae89858c0d 100644 --- a/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm +++ b/iphone/Maps/UI/PlacePage/MWMPlacePageManager.mm @@ -203,7 +203,7 @@ name = L(@"placepage_unknown_place"); m2::PointD const & org = self.data.mercator; - return self.data.isMyPosition ? makeMWMRoutePoint(org) : makeMWMRoutePoint(org, name); + return self.data.isMyPosition ? routePoint(org) : routePoint(org, name); } - (void)share diff --git a/iphone/Maps/UI/Search/MWMSearchManager.mm b/iphone/Maps/UI/Search/MWMSearchManager.mm index d45c158ffd..9886582466 100644 --- a/iphone/Maps/UI/Search/MWMSearchManager.mm +++ b/iphone/Maps/UI/Search/MWMSearchManager.mm @@ -199,7 +199,7 @@ typedef NS_ENUM(NSUInteger, MWMSearchManagerActionBarState) { - (void)tapMyPositionFromHistory { MapsAppDelegate * a = MapsAppDelegate.theApp; - auto p = makeMWMRoutePoint([MWMLocationManager lastLocation].mercator); + auto p = routePoint([MWMLocationManager lastLocation].mercator); if (a.routingPlaneMode == MWMRoutingPlaneModeSearchSource) [[MWMRouter router] buildFromPoint:p bestRouter:YES]; else if (a.routingPlaneMode == MWMRoutingPlaneModeSearchDestination) @@ -218,12 +218,12 @@ typedef NS_ENUM(NSUInteger, MWMSearchManagerActionBarState) { MWMRoutingPlaneMode const m = a.routingPlaneMode; if (m == MWMRoutingPlaneModeSearchSource) { - auto p = makeMWMRoutePoint(result.GetFeatureCenter(), @(result.GetString().c_str())); + auto p = routePoint(result.GetFeatureCenter(), @(result.GetString().c_str())); [[MWMRouter router] buildFromPoint:p bestRouter:YES]; } else if (m == MWMRoutingPlaneModeSearchDestination) { - auto p = makeMWMRoutePoint(result.GetFeatureCenter(), @(result.GetString().c_str())); + auto p = routePoint(result.GetFeatureCenter(), @(result.GetString().c_str())); [[MWMRouter router] buildToPoint:p bestRouter:YES]; } else