Currently, if I subtract two LatLon coordinates, I get a LatLon with the differences:
julia> LatLon(1.214914, 103.851194) - LatLon(1.214986, 103.851527)
LatLon{Float64}(-7.199999999984996e-5, -0.00033299999999769625)
While this may seem reasonable, it is incorrect. The differences between latitudes is not a latitude, and the differences between longitude is not a longitude. This becomes important when the latitude-longitude differences later need to be converted to east-north distances:
julia> en = EastNorth(LatLon(1.214914, 103.851194) - LatLon(1.214986, 103.851527))
EastNorth{Float64}(-37.069390433874574, -7.961347859138245)
julia> norm(en)
37.91467745970203
which is quite different from:
julia> norm(ECEF(LatLon(1.214914, 103.851194)) - ECEF(LatLon(1.214986, 103.851527)))
37.90659161709082
The essential problem is that the actual latitude-longitude is lost in taking the difference, and then the east-north conversion wrongly treats the differences as being located at the origin of the latitude-longitude coordinate system.
Perhaps we need a different data type to represent differences in latitude-longitude, rather than returning them as a latitude-longitude pair?
Currently, if I subtract two
LatLoncoordinates, I get aLatLonwith the differences:While this may seem reasonable, it is incorrect. The differences between latitudes is not a latitude, and the differences between longitude is not a longitude. This becomes important when the latitude-longitude differences later need to be converted to east-north distances:
which is quite different from:
The essential problem is that the actual latitude-longitude is lost in taking the difference, and then the east-north conversion wrongly treats the differences as being located at the origin of the latitude-longitude coordinate system.
Perhaps we need a different data type to represent differences in latitude-longitude, rather than returning them as a latitude-longitude pair?