git-fit 0.21.0 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/git_fit/elevation/correct.rb +9 -4
- data/lib/git_fit/elevation/terrain_coeff.rb +19 -7
- data/lib/git_fit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4b3579f7c261d30e4b352cfb55be41424e843627eb9e50e7d5136b57c49ce63e
|
|
4
|
+
data.tar.gz: 5d7727ed3abc50ff59469ce76dc4f37e07cbed1e73e0b245d026d15ce07861a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a7cd22ebbc16e55b34d832be0466b44d58bc90bea98a164870fdbf1121a6262e4570d1e4060d6b091ba44254986ffa7377131f4ff171590c806a103de658ea1f
|
|
7
|
+
data.tar.gz: 5b87898f84b621126b475eb5c9a922d3aa8b58125040a954346169bcc542dd77dc66fd95493144026e345bfc283d39d40b1547146f113171af5bdfbcb7ef0f91
|
|
@@ -81,16 +81,21 @@ module GitFit
|
|
|
81
81
|
l2 = JSON.parse(File.read(l2_path))
|
|
82
82
|
return nil unless l2.is_a?(Array)
|
|
83
83
|
|
|
84
|
+
# L2 std has two coordinate key styles: keep/2bulu/apple_health/xingzhe
|
|
85
|
+
# write latitude/longitude, FIT-derived sources write positionLat/
|
|
86
|
+
# positionLong (same convention as Dedup::Trajectory and export/gpx).
|
|
84
87
|
pts = l2.filter_map do |pt|
|
|
85
88
|
next unless pt.is_a?(Hash)
|
|
86
|
-
|
|
89
|
+
lat = pt['latitude'] || pt['positionLat']
|
|
90
|
+
lng = pt['longitude'] || pt['positionLong']
|
|
91
|
+
next unless lat && lng && pt['altitude']
|
|
87
92
|
|
|
88
|
-
pt
|
|
93
|
+
[lat.to_f, lng.to_f, pt['altitude'].to_f]
|
|
89
94
|
end
|
|
90
95
|
return nil if pts.size < 2
|
|
91
96
|
|
|
92
|
-
locations = pts.map { |
|
|
93
|
-
alts_raw = pts.map { |
|
|
97
|
+
locations = pts.map { |lat, lng, _alt| [lat, lng] }
|
|
98
|
+
alts_raw = pts.map { |_lat, _lng, alt| alt }
|
|
94
99
|
|
|
95
100
|
dem_alts = dem_corrected_altitudes(locations, alts_raw)
|
|
96
101
|
h = hysteresis_threshold(source, locations, alts_raw)
|
|
@@ -16,6 +16,10 @@ module GitFit
|
|
|
16
16
|
GRID = 0.0003
|
|
17
17
|
|
|
18
18
|
class << self
|
|
19
|
+
# OpenTopography free tier allows 1 request/second — pacing below that
|
|
20
|
+
# guarantees a 429 on every cold-cache slice (observed in workouts CI).
|
|
21
|
+
DEM_SLICE_INTERVAL = 1.05
|
|
22
|
+
|
|
19
23
|
def model_path
|
|
20
24
|
@model_path ||= find_model
|
|
21
25
|
end
|
|
@@ -62,18 +66,26 @@ module GitFit
|
|
|
62
66
|
def elevations_for(locations)
|
|
63
67
|
uniq_vals = uniquify_locations(locations)
|
|
64
68
|
elevs = {}
|
|
69
|
+
last_api = nil
|
|
65
70
|
uniq_vals.each_slice(100).with_index do |slice, bi|
|
|
66
71
|
cached = DemCache.load_batch(slice)
|
|
67
72
|
elevs.merge!(cached)
|
|
68
73
|
missing = DemCache.missing_keys(slice, cached)
|
|
69
|
-
if missing.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
next if missing.empty?
|
|
75
|
+
|
|
76
|
+
# Pace API→API independently of interleaved cache-hit slices:
|
|
77
|
+
# cache processing is free, only consecutive fetches must respect
|
|
78
|
+
# the provider's 1 req/s limit.
|
|
79
|
+
if last_api
|
|
80
|
+
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - last_api
|
|
81
|
+
sleep(DEM_SLICE_INTERVAL - elapsed) if elapsed < DEM_SLICE_INTERVAL
|
|
75
82
|
end
|
|
76
|
-
|
|
83
|
+
missing_locations = missing.map { |lat, lng| [lat, lng] }
|
|
84
|
+
batch = {}
|
|
85
|
+
DemFetch.fetch_batch(missing_locations, bi, batch, method(:grid_key))
|
|
86
|
+
elevs.merge!(batch)
|
|
87
|
+
DemCache.save_batch(batch)
|
|
88
|
+
last_api = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
77
89
|
end
|
|
78
90
|
locations.map { |lat, lng| elevs[grid_key(lat, lng)] }
|
|
79
91
|
end
|
data/lib/git_fit/version.rb
CHANGED