comtec-dr 0.9.0 → 0.10.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 051d6576635668fdf33a0f1a7231cb83a26b3a83
4
- data.tar.gz: 737e0cc7dccf246a8ea3442fb673ee1d3cfcb39e
3
+ metadata.gz: f37b33e76c04f77f66f86b8d33b71b4648d05f68
4
+ data.tar.gz: 896741940c344a497b44d25dccf93781ab9d900b
5
5
  SHA512:
6
- metadata.gz: 3136dd1855c2d87de6d51f1c50fd790613cc595fd496cf5dcbae87a6f239f86ad3c42f92c20eca3b692e7e793277bb3f1613f96ab7dc0f377232263e78eb8c32
7
- data.tar.gz: b603a1f6c69b49e25d08dfd3215b28fe9dc7d597d1e3bcaa62e83768889a6f6cb92f8dee27bafb050748a50bd1b711f0084c007a3e5507ff256c2fd70d984626
6
+ metadata.gz: e1e25340b3c6471052166a911f099b5352342ccacd9ca3422cf115a8baef9098dd09c9a9f680d4e6b94e96805871b87cd6389669a15893a21f9f8e42a3e3f2ad
7
+ data.tar.gz: a6b6bebd3ce4445a9bba16c64ef28d55736dacbc3af888d8fe59cd56c5ba3f2690a2574705d8aad514a7e1f117e7be5e0452cd5d25ab2968681872f28e568fb7
@@ -8,14 +8,14 @@ ARGV.each do |arg|
8
8
  if path.file? && path.basename.to_s.end_with?('.MOV')
9
9
  CSV.open("#{path.basename.to_s.gsub('.MOV','')}.csv",'w') do |csv|
10
10
  track = ComtecDR::GpsTrack.analyze path.to_s
11
- track.track.each{|t| csv << t}
11
+ track.track.each{|t| csv << t.csv_line}
12
12
  end
13
13
  elsif path.directory?
14
14
  CSV.open("#{path.basename.to_s}.csv",'w') do |csv|
15
15
  path.children(with_directory: false).each do |child_path|
16
16
  if child_path.file? && child_path.basename.to_s.end_with?('.MOV')
17
17
  track = ComtecDR::GpsTrack.analyze child_path.to_s
18
- track.track.each{|t| csv << t}
18
+ track.track.each{|t| csv << t.csv_line}
19
19
  end
20
20
  end
21
21
  end
@@ -8,7 +8,7 @@ ARGV.each do |arg|
8
8
  if path.file? && path.basename.to_s.end_with?('.MOV')
9
9
  gpx = ComtecDR::GpxGenerator.new "#{path.basename.to_s.gsub('.MOV','')}.gpx"
10
10
  track = ComtecDR::GpsTrack.analyze path.to_s
11
- gpx.add_track track.compress.track
11
+ gpx.add_track track.compress
12
12
  gpx.write
13
13
  elsif path.directory?
14
14
  gpx = ComtecDR::GpxGenerator.new "#{path.basename.to_s}.gpx"
@@ -16,7 +16,7 @@ ARGV.each do |arg|
16
16
  path.children(with_directory: false).each do |child_path|
17
17
  if child_path.file? && child_path.basename.to_s.end_with?('.MOV')
18
18
  track = ComtecDR::GpsTrack.analyze child_path.to_s
19
- gpx.add_trkseg track.compress.track
19
+ gpx.add_trkseg track.compress
20
20
  end
21
21
  end
22
22
  gpx.write
@@ -1,6 +1,6 @@
1
1
  module ComtecDR
2
2
  class GpsLog
3
- def initialize lat, lat_s, lon, lon_s, speed, jst, msec, x_a, y_a, z_a
3
+ def initialize lat, lat_s, lon, lon_s, speed, jst, msec, x_a, y_a, z_a, filename
4
4
  @lat = lat
5
5
  @lat_sign = lat_s
6
6
  @lon = lon
@@ -11,6 +11,7 @@ module ComtecDR
11
11
  @x_acceleration = x_a
12
12
  @y_acceleration = y_a
13
13
  @z_acceleration = z_a
14
+ @filename = filename
14
15
  end
15
16
 
16
17
  def lat
@@ -46,7 +47,7 @@ module ComtecDR
46
47
  end
47
48
 
48
49
  def csv_line
49
- [lat, lon, speed, jst, msec, x_acceleration, y_acceleration, z_acceleration]
50
+ [lat, lon, speed, jst, msec, x_acceleration, y_acceleration, z_acceleration, @filename]
50
51
  end
51
52
 
52
53
  private
@@ -14,8 +14,8 @@ module ComtecDR
14
14
  new_track = self.class.new
15
15
  prev = []
16
16
  self.track.each do |t|
17
- new_track << t unless t[0..2] == prev[0..2]
18
- prev = t
17
+ new_track << t unless t.csv_line[0..2] == prev
18
+ prev = t.csv_line[0..2]
19
19
  end
20
20
  new_track
21
21
  end
@@ -24,8 +24,8 @@ module ComtecDR
24
24
  def analyze file_path
25
25
  self.new.tap do |track|
26
26
  ComtecDR::UdatAnalyzer.analyze(ComtecDR::MovDemuxer.demux file_path).each do |line|
27
- log = ComtecDR::GpsLog.new *line
28
- track << [*log.csv_line, Pathname.new(file_path).basename.to_s]
27
+ log = ComtecDR::GpsLog.new *[*line, Pathname.new(file_path).basename.to_s]
28
+ track << log
29
29
  end
30
30
  end
31
31
  end
@@ -15,19 +15,29 @@ module ComtecDR
15
15
  @doc.add_element(@gpx)
16
16
  end
17
17
 
18
- def add_track csv = nil
18
+ def add_track track = nil
19
19
  @trk = REXML::Element.new('trk')
20
20
  @gpx.add_element(@trk)
21
21
 
22
- add_trkseg csv if !csv.nil?
22
+ add_trkseg track if !track.nil?
23
23
  end
24
24
 
25
- def add_trkseg csv
25
+ def add_trkseg track
26
26
  trkseg = REXML::Element.new('trkseg')
27
27
  @trk.add_element(trkseg)
28
- csv.each do |line|
28
+
29
+ track.track.each do |t|
29
30
  trkpt = REXML::Element.new('trkpt')
30
- trkpt.add_attributes({'lat' => line[0], 'lon' => line[1]})
31
+ trkpt.add_attributes({'lat' => t.lat, 'lon' => t.lon})
32
+
33
+ time = REXML::Element.new('time')
34
+ time.add_text(t.jst.utc.iso8601)
35
+ trkpt.add_element(time)
36
+
37
+ speed = REXML::Element.new('speed')
38
+ speed.add_text((t.speed.to_f * 1000 / 3600).to_s)
39
+ trkpt.add_element(speed)
40
+
31
41
  trkseg.add_element(trkpt)
32
42
  end
33
43
  end
@@ -1,7 +1,7 @@
1
1
  module ComtecDR
2
2
  class UdatAnalyzer
3
3
  LOG_PATTERN = /
4
- A
4
+ (?:[AV])
5
5
  (?<lat>[\d.]*)(?<lat_sign>[NS])
6
6
  (?<lon>[\d.]*)(?<lon_sign>[EW])
7
7
  (?<speed>\d{4})
@@ -1,6 +1,6 @@
1
1
  module ComtecDR
2
2
  MAJOR = 0
3
- MINOR = 9
3
+ MINOR = 10
4
4
  PATCH = 0
5
5
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comtec-dr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shogo Kawaguchi