[ios] Add random smoothly changed elevation to iOS Simulator for testing track recording

Signed-off-by: Alexander Borsuk <me@alex.bio>
This commit is contained in:
Alexander Borsuk
2025-06-09 00:24:48 +02:00
committed by Yannik Bloscheck
parent 529272cd54
commit f3bc6d9d8b
3 changed files with 92 additions and 0 deletions

View File

@@ -10,6 +10,10 @@
#include "map/gps_tracker.hpp"
#if TARGET_OS_SIMULATOR
#include "MountainElevationGenerator.hpp"
#endif
namespace
{
using Observer = id<MWMLocationObserver>;
@@ -472,6 +476,25 @@ void setShowLocationAlert(BOOL needShow) {
if (location.horizontalAccuracy < 0.)
return;
#if TARGET_OS_SIMULATOR
// There is no simulator < 15.0 in the new XCode.
if (@available(iOS 15.0, *))
{
// iOS Simulator doesn't provide any elevation in its locations. Mock it.
static MountainElevationGenerator generator;
location = [[CLLocation alloc] initWithCoordinate:location.coordinate
altitude:generator.NextElevation()
horizontalAccuracy:location.horizontalAccuracy
verticalAccuracy:location.horizontalAccuracy
course:location.course
courseAccuracy:location.courseAccuracy
speed:location.speed
speedAccuracy:location.speedAccuracy
timestamp:location.timestamp
sourceInfo:location.sourceInformation];
}
#endif
self.lastLocationStatus = MWMLocationStatusNoError;
self.locationSource = location::EAppleNative;
[self processLocationUpdate:location];