mirror of
https://github.com/xweiba/location-spoofer.git
synced 2026-09-21 22:30:46 +08:00
fix: 修复跨境定位后的 MapKit 坐标偏移
This commit is contained in:
@@ -122,6 +122,43 @@ final class FavoriteLocationStoreTests: XCTestCase {
|
||||
XCTAssertNil(CoordinateConverter.diagnoseRepresentation(sample: unrelated, pair: pair).inferredSystem)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testDetectedMapCoordinateSystemChangePreventsHongKongWGS84DoubleConversion() {
|
||||
let original = CoordinateConverter.currentMapCoordinateSystem
|
||||
defer { _ = CoordinateConverter.applyDetectedMapCoordinateSystem(original) }
|
||||
_ = CoordinateConverter.applyDetectedMapCoordinateSystem(.gcj02)
|
||||
|
||||
let hongKongObservatory = CLLocationCoordinate2D(
|
||||
latitude: 22.302_344,
|
||||
longitude: 114.174_566
|
||||
)
|
||||
let stalePair = CoordinatePair(
|
||||
mapCoordinate: hongKongObservatory,
|
||||
mapCoordinateSystem: CoordinateConverter.currentMapCoordinateSystem
|
||||
)
|
||||
|
||||
let change = CoordinateConverter.applyDetectedMapCoordinateSystem(.wgs84)
|
||||
let pair = CoordinatePair(
|
||||
mapCoordinate: hongKongObservatory,
|
||||
mapCoordinateSystem: CoordinateConverter.currentMapCoordinateSystem
|
||||
)
|
||||
|
||||
XCTAssertEqual(change?.previous, .gcj02)
|
||||
XCTAssertEqual(change?.current, .wgs84)
|
||||
XCTAssertNotEqual(stalePair.wgs84.longitude, hongKongObservatory.longitude)
|
||||
XCTAssertEqual(pair.wgs84.latitude, hongKongObservatory.latitude, accuracy: 0.000_000_1)
|
||||
XCTAssertEqual(pair.wgs84.longitude, hongKongObservatory.longitude, accuracy: 0.000_000_1)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testApplyingSameDetectedMapCoordinateSystemDoesNotReportAChange() {
|
||||
let original = CoordinateConverter.currentMapCoordinateSystem
|
||||
defer { _ = CoordinateConverter.applyDetectedMapCoordinateSystem(original) }
|
||||
_ = CoordinateConverter.applyDetectedMapCoordinateSystem(.gcj02)
|
||||
|
||||
XCTAssertNil(CoordinateConverter.applyDetectedMapCoordinateSystem(.gcj02))
|
||||
}
|
||||
|
||||
func testMapConfigurationNeverRequestsRealUserLocation() {
|
||||
XCTAssertFalse(MapConfiguration.default.showsUserLocation)
|
||||
XCTAssertFalse(MapConfiguration.default.allowsCurrentLocationRequest)
|
||||
|
||||
@@ -65,6 +65,12 @@ if grep -q 'logEvent("CONNECT " + host + " -> passthrough")' "$ROOT/Core/proxy.g
|
||||
fi
|
||||
grep -q 'enum SystemSettingsNavigator' "$SETTINGS_NAVIGATOR" || fail "shared settings navigator is missing"
|
||||
grep -q 'await CoordinateConverter.resolveInitialMapCoordinateSystem()' "$CONTENT" || fail "map type must resolve before MapHomeView construction"
|
||||
grep -q 'static func refreshMapCoordinateSystem() async' "$CONVERTER" || fail "runtime MapKit coordinate-system changes must reuse the fixed-anchor probe"
|
||||
grep -q 'fixedAnchorCoordinateSystemProbe()' "$CONVERTER" || fail "runtime coordinate-system refresh must use the location-independent fixed anchor"
|
||||
test "$(grep -c 'initialMapCoordinateSystemUsedFallback = false' "$CONVERTER")" -ge 2 || fail "a successful runtime anchor probe must disable location-region fallback correction"
|
||||
grep -q 'refreshMapCoordinateSystemAfterLocationEnvironmentChange' "$MAP_HOME" || fail "MapHomeView must refresh the coordinate system after spoofing changes the location environment"
|
||||
grep -q 'nearestTargetDistance' "$MAP_HOME" || fail "spoof refresh must wait until the MapKit blue point reaches the active target"
|
||||
grep -q 'reprojectMapSelection(for: change)' "$MAP_HOME" || fail "coordinate-system refresh must replay the persisted coordinate pair"
|
||||
grep -q 'phase = .map' "$CONTENT" || fail "ContentView must explicitly gate MapHomeView construction"
|
||||
! grep -q 'startTileProbe' "$MAP_HOME" || fail "MapHomeView must not start a second fixed-anchor coordinate-system probe"
|
||||
! grep -q 'initializeMap()' "$MAP_HOME" || fail "MapHomeView must not replay a second map initialization from onAppear"
|
||||
|
||||
Reference in New Issue
Block a user