Skip to content

Commit

Permalink
prevent StackOverflowError in LatLon constructor
Browse files Browse the repository at this point in the history
now it gives a MethodError instead
fixes #47
  • Loading branch information
visr committed Nov 4, 2018
1 parent 2774631 commit b715e35
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ struct LatLon{T <: Number}
lat::T
lon::T
end
LatLon(lat, lon) = LatLon(promote(lat, lon)...)
LatLon(;lat=NaN,lon=NaN) = LatLon(lat,lon) # Constructor that is idependent of storage order
LatLon(lat::Number, lon::Number) = LatLon(promote(lat, lon)...)
LatLon(;lat=NaN,lon=NaN) = LatLon(lat,lon) # Constructor that is independent of storage order
LatLon(lla::LLA) = LatLon(lla.lat, lla.lon)
function LatLon(x, datum::Union{Datum,Ellipsoid})
lla = LLA(x, datum)
Expand Down
1 change: 1 addition & 0 deletions test/points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@test LatLon(lla) == latlon
@test LatLon(1//1, 1.) == latlon
@test LatLon(1, 1) == LatLon{Int}(1, 1)
@test_throws MethodError LatLon(missing, missing)

@test LLA(latlon) == lla

Expand Down

0 comments on commit b715e35

Please sign in to comment.