Skip to content

Commit

Permalink
Update latlon including test. Added tests to Allftplus.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjdverbeek committed Apr 16, 2020
1 parent 4a6bdc9 commit 805ee38
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 115 deletions.
14 changes: 0 additions & 14 deletions src/Allftplus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ struct AllFtPointProfile
pointDistance::Union{Int64, Missing}
pointType::AbstractString
geoPointId::Union{Point_deg, AbstractString}
# geoPointId::Union{Point, AbstractString}
ratio::Union{Int64, Missing}
isVisible::Bool # Y indicated IFR/GAT/IFPSTART, N indicates VFR/OAT/IFPSTOP/STAY
function AllFtPointProfile(x::AbstractString)
Expand All @@ -181,19 +180,6 @@ struct AllFtPointProfile
end
end

# function latlon(str::AbstractString)
# lat_h = parse(Float64, str[1:2])
# lat_m = parse(Float64, str[3:4])
# lat_s = parse(Float64, str[5:6])
# sign_lat = str[7] == 'N' ? 1 : -1
# lon_h = parse(Float64, str[8:10])
# lon_m = parse(Float64, str[11:12])
# lon_s = parse(Float64, str[13:14])
# sign_lon = str[15] == 'E' ? 1 : -1
# return Point(sign_lat*(lat_h + lat_m/60.0 + lat_s/3600.0),
# sign_lon*(lon_h + lon_m/60.0 + lon_s/3600.0))
# end

function AllFtPointProfileList(items::Union{AbstractString, Missing})
if items === missing
return missing
Expand Down
13 changes: 0 additions & 13 deletions src/Are.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,6 @@ function box_spherical_polygon(points::Array{Float64,2})
return box
end

# function latitude_options(pos₁::Point, pos₂::Point)
# pos₁_deg = Navigation.Point_deg(pos₁.lat, pos₁.lon)
# pos₂_deg = Navigation.Point_deg(pos₁.lat, pos₁.lon)
# bearing = Navigation.bearing(pos₁_deg, pos₂_deg)
# closest_point_deg = Navigation.closest_point_to_pole(pos₁_deg, bearing)
# if Navigation.distance(pos₁_deg, pos₂_deg) > Navigation.distance(pos₁_deg,
# closest_point_deg)
# return pos₁.lat, pos₂.lat, closest_point_deg.ϕ
# else
# return pos₁.lat, pos₂.lat
# end
# end

function latitude_options(pos₁::Point_deg, pos₂::Point_deg)
bearing = Navigation.bearing(pos₁, pos₂)
closest_point_deg = Navigation.closest_point_to_pole(pos₁, bearing)
Expand Down
2 changes: 1 addition & 1 deletion src/Exp2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module Exp2

export read

# include("utility.jl")
#TODO Keep unused fields?
using ..util # new
using Format
using CSV
Expand Down
75 changes: 0 additions & 75 deletions src/Frp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ ALBANIA I VOLBI N413855 E0194122
"""
module Frp

#TODO Last Area is not read correctly. Needs correction.

export read

# include("utility.jl")
using ..util

struct FreeRoutePoint
Expand All @@ -77,78 +74,6 @@ struct FreeRouteArea
freerouteairports::Vector{FreeRouteAirports}
end

# function extract_lat(str::AbstractString)
# if length(str) == 7
# if str[1] in ['N','S']
# sign_lat = str[1] == 'N' ? 1 : -1
# lat_h = parse(Float64, str[2:3])
# lat_m = parse(Float64, str[4:5])
# lat_s = parse(Float64, str[6:7])
# else
# sign_lat = str[7] == 'N' ? 1 : -1
# lat_h = parse(Float64, str[1:2])
# lat_m = parse(Float64, str[3:4])
# lat_s = parse(Float64, str[5:6])
# end
# elseif length(str) == 5
# if str[1] in ['N','S']
# sign_lat = str[1] == 'N' ? 1 : -1
# lat_h = parse(Float64, str[2:3])
# lat_m = parse(Float64, str[4:5])
# lat_s = 0.0
# else
# sign_lat = str[5] == 'N' ? 1 : -1
# lat_h = parse(Float64, str[1:2])
# lat_m = parse(Float64, str[3:4])
# lat_s = 0.0
# end
# else
# return missing
# end
# return sign_lat*(lat_h + lat_m/60.0 + lat_s/3600.0)
# end
#
# function extract_lon(str::AbstractString)
# if length(str) == 8
# if str[1] in ['E','W']
# sign_lon = str[1] == 'E' ? 1 : -1
# lon_h = parse(Float64, str[2:4])
# lon_m = parse(Float64, str[5:6])
# lon_s = parse(Float64, str[7:8])
# else
# sign_lon = str[8] == 'E' ? 1 : -1
# lon_h = parse(Float64, str[1:3])
# lon_m = parse(Float64, str[4:5])
# lon_s = parse(Float64, str[6:7])
# end
# elseif length(str) == 6
# if str[1] in ['E','W']
# sign_lon = str[1] == 'E' ? 1 : -1
# lon_h = parse(Float64, str[2:4])
# lon_m = parse(Float64, str[5:6])
# lon_s = 0.0
# else
# sign_lon = str[6] == 'E' ? 1 : -1
# lon_h = parse(Float64, str[1:3])
# lon_m = parse(Float64, str[4:5])
# lon_s = 0.0
# end
# else
# return missing
# end
# return sign_lon*(lon_h + lon_m/60.0 + lon_s/3600.0)
# end
#
# function latlon(str_lat::AbstractString, str_lon::AbstractString)
# lat = extract_lat(str_lat)
# lon = extract_lon(str_lon)
# if !ismissing(lat*lon)
# return Point(lat, lon)
# else
# return missing
# end
# end

function read(file)
freerouteareas = Dict{String, FreeRouteArea}()
freerouteareaname = ""
Expand Down
1 change: 0 additions & 1 deletion src/Mot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Mot fileformat example
"""
module Mot

