Class: ComtecDR::GpsTrack

Inherits:
Object
  • Object
show all
Defined in:
lib/comtec-dr/gps_track.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGpsTrack

Returns a new instance of GpsTrack.



4
5
6
# File 'lib/comtec-dr/gps_track.rb', line 4

def initialize
  @track = []
end

Instance Attribute Details

#trackObject (readonly)

Returns the value of attribute track.



3
4
5
# File 'lib/comtec-dr/gps_track.rb', line 3

def track
  @track
end

Class Method Details

.analyze(file_path) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/comtec-dr/gps_track.rb', line 24

def analyze file_path
  self.new.tap do |track|
    ComtecDR::UdatAnalyzer.analyze(ComtecDR::MovDemuxer.demux file_path).each do |line|
      log = ComtecDR::GpsLog.new *line
      track << [*log.csv_line, Pathname.new(file_path).basename.to_s]
    end
  end
end

Instance Method Details

#<<(log) ⇒ Object



8
9
10
# File 'lib/comtec-dr/gps_track.rb', line 8

def << log
  @track << log
end

#compressObject

位置情報を圧縮



13
14
15
16
17
18
19
20
21
# File 'lib/comtec-dr/gps_track.rb', line 13

def compress
  new_track = self.class.new
  prev = []
  self.track.each do |t|
    new_track << t unless t[0..2] == prev[0..2]
    prev = t
  end
  new_track
end