You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[CommonDataModel.jl](https://github.com/JuliaGeo/CommonDataModel.jl) contains abstracts type definition for loading and manipulating GRIB, NetCDF, geoTiff and Zarr files.
40
40
-[NetCDF Data Model](https://docs.unidata.ucar.edu/netcdf-c/current/netcdf_data_model.html)
SpaceDataModel.jl provides a set of abstractions and generic functions that can be extended by users to create custom implementations. This page documents these interfaces and provides examples of how to use them.
4
+
5
+
## References
6
+
7
+
-[DataAPI.jl](https://github.com/JuliaData/DataAPI.jl): A data-focused namespace for packages to share functions
8
+
9
+
## Coordinate Systems
10
+
11
+
The package exports three key components for coordinate system handling:
12
+
13
+
-[`AbstractCoordinateSystem`](@ref): Base abstract type for all coordinate system implementations
14
+
-[`AbstractCoordinateVector`](@ref): Base abstract type to represent coordinates in a coordinate systems
15
+
-[`getcsys`](@ref): Function to retrieve the coordinate system from an object
16
+
17
+
18
+
There are two main approaches to implementing coordinate vectors and their associated systems:
19
+
20
+
### Approach 1: Explicit Coordinate System Field
21
+
22
+
Store the coordinate system directly as a field in the vector type:
23
+
24
+
```julia
25
+
# Define a coordinate system
26
+
struct GEO <:AbstractCoordinateSystemend
27
+
28
+
# Define a vector with an explicit coordinate system field
# Implementation of getcsys simply returns the stored field
35
+
getcsys(x::CoordinateVector) = x.csys
36
+
```
37
+
38
+
### Approach 2: Implicit Coordinate System
39
+
40
+
Associate a specific coordinate system with a vector type:
41
+
42
+
```julia
43
+
# Define a coordinate system
44
+
struct GEO <:AbstractCoordinateSystemend
45
+
46
+
# Define a vector type specific to a coordinate system
47
+
struct GEOVector{D} <:AbstractCoordinateVector
48
+
data::D
49
+
end
50
+
51
+
# Implementation of getcsys returns the appropriate system
52
+
getcsys(x::GEOVector) =GEO()
53
+
```
54
+
55
+
Both approaches are highly efficient and provide equivalent performance due to Julia's type inference system.
56
+
57
+
### Elsewhere
58
+
59
+
-[CoordRefSystems.jl](https://github.com/JuliaEarth/CoordRefSystems.jl) provides conversions between Coordinate Reference Systems (CRS) for cartography use cases.
60
+
-[Geodesy.jl](https://github.com/JuliaGeo/Geodesy.jl) for working with points in various world and local coordinate systems.
61
+
-[WCS.jl](https://juliaastro.org/WCS/stable/) : Astronomical World Coordinate System library
Base abstract type for all coordinate system implementations.
9
+
"""
7
10
abstract type AbstractCoordinateSystem end
8
11
9
-
struct CoordinateVector{T,C} <:FieldVector{3,T}
10
-
x::T
11
-
y::T
12
-
z::T
13
-
sym::C
14
-
end
12
+
"""
13
+
AbstractCoordinateVector
15
14
16
-
for sys in (:GDZ, :GEO, :GSM, :GSE, :SM, :GEI, :MAG, :SPH, :RLL, :HEE, :HAE, :HEEQ, :J2000)
17
-
@evalstruct$sys <:AbstractCoordinateSystemend
18
-
@eval$sys(x, y, z) =CoordinateVector(x, y, z, $sys())
19
-
@eval$sys(x) =CoordinateVector(x..., $sys())
20
-
@evalexport$sys
21
-
end
15
+
Base abstract type to represent coordinates in a coordinate systems.
16
+
"""
17
+
abstract type AbstractCoordinateVector end
22
18
23
-
@doc"""Geocentric Solar Magnetospheric (GSM)\n\nX points sunward from Earth's center. The X-Z plane is defined to contain Earth's dipole axis (positive North).
24
-
"""GSM
19
+
"""
20
+
getcsys(x)
25
21
26
-
coord(v::CoordinateVector) = v.sym
27
-
Base.String(::Type{S}) where {S<:AbstractCoordinateSystem} =String(nameof(S))
28
-
Base.String(::S) where {S<:AbstractCoordinateSystem} =T(S)
0 commit comments