Skip to content

Commit

Permalink
Improved output and help messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Ferris committed Apr 13, 2016
1 parent 004a692 commit defcb69
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
17 changes: 11 additions & 6 deletions src/crs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
A co-ordinate reference system `CRS{CoordinateSystem, Datum}` represents the
information required to georeference a point in the co-ordinate system. The
`datum` field may be a singleton instance (e.g. wgs84 of singleton type WGS84)
or a user-defined object containing any necessary information to perform any
necessary CRS transformations.
or a user-defined object containing any information necessary to perform any
intended CRS transformations.
Positions may be converted into a new CRS using the `geotransform` function:
geotransform(crs::CRS, position::Position)
Expand Down Expand Up @@ -39,10 +39,11 @@ function CRS{CoordinateSystem, Datum}(x::Position{CoordinateSystem, Datum})
end

function Base.show{CoordinateSystem, Datum}(io::IO, crs::CRS{CoordinateSystem, Datum})
print(io, "CRS in $CoordinateSystem coordiantes using datum $(crs.datum)")
print(io, "CRS($CoordinateSystem, datum=$(crs.datum))")
end
function Base.show{Datum}(io::IO, crs::CRS{ENU, Datum})
print(io, "CRS in ENU coordiantes from origin $(crs.datum)")
# Flatten the output for ENU Positions to make them more readable
function Base.show{Datum <: Position}(io::IO, crs::CRS{ENU, Datum})
print(io, "CRS(ENU, origin=$(crs.datum.x), datum=$(crs.datum.datum))")
end

# ----------------------------------------------------------
Expand All @@ -53,5 +54,9 @@ Base.call{CS}(crs::CRS{CS}, x::CS) = Position(x, crs.datum)
Base.call{CS}(crs::CRS{CS}, x...) = Position(CS(x...), crs.datum)

function Base.show{CoordinateSystem, Datum}(io::IO, pos::Position{CoordinateSystem, Datum})
print(io, "$(pos.x) in datum $(pos.datum)")
print(io, "Position($(pos.x), datum=$(pos.datum))")
end
# Flatten the output for ENU Positions to make them more readable
function Base.show{Datum <: Position}(io::IO, pos::Position{ENU, Datum})
print(io, "Position($(pos.x), origin=$(pos.datum.x), datum=$(pos.datum.datum))")
end
31 changes: 24 additions & 7 deletions src/points.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
### Point Types ###
###################

### Point in Latitude-Longitude-Altitude (LLA) coordinates
# Used to store node data in OpenStreetMap XML files
"""
Latitude, longitude, and alititude co-ordinate system.
(Note: assumes degrees not radians)
Expand All @@ -16,6 +14,12 @@ immutable LLA
end
LLA(lat, lon) = LLA(lat, lon, 0.0)

function Base.show(io::IO, lla::LLA)
# Avoid any confusion regarding order of latitude and longitude
print(io, "LLA(lat=$(lla.lat), lon=$(lla.lon), alt=$(lla.alt))")
end


"""
Latitude and longitude co-ordinates.
(Note: assumes degrees not radians)
Expand All @@ -30,20 +34,30 @@ function LatLon(x, datum)
return LatLon(lla.lat, lla.lon)
end

function Base.show(io::IO, ll::LatLon)
# Avoid any confusion regarding order of latitude and longitude
print(io, "LatLon(lat=$(ll.lat), lon=$(ll.lon))")
end


"""
Point in Earth-Centered-Earth-Fixed (ECEF) coordinates
Global cartesian coordinate system rotating with the Earth
Point in Earth-Centered-Earth-Fixed (ECEF) coordinates.
Global cartesian coordinate system rotating with the Earth.
"""
immutable ECEF # <: FixedVectorNoTuple{3,Float64}
x::Float64
y::Float64
z::Float64
end

function Base.show(io::IO, ecef::ECEF)
print(io, "ECEF(x=$(ecef.x), y=$(ecef.y), z=$(ecef.z))")
end


"""
Point in East-North-Up (ENU) coordinates
Local cartesian coordinate system
Linearized about a reference point
Point in East-North-Up (ENU) coordinates. Local cartesian coordinate system,
linearized about a reference point.
"""
immutable ENU # <: FixedVectorNoTuple{3,Float64}
e::Float64
Expand All @@ -52,6 +66,9 @@ immutable ENU # <: FixedVectorNoTuple{3,Float64}
end
ENU(x, y) = ENU(x, y, 0.0)

function Base.show(io::IO, enu::ENU)
print(io, "ENU(e=$(enu.e), n=$(enu.n), u=$(enu.u))")
end

### distance
# Point translators
Expand Down

0 comments on commit defcb69

Please sign in to comment.