Class: Geoptima::MergedTrace

Inherits:
Trace
  • Object
show all
Defined in:
lib/geoptima/data.rb

Instance Attribute Summary collapse

Attributes inherited from Trace

#bounds, #data_id, #data_id_hashset, #dataset, #events, #name, #padding, #scale, #totals

Instance Method Summary collapse

Methods inherited from Trace

#as_csv, #as_gpx, #as_gpx_route, #as_gpx_track, #as_gpx_ways, #average, #bottom, #bounds_as_gpx, #check_bounds, #check_bounds_max, #check_bounds_min, #check_totals, #check_trace_bounds, #co_located, #color, #colors, #data_ids, #event_as_gpx, #fix_options, #height, #initialize_tags, #left, #remove_outliers, #scale_event, #size, #to_png, #to_s, #too_far, #width

Constructor Details

#initialize(dataset) ⇒ MergedTrace

Returns a new instance of MergedTrace.



393
394
395
396
397
398
399
# File 'lib/geoptima/data.rb', line 393

def initialize(dataset)
  @dataset = dataset
  @name = dataset.name
  @data_id_hashset = {}
  @traces = []
  initialize_tags
end

Instance Attribute Details

#tracesObject (readonly)

Returns the value of attribute traces.



392
393
394
# File 'lib/geoptima/data.rb', line 392

def traces
  @traces
end

Instance Method Details

#<<(t) ⇒ Object



403
404
405
406
407
408
# File 'lib/geoptima/data.rb', line 403

def <<(t)
  check_trace_totals(t)
  check_trace_bounds(t)
  @data_id_hashset = @data_id_hashset.merge(t.data_id_hashset)
  @traces << t
end

#check_trace_totals(t) ⇒ Object



419
420
421
422
# File 'lib/geoptima/data.rb', line 419

def check_trace_totals(t)
  @totals ||= [0.0,0.0,0]
  [0,1,2].each{|i| @totals[i] += t.totals[i]}
end

#eachObject



409
410
411
412
413
414
415
# File 'lib/geoptima/data.rb', line 409

def each
  traces.each do |t|
    t.events.each do |e|
      yield e
    end
  end
end

#lengthObject



416
417
418
# File 'lib/geoptima/data.rb', line 416

def length
  @length ||= traces.inject(0){|a,t| a+=t.length;a}
end

#tracenameObject



400
401
402
# File 'lib/geoptima/data.rb', line 400

def tracename
  @tracename ||= "Merged-#{traces.length}-traces-#{traces[0]}"
end