git-fit 0.21.3 → 0.21.4
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/backfill.rb +34 -1
- 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: ee59f447feece2b79c93671bd58f34374178d6b7e1f17ad6444f6b1d07a906c3
|
|
4
|
+
data.tar.gz: 35493309be5989b82b7b27dcee0821befc8f42fe86d68c0f1304444e63461ab3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: da503a2a3edfad88f2de9dd5018be3955f254316630aa507a2a58b7c55632001c1b942422c1f306850f1792d7858298a4c0c3cfbf19bf5f8559e696480fee60c
|
|
7
|
+
data.tar.gz: ffa50cac4cb4ef2534408cc971c6f75bb61c4b2e921146cdf3d58e647c7e549c3e57e5e87c082f504bc9addd6b8d28878e6e0649632dfadb7b4aa4b32cd71599
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module GitFit
|
|
4
4
|
module Elevation
|
|
5
5
|
class Backfill
|
|
6
|
-
SOURCES = %w[igpsport xoss strava garmin garmin_cn xingzhe].freeze
|
|
6
|
+
SOURCES = %w[igpsport xoss strava garmin garmin_cn xingzhe keep].freeze
|
|
7
7
|
BATCH_SIZE = 100
|
|
8
8
|
|
|
9
9
|
def initialize(db, force: false)
|
|
@@ -62,6 +62,7 @@ module GitFit
|
|
|
62
62
|
when 'garmin_cn' then compute_from_fit(source, natural_id)
|
|
63
63
|
when 'strava' then compute_from_l2(source, natural_id)
|
|
64
64
|
when 'xingzhe' then compute_from_xingzhe(natural_id)
|
|
65
|
+
when 'keep' then compute_from_keep(natural_id)
|
|
65
66
|
else return
|
|
66
67
|
end
|
|
67
68
|
|
|
@@ -104,6 +105,38 @@ module GitFit
|
|
|
104
105
|
nil
|
|
105
106
|
end
|
|
106
107
|
|
|
108
|
+
def compute_from_keep(natural_id)
|
|
109
|
+
l2_path = File.join('data', 'std', 'keep', "#{natural_id}.json")
|
|
110
|
+
return nil unless File.exist?(l2_path)
|
|
111
|
+
|
|
112
|
+
l2 = JSON.parse(File.read(l2_path))
|
|
113
|
+
return nil unless l2.is_a?(Array)
|
|
114
|
+
|
|
115
|
+
alts = l2.filter_map do |pt|
|
|
116
|
+
next unless pt.is_a?(Hash)
|
|
117
|
+
|
|
118
|
+
alt = pt['altitude']
|
|
119
|
+
next unless alt
|
|
120
|
+
|
|
121
|
+
alt.to_f
|
|
122
|
+
end
|
|
123
|
+
return nil if alts.size < 2
|
|
124
|
+
|
|
125
|
+
gain = elevation_gain_from_alts(alts, threshold: 0.0)
|
|
126
|
+
loss = elevation_loss_from_alts(alts, threshold: 0.0)
|
|
127
|
+
filtered = self.class.filter_low_outliers(alts)
|
|
128
|
+
|
|
129
|
+
{
|
|
130
|
+
elevation_gain: gain.round(1),
|
|
131
|
+
elevation_loss: loss.round(1),
|
|
132
|
+
elevation_min: (filtered.min || alts.min)&.round(1),
|
|
133
|
+
elevation_max: alts.max&.round(1),
|
|
134
|
+
}
|
|
135
|
+
rescue StandardError => e
|
|
136
|
+
warn "Elevation backfill [keep][#{natural_id}]: #{e.message}"
|
|
137
|
+
nil
|
|
138
|
+
end
|
|
139
|
+
|
|
107
140
|
def compute_from_xingzhe(natural_id)
|
|
108
141
|
# New per-id directory: data/raw/xingzhe/{id}/stream.json (Phase 1, commit 661007e)
|
|
109
142
|
# Legacy flat: data/raw/xingzhe/{id}.json
|
data/lib/git_fit/version.rb
CHANGED