球面ユーティリティ
球面ジオメトリのヘルパーは Spherical enum を通じて提供されています。プロバイダー SDK の外でマップ関連のジオメトリが必要な場合に、計測や派生座標の計算にこれらのヘルパーを使用してください。
パブリック関数
Section titled “パブリック関数”computeDistanceBetween(from:to:) -> DoublecomputeHeading(from:to:) -> DoublecomputeOffset(origin:distance:heading:) -> GeoPointcomputeOffsetOrigin(to:distance:heading:) -> GeoPoint?computeLength(_:) -> DoublecomputeArea(_:) -> DoublecomputeSignedArea(_:) -> DoublesphericalInterpolate(from:to:fraction:) -> GeoPointlinearInterpolate(from:to:fraction:) -> GeoPoint
let tokyo = GeoPoint(latitude: 35.6812, longitude: 139.7671)let tower = GeoPoint(latitude: 35.6586, longitude: 139.7454)
let distance = Spherical.computeDistanceBetween(from: tokyo, to: tower)let heading = Spherical.computeHeading(from: tokyo, to: tower)let point = Spherical.computeOffset(origin: tokyo, distance: 1_000, heading: 90)let routeLength = Spherical.computeLength(route)let polygonArea = Spherical.computeArea(polygon)ルートの長さ
Section titled “ルートの長さ”ルートやトラックには computeLength(_:) を使用してください:
let routeLengthMeters = Spherical.computeLength(routePoints)結果はメートル単位で返されます。
ポリゴンの面積
Section titled “ポリゴンの面積”閉じたパスの符号なし面積には computeArea(_:) を、巻き方向が重要な場合は computeSignedArea(_:) を使用してください:
let areaSquareMeters = Spherical.computeArea(polygonPoints)let signedArea = Spherical.computeSignedArea(polygonPoints)球面上の移動には sphericalInterpolate(from:to:fraction:) を、単純な緯度・経度の線形補間には linearInterpolate(from:to:fraction:) を使用してください。
let halfway = Spherical.sphericalInterpolate( from: pointA, to: pointB, fraction: 0.5)