Skip to content
Snippets Groups Projects
Verified Commit a8b449e8 authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Add LonLatExtended

parent 2dd781a7
No related branches found
No related tags found
No related merge requests found
......@@ -121,6 +121,7 @@ MCEventMatcher,
SummarysliceIntervalIterator,
getevent,
LonLat, # TODO: move this to types?
LonLatExtended, # TODO: move this to types?
lonlat,
isnorthern,
......
......@@ -4,6 +4,15 @@ A position in longitude and latitude.
struct LonLat
lon::Float64
lat::Float64
end
"""
A position in longitude and latitude including the point scale factor and the meridian
convergence angle.
"""
struct LonLatExtended
lon::Float64
lat::Float64
point_scale_factor::Float64
meridian_convergence::Float64
end
......@@ -18,7 +27,7 @@ which were originally derived by Johann Heinrich Louis Krüger in 1912.
millimeter within 3000 km of the central meridian.
"""
function lonlat end
function lonlat(utm::UTMPosition)::LonLat
function lonlat(utm::UTMPosition)::LonLatExtended
N = utm.northing / 1000
E = utm.easting / 1000
hemi = isnorthern(utm) ? +1 : -1
......@@ -65,7 +74,7 @@ function lonlat(utm::UTMPosition)::LonLat
k = k₀*A/a * ( (1 + ((1 - n)/(1 + n))*tan(ϕ))^2 * (cos(ξ′)^2 + sinh(η′)^2)/(σ′^2 + τ′^2) )
# meridian convergence
γ = hemi * atan( (τ′ + σ′*tan(ξ′)*tanh(η′)) / (σ′ + τ′*tan(ξ′)*tanh(η′)) )
return LonLat(λ, ϕ, k, γ)
return LonLatExtended(λ, ϕ, k, γ)
end
lonlat(d::Detector; kwargs...) = lonlat(d.pos; kwargs...)
......@@ -114,5 +123,5 @@ function lonlat_aanet(utm::UTMPosition)::LonLat
longitude = ((δ * (180.0 / π)) + s) + diflon
latitude = ((lat + (1 + e2cuadrada * cos(lat)^2 - (3.0 / 2.0) * e2cuadrada * sin(lat) * cos(lat) * (tao - lat)) * (tao - lat)) * (180.0 / π)) + diflat
return LonLat(longitude * π / 180, latitude * π / 180, 0, 0)
return LonLat(longitude * π / 180, latitude * π / 180)
end
......@@ -341,8 +341,8 @@ end
end
@testset "coords" begin
@test LonLat(0.2788259891652955, 0.6334183919376817, 1.3971407689009945, 0.010078736515781934) == lonlat(Detector(datapath("detx", "KM3NeT_00000133_20221025.detx")))
@test LonLat(0.2788259891652955, 0.6334183919376817, 1.3971407689009945, 0.010078736515781934) == lonlat(Detector(datapath("datx", "KM3NeT_00000133_20221025.datx")))
@test LonLatExtended(0.2788259891652955, 0.6334183919376817, 1.3971407689009945, 0.010078736515781934) == lonlat(Detector(datapath("detx", "KM3NeT_00000133_20221025.detx")))
@test LonLatExtended(0.2788259891652955, 0.6334183919376817, 1.3971407689009945, 0.010078736515781934) == lonlat(Detector(datapath("datx", "KM3NeT_00000133_20221025.datx")))
@test isnorthern(UTMPosition(1, 2, 3, 'N', 0.0))
@test !isnorthern(UTMPosition(1, 2, 3, 'D', 0.0))
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment