Class: GitFit::Elevation::Correct

Inherits:
Object
  • Object
show all
Defined in:
lib/git_fit/elevation/correct.rb

Overview

Strategy-corrected elevation: L2 std → (optional DEM) → adaptive hysteresis threshold → activities.elevation_terrain. Raw device/API values stay in elevation (written by Backfill); this class only fills the _terrain columns.

Constant Summary collapse

SOURCES =
%w[garmin garmin_cn strava keep igpsport xoss xingzhe 2bulu apple_health].freeze
BARO_SOURCES =
%w[xingzhe 2bulu apple_health].freeze
BATCH_SIZE =
100
STATIC_HYST_BARO =
2.0
STATIC_HYST_GPS =
3.0

Instance Method Summary collapse

Constructor Details

#initialize(db, force: false, dry_run: false, dem: true) ⇒ Correct

Returns a new instance of Correct.



15
16
17
18
19
20
21
22
23
24
# File 'lib/git_fit/elevation/correct.rb', line 15

def initialize(db, force: false, dry_run: false, dem: true)
  @db = db
  @force = force
  @dry_run = dry_run
  @dem = dem
  @updated = 0
  @skipped = 0
  @failed = 0
  @no_model = 0
end

Instance Method Details

#call(source = nil) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/git_fit/elevation/correct.rb', line 26

def call(source = nil)
  sources = source ? [source] : SOURCES
  sources.each do |src|
    correct_source(src)
  end
  { updated: @updated, skipped: @skipped, failed: @failed, no_model: @no_model }
end