I want to draw out a Great Circle radial from a point on the Earth's Surface using the initial point and a Bearing Distance. The line will be greater than 500 KM.
Currently I am using the following:
func drawRadialFromPoint(_ point: Point, heading: Double, distance: Double) {
let overlay = GraphicsOverlay()
let endPoint = calculateEndPoint(from: point, heading: heading, distance: distance)
let polyline = Polyline(
points: [
point,
endPoint
]
)
let polylineSymbol = SimpleLineSymbol(style: .solid, color: .blue, width: 3.0)
let polylineGraphic = Graphic(geometry: polyline, symbol: polylineSymbol)
overlay.addGraphic(polylineGraphic)
}
func calculateEndPoint(from startPoint: Point, heading: Double, distance: Double) -> Point {
let angleInRadians = heading * .pi / 180
let x = startPoint.x + distance * sin(angleInRadians)
let y = startPoint.y + distance * cos(angleInRadians)
return Point(x: x, y: y, spatialReference: startPoint.spatialReference)
}
It seems to work but there are two problems. I don't believe this method is accurate for long distances on the Earth and I was hoping the API would offer a more accurate method to achieve this.
Secondly, when the user pans the earth and the start point is no longer visible, the line disappears which is a problem.
Is there a better way to achieve this?