Comments (6)
@ettersi , regarding the first conversion, you can convert to LatLonAlt
first and then convert to Cartesian
since these two methods are already implemented. Would you like to submit a PR?
The second conversion should be trivial to add as well in a second PR.
from coordrefsystems.jl.
I've added the Cartesian <> Projected
conversion in #52. Regarding the LatLon <> LatLonAlt
conversion, I've since come to realise that implementing this as a Base.convert()
method might be dangerous.
julia> Base.convert(::Type{LatLon}, coords::LatLonAlt{Datum}) where {Datum} = convert(LatLon{Datum}, coords)
Base.convert(::Type{LatLon{Datum}}, coords::LatLonAlt{Datum}) where {Datum} = LatLon(coords.lat, coords.lon)
julia> a = Ref{LatLon}(LatLon(0,0))
a[] = LatLonAlt(0,0,1e10)
a[]
# Where did my Alt go?!
GeodeticLatLon{WGS84Latest} coordinates
├─ lat: 0.0°
└─ lon: 0.0°
Of course, one could argue that the user asked for this since they explicitly requested a Ref{LatLon}
, but I'm not sure whether this argument strikes the right balance between supporting power users and protecting mere mortals from silly mistakes. Also, just for reference, the Julia docs say this about convert()
:
[
convert()
] is also usually lossless; converting a value to a different type and back again should result in the exact same value.
from coordrefsystems.jl.
Yes, we saw this pattern before, and decided that the feature is good enough to ignore the convert
footnote. The problem with convert
is that it was designed with very strict computer-science use cases in mind. We could have used a different function name to avoid these pedantic footnotes, but then we would loose the nice syntax
Mercator[LatLon(0,0), LatLon(0,90), ...]
and all the nice automatic conversions that Julia does when it encounters two CRS of different type.
from coordrefsystems.jl.
We could have used a different function name to avoid these pedantic footnotes, but then we would loose the nice syntax
Mercator[LatLon(0,0), LatLon(0,90), ...]and all the nice automatic conversions that Julia does when it encounters two CRS of different type.
You can always have a separate conversion mechanism (e.g. constructors) which is free to add or remove information, and then make convert()
dispatch to this mechanism whenever the conversion is lossless.
from coordrefsystems.jl.
I don't remember out of my head now, but I think Julia works in the opposite direction, it uses convert
as a fallback to construct a type to another. In any case, I believe that we are fine with adopting convert
between LatLon
and LatLonAlt
.
Feel free to submit a PR for it. We can review and merge today, together with the other PR, and then release a patch.
from coordrefsystems.jl.
Fixed on master.
from coordrefsystems.jl.
Related Issues (14)
- Fix inverse of TransverseMercator
- Add epoch shift to datum
- Benchmark quotient is flipped HOT 2
- Invoking cartography methods without Unitful directly attached to point types HOT 2
- TagBot trigger issue HOT 20
- Add cstrip() and cwrap functions HOT 11
- Add local coordinates HOT 2
- Implement "wrapping" local coordinates? HOT 9
- Cartesian isapprox should do vector comparison instead of elementwise comparison
- LatLon > Robinson conversion is not numerically stable HOT 5
- Add `Cartesian` constructor with tuple of numbers
- Allow conversion `LatLon{WGS84Latest}` --> `Mercator{ITRF{2008}}`
- Support for local (projected) CRS instances
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coordrefsystems.jl.