Open anowacki opened 4 years ago
Good questions.
julia> lon = 1/60 # one arc minute
0.016666666666666666
julia> (lon + 360) - 360 == lon
false
This is really interesting. Where should the validation occur? We can definitely verify that the latitude is sensible for UTM conversions and catch that case. Should user's be expected to do the same with their code? Or should the inner constructor do it for them?
I could go any way on this... I'd probably be tempted to trust the user to do the right thing and just treat LLA
as a simple struct (without invariants enforced) and let operations worry about that, but that is not a strong opinion.
Yes I could go either way as well. Having the LLA
as "simple data" has certian advantages, for example it allows you to reinterpret a buffer of a separate type as LLA
s which could be handy for interop. It also makes things more flexible when dealing with data from outside Geodesy
which may want different or broken invariants. A good analogy here is String
which allows invalid UTF-8 data for the same reasons:
julia> s = "\xff"
"\xff"
julia> s[1]
'\xff': Malformed UTF-8 (category Ma: Malformed, bad data)
Currently, no check is done on the range of values when either constructing or converting
LLA
s orLatLon
s:(It appears the
ECEF
conversion works as if the latitude wraps around over the pole, whilst clearly the UTM conversion needs valid latitudes.)It is also the case that longitudes are compared as if they are linear numbers, when in reality they are periodic, and thus two points can represent the same position when n × 360° apart but not be 'equal':
This raises a few questions:
LLA
s andLatLon
s; or c. remain unnormalised and points only be equal when longitudes are strictly the same?Letting the user make their own mistakes is an acceptable approach, but I think it should be noted carefully somewhere if this is the case. Alternatively, the safety net of bailing out when
abs(latitude) > 90
is often worth the effort, not least since it quite often might catch cases of latitude and longitude being mixed up!Happy to submit a PR for whichever route is best.
(My own preference would be for enforcement of
-90 ≤ lat ≤ 90
in construction forLLA
s andLatLon
s, and modulo-360 comparison of longitudes. This allows one to keep longitudes around some arbitrary meridian.)