mirror of
https://github.com/xweiba/location-spoofer.git
synced 2026-09-21 22:30:46 +08:00
fix: 瓦片类型仅由搜索结果坐标+蓝点推算,去掉其他判断逻辑
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import Foundation
|
||||
import CoreLocation
|
||||
|
||||
/// GCJ-02 (火星坐标) ↔ WGS-84 坐标转换。
|
||||
///
|
||||
@@ -95,6 +96,17 @@ enum CoordinateConverter {
|
||||
return .wgs84
|
||||
}
|
||||
|
||||
/// 通过搜索结果坐标 + 蓝点推算瓦片类型(搜索结果在当期瓦片坐标系,蓝点是 WGS-84)
|
||||
static func detectTile(resultCoord: (lat: Double, lon: Double), userLocation: CLLocation?) -> CoordType? {
|
||||
guard let bl = userLocation,
|
||||
CLLocationCoordinate2DIsValid(bl.coordinate),
|
||||
bl.horizontalAccuracy >= 0 else { return nil }
|
||||
let wgs = gcj02ToWgs84(lat: resultCoord.lat, lon: resultCoord.lon)
|
||||
let dGCJ = distance(lat1: wgs.lat, lon1: wgs.lon, lat2: bl.coordinate.latitude, lon2: bl.coordinate.longitude)
|
||||
let dRaw = distance(lat1: resultCoord.lat, lon1: resultCoord.lon, lat2: bl.coordinate.latitude, lon2: bl.coordinate.longitude)
|
||||
return dGCJ < dRaw ? .gcj02 : .wgs84
|
||||
}
|
||||
|
||||
// MARK: - 核心转换
|
||||
|
||||
/// GCJ-02 → WGS-84(迭代法,精度优于 0.5 米)
|
||||
|
||||
Reference in New Issue
Block a user