11"""
22Representation of a geospatial coordinates.
33
4+ # Fields
45- `lat::Float64`: Latitude.
56- `lon::Float64`: Longitude.
67- `alt::Float64`: Altitude.
8+
9+ # Constructors
10+ GeoLocation(lat, lon)
11+ GeoLocation(point::Vector{<:Real})
12+ GeoLocation(point_vector::Vector{<:Vector{<:Real}})
13+ GeoLocation(g::OSMGraph, ep::EdgePoint)
714"""
815@with_kw_noshow struct GeoLocation
916 lat:: Float64
1017 lon:: Float64
1118 alt:: Float64 = 0.0
1219end
13-
1420GeoLocation (lat:: AbstractFloat , lon:: AbstractFloat ):: GeoLocation = GeoLocation (lat= lat, lon= lon)
1521GeoLocation (lat:: Real , lon:: Real ):: GeoLocation = GeoLocation (lat= float (lat), lon= float (lon))
1622GeoLocation (point:: Vector{<:AbstractFloat} ):: GeoLocation = GeoLocation (point... )
@@ -20,6 +26,9 @@ GeoLocation(point_vector::Vector{<:Vector{<:Real}})::Vector{GeoLocation} = [GeoL
2026function Base.:(== )(loc1:: GeoLocation , loc2:: GeoLocation )
2127 return loc1. lat == loc2. lat && loc1. lon == loc2. lon && loc1. alt == loc2. alt
2228end
29+ function Base. isapprox (loc1:: GeoLocation , loc2:: GeoLocation )
30+ return loc1. lat ≈ loc2. lat && loc1. lon ≈ loc2. lon && loc1. alt ≈ loc2. alt
31+ end
2332function Base. hash (loc:: GeoLocation , h:: UInt )
2433 for field in fieldnames (GeoLocation)
2534 h = hash (getproperty (loc, field), h)
3039"""
3140OpenStreetMap node.
3241
42+ # Fields
3343`T<:Integer`
3444- `id::T`: OpenStreetMap node id.
3545- `nodes::Vector{T}`: Node's GeoLocation.
4454"""
4555OpenStreetMap way.
4656
57+ # Fields
4758`T<:Integer`
4859- `id::T`: OpenStreetMap way id.
4960- `nodes::Vector{T}`: Ordered list of node ids making up the way.
7586"""
7687OpenStreetMap turn restriction (relation).
7788
89+ # Fields
7890`T<:Integer`
7991- `id::T`: OpenStreetMap relation id.
8092- `type::String`: Either a `via_way` or `via_node` turn restriction.
101113"""
102114Container for storing OpenStreetMap node, way, relation and graph related obejcts.
103115
116+ # Fields
104117`U <: Integer,T <: Integer,W <: Real`
105118- `nodes::Dict{T,Node{T}}`: Mapping of node ids to node objects.
106119- `node_coordinates::Vector{Vector{W}}`: Vector of node coordinates [[lat, lon]...], indexed by graph vertices.
155168"""
156169OpenStreetMap building polygon.
157170
171+ # Fields
158172`T<:Integer`
159173- `id::T`: OpenStreetMap building way id.
160174- `nodes::Vector{T}`: Ordered list of node ids making up the building polyogn.
169183"""
170184OpenStreetMap building.
171185
186+ # Fields
172187`T<:Integer`
173188- `id::T`: OpenStreetMap building way id a simple polygon, relation id if a multi-polygon
174189- `is_relation::Bool`: True if building is a a multi-polygon / relation.
@@ -196,3 +211,11 @@ abstract type DijkstraDict <: Dijkstra end
196211abstract type AStar <: PathAlgorithm end
197212abstract type AStarVector <: AStar end
198213abstract type AStarDict <: AStar end
214+
215+ """
216+ Additional GeoLocation methods that require types defined above.
217+ """
218+ GeoLocation (g:: OSMGraph , ep:: EdgePoint ):: GeoLocation = GeoLocation (
219+ lon = g. nodes[ep. n1]. location. lon + (g. nodes[ep. n2]. location. lon - g. nodes[ep. n1]. location. lon) * ep. pos,
220+ lat = g. nodes[ep. n1]. location. lat + (g. nodes[ep. n2]. location. lat - g. nodes[ep. n1]. location. lat) * ep. pos
221+ )
0 commit comments