# include("utility.jl")
using ..util
using Dates

Expand Down
14 changes: 7 additions & 7 deletions src/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ function latlon(str_lat::AbstractString, str_lon::AbstractString)
end

function latlon(str::AbstractString)
eorw = "W"
if occursin("E", str)
eorw = "E"
nors = "S"
if occursin("S", str)
nors = "S"
else
eorw = "W"
nors = "N"
end

split_str = split(str, eorw)
str_lat = split_str[1]
str_lon = eorw*split_str[2]
split_str = split(str, nors)
str_lat = split_str[1]*nors
str_lon = split_str[2]
return latlon(str_lat, str_lon)
end

Expand Down
27 changes: 27 additions & 0 deletions test/Implemented/Allftplus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,46 @@ using Dates
@test df2[2,:ftfmEetFirNrOfInstances_72] == 0
@test df2[1,:ftfmEetFirList_73] == "EHAAFIR:10"
@test df2[2,:ftfmEetPtNrOfInstances_74] == 0
#TODO Setup function to extract EetPtList
@test df2[1,:ftfmEetPtList_75] == "55N020W:125 57N030W:170 58N040W:211 58N050W:251 CUDDY:281"
@test df2[2,:ftfmAiracCycleReleaseNumber_76] == 447
@test df2[2,:ftfmEnvBaselineNumber_77] == 842
@test df2[2,:ftfmDepartureRunway_78] == "GCXO30"
@test df2[2,:ftfmArrivalRunway_79] == "GCHI34"
@test df[2,:ftfmReqFlightlevelSpeedNrOfInstances_80] == 1
@test df2[1,:ftfmReqFlightlevelSpeedList_81] == "F320:N0487:0 F340:M084:1383 F360:M084:4022"
fll = DDR2import.Allftplus.reqFlightlevelSpeedList(df2[1,:ftfmReqFlightlevelSpeedList_81])
@test fll[1].FL == 320
@test fll[2].Spd == "M084"
@test fll[3].Value == 4022 # TODO What is Value? Time in seconds? Travel distance in NM?
@test df2[2,:ftfmConsumedFuel_82] == 322.0
@test df2[2,:ftfmRouteCharges_83] == 49.0
@test df2[2,:ftfmAllFtPointNrOfInstances_84] == 16
pp = DDR2import.Allftplus.AllFtPointProfileList(df2[2,:ftfmAllFtPointProfile_85])
@test Dates.minute(pp[1].datetime) == 10
@test pp[5].point == "TESEL"
@test pp[1].route == "HIE1J"
@test pp[2].FL == 25
@test pp[3].pointDistance == 11
@test pp[4].pointType == "V"
@test pp[6].geoPointId.ϕ 28.461666 atol = 0.0001
@test pp[6].geoPointId.λ -16.875555555555557 atol = 0.0001
@test pp[8].ratio == 54
@test pp[9].isVisible == true
#@test df[2,:ftfmAllFtPointProfile_85]
@test df2[2,:ftfmAllFtAirspaceNrOfInstances_86] == 10
#@test df[2,:ftfmAllFtAirspaceProfile_87]
ap = DDR2import.Allftplus.AllFtAirspaceProfileList(df2[2,:ftfmAllFtAirspaceProfile_87])
@test Dates.minute(ap[1].entry_datetime) == 10
@test ap[2].sector == "GCXOAXO"
@test Dates.day(ap[3].exit_datetime) == 3
@test ap[4].fir == "NAS"
@test ap[5].entry_geoPointId.ϕ 28.47222222222222 atol = 0.00001
@test ap[6].exit_geoPointId.λ -17.3275 atol = 0.00001
@test ap[7].entry_FL == 80
@test ap[8].exit_FL == 80
@test ap[9].entry_pointDistance == 119
@test ap[10].exit_pointDistance == 185
@test df2[2,:ftfmAllFtCircleIntersectionsNrOfInstances_88] == 2
#@test df[2,:ftfmAllFtCircleIntersections_89]
@test df2[3,:rtfmAiracCycleReleaseNumber_90] == 447
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using Test
"Implemented\\Nnpt", "Implemented\\Cost", "Implemented\\Crco",
"Implemented\\Ur", "Implemented\\Arp", "Implemented\\Ntfv",
"util"]
# tests = ["util"]
# tests = ["Implemented\\Allftplus"]

for t in tests
include("$(t).jl")
Expand Down
6 changes: 3 additions & 3 deletions test/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ using Dates
@test DDR2import.util.latlon("S123456", "012E").λ 12.0 atol = 0.0001
@test DDR2import.util.latlon("S123456", "E1") === NaN

@test DDR2import.util.latlon("S123456E1123456.0").ϕ -12.58222222 atol = 0.0001
@test DDR2import.util.latlon("S123456E1123456.0").λ 112.58222222 atol = 0.0001
@test DDR2import.util.latlon("S123456W1123456.0").λ -112.58222222 atol = 0.0001
@test DDR2import.util.latlon("123456S1123456.0E").ϕ -12.58222222 atol = 0.0001
@test DDR2import.util.latlon("123456S1123456.0E").λ 112.58222222 atol = 0.0001
@test DDR2import.util.latlon("123456S1123456.0W").λ -112.58222222 atol = 0.0001


yymmdd = DateFormat("YYmmdd")
Expand Down

0 comments on commit 805ee38

Please sign in to comment.