From f83fe2c7ba453f387b59b2c50f8066af40c33bc5 Mon Sep 17 00:00:00 2001 From: Igor Khmurets Date: Thu, 26 Jun 2014 11:55:35 +0300 Subject: [PATCH] [ios] PP altitude and speed fixes --- iphone/Maps/Bookmarks/BookmarksVC.mm | 2 +- iphone/Maps/Classes/Common.h | 3 ++- iphone/Maps/Classes/MapViewController.mm | 1 + iphone/Maps/Classes/PlacePageInfoCell.mm | 4 ++-- iphone/Maps/Classes/PlacePageView.mm | 17 +++++++++++++---- iphone/Maps/Platform/LocationManager.h | 4 ++-- iphone/Maps/Platform/LocationManager.mm | 4 ++-- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/iphone/Maps/Bookmarks/BookmarksVC.mm b/iphone/Maps/Bookmarks/BookmarksVC.mm index cb93ade5b8..478de9d52d 100644 --- a/iphone/Maps/Bookmarks/BookmarksVC.mm +++ b/iphone/Maps/Bookmarks/BookmarksVC.mm @@ -354,7 +354,7 @@ m2::PointD const center = bm->GetOrg(); double const metres = ms::DistanceOnEarth(info.m_latitude, info.m_longitude, MercatorBounds::YToLat(center.y), MercatorBounds::XToLon(center.x)); - cell.bmDistance.text = [LocationManager formatDistance:metres]; + cell.bmDistance.text = [LocationManager formattedDistance:metres]; } } } diff --git a/iphone/Maps/Classes/Common.h b/iphone/Maps/Classes/Common.h index 742ee4d89c..3975782973 100644 --- a/iphone/Maps/Classes/Common.h +++ b/iphone/Maps/Classes/Common.h @@ -6,4 +6,5 @@ #define BOOKMARK_CATEGORY_DELETED_NOTIFICATION @"BookmarkCategoryDeletedNotification" #define METRICS_CHANGED_NOTIFICATION @"MetricsChangedNotification" -#define BOOKMARK_DELETED_NOTIFICATION @"BookmarkDeletedNotification" \ No newline at end of file +#define BOOKMARK_DELETED_NOTIFICATION @"BookmarkDeletedNotification" +#define LOCATION_MANAGER_STARTED_NOTIFICATION @"LocationManagerStartedNotification" \ No newline at end of file diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index a01255ccb1..239f220562 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -175,6 +175,7 @@ const long long LITE_IDL = 431183278L; [[MapsAppDelegate theApp] disableStandby]; [[MapsAppDelegate theApp].m_locationManager start:self]; + [[NSNotificationCenter defaultCenter] postNotificationName:LOCATION_MANAGER_STARTED_NOTIFICATION object:nil]; return; } diff --git a/iphone/Maps/Classes/PlacePageInfoCell.mm b/iphone/Maps/Classes/PlacePageInfoCell.mm index de2e45d66e..980bff0189 100644 --- a/iphone/Maps/Classes/PlacePageInfoCell.mm +++ b/iphone/Maps/Classes/PlacePageInfoCell.mm @@ -80,8 +80,8 @@ { point = self.pinPoint; } - string const coords = useDMS ? MeasurementUtils::FormatMercatorAsDMS(point) - : MeasurementUtils::FormatMercator(point); + string const coords = useDMS ? MeasurementUtils::FormatMercatorAsDMS(point, 2) + : MeasurementUtils::FormatMercator(point, 6); self.coordinatesLabel.text = [NSString stringWithUTF8String:coords.c_str()]; } diff --git a/iphone/Maps/Classes/PlacePageView.mm b/iphone/Maps/Classes/PlacePageView.mm index 3cecbdd6b1..f01c38ee0a 100644 --- a/iphone/Maps/Classes/PlacePageView.mm +++ b/iphone/Maps/Classes/PlacePageView.mm @@ -94,9 +94,16 @@ typedef NS_ENUM(NSUInteger, CellRow) updatingTable = NO; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startMonitoringLocation:) name:LOCATION_MANAGER_STARTED_NOTIFICATION object:nil]; + return self; } +- (void)startMonitoringLocation:(NSNotification *)notification +{ + [[MapsAppDelegate theApp].m_locationManager start:self]; +} + - (void)onLocationError:(location::TLocationError)errorCode { NSLog(@"Location error %i in %@", errorCode, [[self class] className]); @@ -119,9 +126,11 @@ typedef NS_ENUM(NSUInteger, CellRow) [cell updateDistance]; if ([self isMarkOfType:UserMark::MY_POSITION]) - self.typeLabel.text = [[MapsAppDelegate theApp].m_locationManager formatSpeedAndAltitude]; - if ([self isMarkOfType:UserMark::MY_POSITION]) - [cell updateCoordinates]; + { + self.typeLabel.text = [[MapsAppDelegate theApp].m_locationManager formattedSpeedAndAltitude]; + if (self.state == PlacePageStateOpened) + [cell updateCoordinates]; + } } - (void)onCompassUpdate:(location::CompassInfo const &)info @@ -229,7 +238,7 @@ typedef NS_ENUM(NSUInteger, CellRow) self.titleLabel.origin = CGPointMake(23, 29); if ([self isMarkOfType:UserMark::MY_POSITION]) - self.typeLabel.text = [[MapsAppDelegate theApp].m_locationManager formatSpeedAndAltitude]; + self.typeLabel.text = [[MapsAppDelegate theApp].m_locationManager formattedSpeedAndAltitude]; else self.typeLabel.text = self.types; self.typeLabel.width = [self typesWidth]; diff --git a/iphone/Maps/Platform/LocationManager.h b/iphone/Maps/Platform/LocationManager.h index 5744596dcc..056fc3f198 100644 --- a/iphone/Maps/Platform/LocationManager.h +++ b/iphone/Maps/Platform/LocationManager.h @@ -34,9 +34,9 @@ - (bool)getLat:(double &)lat Lon:(double &)lon; - (bool)getNorthRad:(double &)rad; -+ (NSString *)formatDistance:(double)meters; ++ (NSString *)formattedDistance:(double)meters; // Returns nil if neither speed nor altitude are available -- (NSString *)formatSpeedAndAltitude; +- (NSString *)formattedSpeedAndAltitude; - (bool)lastLocationIsValid; - (BOOL)enabledOnMap; diff --git a/iphone/Maps/Platform/LocationManager.mm b/iphone/Maps/Platform/LocationManager.mm index 32bc2b4269..0a6bd915eb 100644 --- a/iphone/Maps/Platform/LocationManager.mm +++ b/iphone/Maps/Platform/LocationManager.mm @@ -211,7 +211,7 @@ return false; } -+ (NSString *)formatDistance:(double)meters ++ (NSString *)formattedDistance:(double)meters { if (meters < 0.) return nil; @@ -250,7 +250,7 @@ else return rocket; } -- (NSString *)formatSpeedAndAltitude +- (NSString *)formattedSpeedAndAltitude { CLLocation * l = [self lastLocation]; if (l)