[ios] predownload and set tajikistan map

This commit is contained in:
mamadnazar 2025-03-13 13:28:39 +05:00
parent 7aa4f4dc03
commit a7d7d80a8a
2 changed files with 30 additions and 5 deletions

View file

@ -109,11 +109,7 @@ using namespace osm_auth_ios;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"application:didFinishLaunchingWithOptions: %@", launchOptions);
[FileManagerHelper copyProjectFileToDocumentsWithFileName:@"Tajikistan"
fileExtension:@"mwm"
toSubdirectory:@"240429"];
GetFramework().LoadMapsSync();
[self setTajikistanMap];
[HttpThreadImpl setDownloadIndicatorProtocol:self];
@ -267,6 +263,20 @@ using namespace osm_auth_ios;
if (!isInBounds) [MapViewController setViewportToDushanbe];
}
- (void) setTajikistanMap {
BOOL fileExists = [FileManagerHelper fileExistsInDocumentsWithSubdirectory:@"240429"
fileName:@"Tajikistan"
fileExtension:@"mwm"];
if (!fileExists) {
[FileManagerHelper copyProjectFileToDocumentsWithFileName:@"Tajikistan"
fileExtension:@"mwm"
toSubdirectory:@"240429"];
GetFramework().LoadMapsSync();
}
}
BOOL isLocationInBounds1(ms::LatLon location, ms::LatLon topLeft, ms::LatLon bottomRight) {
return (location.m_lat <= topLeft.m_lat &&
location.m_lat >= bottomRight.m_lat &&

View file

@ -38,5 +38,20 @@ import Foundation
}
}
}
@objc static func fileExistsInDocuments(subdirectory: String, fileName: String, fileExtension: String) -> Bool {
let fileManager = FileManager.default
guard let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first else {
print("Could not access Documents directory.")
return false
}
let subdirectoryURL = documentsDirectory.appendingPathComponent(subdirectory)
let fileURL = subdirectoryURL.appendingPathComponent("\(fileName).\(fileExtension)")
return fileManager.fileExists(atPath: fileURL.path)
}
}