1
1
"""
2
2
Representation of a geospatial coordinates.
3
3
4
+ # Fields
4
5
- `lat::Float64`: Latitude.
5
6
- `lon::Float64`: Longitude.
6
7
- `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)
7
14
"""
8
15
@with_kw_noshow struct GeoLocation
9
16
lat:: Float64
10
17
lon:: Float64
11
18
alt:: Float64 = 0.0
12
19
end
13
-
14
20
GeoLocation (lat:: AbstractFloat , lon:: AbstractFloat ):: GeoLocation = GeoLocation (lat= lat, lon= lon)
15
21
GeoLocation (lat:: Real , lon:: Real ):: GeoLocation = GeoLocation (lat= float (lat), lon= float (lon))
16
22
GeoLocation (point:: Vector{<:AbstractFloat} ):: GeoLocation = GeoLocation (point... )
@@ -20,6 +26,9 @@ GeoLocation(point_vector::Vector{<:Vector{<:Real}})::Vector{GeoLocation} = [GeoL
20
26
function Base.:(== )(loc1:: GeoLocation , loc2:: GeoLocation )
21
27
return loc1. lat == loc2. lat && loc1. lon == loc2. lon && loc1. alt == loc2. alt
22
28
end
29
+ function Base. isapprox (loc1:: GeoLocation , loc2:: GeoLocation )
30
+ return loc1. lat ≈ loc2. lat && loc1. lon ≈ loc2. lon && loc1. alt ≈ loc2. alt
31
+ end
23
32
function Base. hash (loc:: GeoLocation , h:: UInt )
24
33
for field in fieldnames (GeoLocation)
25
34
h = hash (getproperty (loc, field), h)
30
39
"""
31
40
OpenStreetMap node.
32
41
42
+ # Fields
33
43
`T<:Integer`
34
44
- `id::T`: OpenStreetMap node id.
35
45
- `nodes::Vector{T}`: Node's GeoLocation.
44
54
"""
45
55
OpenStreetMap way.
46
56
57
+ # Fields
47
58
`T<:Integer`
48
59
- `id::T`: OpenStreetMap way id.
49
60
- `nodes::Vector{T}`: Ordered list of node ids making up the way.
75
86
"""
76
87
OpenStreetMap turn restriction (relation).
77
88
89
+ # Fields
78
90
`T<:Integer`
79
91
- `id::T`: OpenStreetMap relation id.
80
92
- `type::String`: Either a `via_way` or `via_node` turn restriction.
101
113
"""
102
114
Container for storing OpenStreetMap node, way, relation and graph related obejcts.
103
115
116
+ # Fields
104
117
`U <: Integer,T <: Integer,W <: Real`
105
118
- `nodes::Dict{T,Node{T}}`: Mapping of node ids to node objects.
106
119
- `node_coordinates::Vector{Vector{W}}`: Vector of node coordinates [[lat, lon]...], indexed by graph vertices.
155
168
"""
156
169
OpenStreetMap building polygon.
157
170
171
+ # Fields
158
172
`T<:Integer`
159
173
- `id::T`: OpenStreetMap building way id.
160
174
- `nodes::Vector{T}`: Ordered list of node ids making up the building polyogn.
169
183
"""
170
184
OpenStreetMap building.
171
185
186
+ # Fields
172
187
`T<:Integer`
173
188
- `id::T`: OpenStreetMap building way id a simple polygon, relation id if a multi-polygon
174
189
- `is_relation::Bool`: True if building is a a multi-polygon / relation.
@@ -196,3 +211,11 @@ abstract type DijkstraDict <: Dijkstra end
196
211
abstract type AStar <: PathAlgorithm end
197
212
abstract type AStarVector <: AStar end
198
213
abstract 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