@@ -15,6 +15,36 @@ if !@isdefined h3GetResolution
15
15
end
16
16
17
17
18
+ if ! @isdefined h3IsValid
19
+ @info " Defining h3IsValid"
20
+ function h3IsValid (h3)
21
+ isValidCell (h3)
22
+ end
23
+ end
24
+
25
+
26
+ @static if ! @isdefined (GeoCoord)
27
+ @info " Defining GeoCoord compatibility struct"
28
+ struct GeoCoord
29
+ lat:: Float64 # in radians
30
+ lon:: Float64 # in radians
31
+ end
32
+ end
33
+
34
+ # Runtime conditional method definition (always allowed)
35
+ if ! (@isdefined geoToH3) && (@isdefined latLngToCell)
36
+ @info " Defining geoToH3 compatibility shim"
37
+ function geoToH3 (coord:: GeoCoord , res:: Integer )
38
+ return latLngToCell (LatLng (coord. lat, coord. lon), res)
39
+ end
40
+
41
+ function h3ToGeo (cell_id)
42
+ lat_lng_rad = cellToLatLng (cell_id)
43
+ GeoCoord (lat_lng_rad. lat, lat_lng_rad. lng)
44
+ end
45
+ end
46
+
47
+
18
48
# the function and api have changed; the H3.jl library as of 3.2 is not defined correctly
19
49
edge_length_check = edgeLengthKm (3 )
20
50
if edge_length_check isa Number
@@ -74,7 +104,8 @@ julia> smoothing('count.csv', [[1.0, 20]], 50)
74
104
h3res = h3GetResolution (df. h3idx[1 ])
75
105
edge_length = get_avg_edge_length_km (h3res)
76
106
println (@sprintf (" Edge resolution : %d" , h3res))
77
- println (@sprintf (" Edge length : %.3f km" , edgeLengthKm (h3res)))
107
+ # println(@sprintf("Edge length : %.3f km", edgeLengthKm(h3res)))
108
+ println (@sprintf (" Edge length : %.3f km" , edge_length))
78
109
79
110
maxdistk = Int (ceil (maxdistkm / edge_length))
80
111
println (@sprintf (" Max dist k : %d " , maxdistk))
@@ -105,7 +136,7 @@ julia> smoothing('count.csv', [[1.0, 20]], 50)
105
136
dsts = zeros (Float32, length (idxs))
106
137
for idx in enumerate (idxs)
107
138
d = h3Distance (base, idx[2 ])
108
- dsts[idx[1 ]] = d * edgeLengthKm (h3res)
139
+ dsts[idx[1 ]] = d * edge_length
109
140
if dsts[idx[1 ]] < 1.0
110
141
dsts[idx[1 ]] = 1.0
111
142
end
0 commit comments