Meshtastic-Apple/Meshtastic/Helpers/Map/TileOverlay.swift
Austin Payne 3c0e56aeaf improvement: avoid duplicate map tile loading
Previously a map tile cache miss would cause 2x loading of the tile: once from
the remote tile server (which is then written to disk) and once from disk
during the default MKTileOverlay.loadTile function. Instead we now directly
implement loadTile so that we can avoid the duplicate loading and simply
return the fetched remote tile after it is cached, which leads to a
noticeable improvement in offline map performance.
2024-02-15 21:12:00 -07:00

17 lines
368 B
Swift

//
// TileOverlay.swift
// Meshtastic
//
// Copyright(c) Garth Vander Houwen 5/5/23.
//
import Foundation
import MapKit
typealias TileCoordinates = (x: Int, y: Int, z: Int)
class TileOverlay: MKTileOverlay {
override func loadTile(at path: MKTileOverlayPath) async throws -> Data {
return try OfflineTileManager.shared.loadAndCacheTileOverlay(for: path)
}
}