comtec-dr 0.7.0 → 0.8.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: 37ef6784e41a9bd1c4778ab734adb382e2a3860e
4
- data.tar.gz: 8a784e19f516e8f597cb9e4733e01802a8b4db84
3
+ metadata.gz: 80e24446a1bc5937c236b7a810ee53533695692e
4
+ data.tar.gz: 76ae164fedf54aa09230b970b798e1128cd2ac2a
5
5
  SHA512:
6
- metadata.gz: 3d2c9b06f10caf8bad474a3a27aa2e0cd239925fb3c9340876fbe3c2923872ab467c271722d8788af95265e49631cfe0d57bfeed81446b97641ca9906a8449cb
7
- data.tar.gz: 0e5cd18743b3f51fa79de9a38b5a49fbba70e303ca509c28ad16100eedc47cb4ee61710d5ed9195a8eded01e7ed5b40abcd2ddf535b39c61c4bc52249f405700
6
+ metadata.gz: 87611f1a944be3c93b6d7c353f47241024fb09c7ef9b72b6a428814e55ce01709de7d435fe73fc025560a549227564e8f3b695a298e631744dac7f83d0f71bad
7
+ data.tar.gz: 79f3d0e2c1991da3bef41180b5340a318f8f65087b816def1826ca26e2e5699c3d3769ae52ef4efe025aea6095922516bfa0f2c1058a6d12d6bc7e6a5feae5f8
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'pathname'
5
+ require 'csv'
6
+ require 'comtec-dr'
7
+
8
+ ARGV.each do |arg|
9
+ path = Pathname arg
10
+ if path.file? && path.basename.to_s.end_with?('.csv')
11
+ gpx = ComtecDR::GpxGenerator.new "#{path.basename.to_s.gsub('.csv','')}.gpx"
12
+ csv = CSV.read path.to_s
13
+ gpx.add_track csv
14
+ gpx.write
15
+ elsif path.directory?
16
+ gpx = ComtecDR::GpxGenerator.new "#{path.basename.to_s}.gpx"
17
+ csvs = []
18
+ path.children.each do |child_path|
19
+ if child_path.file? && child_path.basename.to_s.end_with?('.csv')
20
+ csv = CSV.read child_path.to_s
21
+ csvs << csv
22
+ end
23
+ end
24
+ csvs.each do |csv|
25
+ gpx.add_track csv
26
+ end
27
+ gpx.write
28
+ end
29
+ end
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
3
+ require 'bundler/setup'
4
4
  require 'pathname'
5
- require "comtec-dr"
5
+ require 'comtec-dr'
6
6
 
7
7
  ARGV.each do |arg|
8
8
  path = Pathname arg
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
3
+ require 'bundler/setup'
4
4
  require 'pathname'
5
5
  require 'csv'
6
- require "comtec-dr"
6
+ require 'comtec-dr'
7
7
 
8
8
  ARGV.each do |arg|
9
9
  path = Pathname arg
10
10
  if path.file? && path.basename.to_s.end_with?('.MOV')
11
11
  CSV.open("#{path.basename.to_s.gsub('.MOV','')}.csv",'w') do |csv|
12
12
  ComtecDR::UdatAnalyzer.analyze(ComtecDR::MovDemuxer.demux path.to_s).each do |line|
13
- log = GpsLog.new *line
13
+ log = ComtecDR::GpsLog.new *line
14
14
  csv << [*log.csv_line, path.basename.to_s]
15
15
  end
16
16
  end
@@ -19,7 +19,7 @@ ARGV.each do |arg|
19
19
  path.children.each do |child_path|
20
20
  if child_path.file? && child_path.basename.to_s.end_with?('.MOV')
21
21
  ComtecDR::UdatAnalyzer.analyze(ComtecDR::MovDemuxer.demux child_path.to_s).each do |line|
22
- log = GpsLog.new *line
22
+ log = ComtecDR::GpsLog.new *line
23
23
  csv << [*log.csv_line, child_path.basename.to_s]
24
24
  end
25
25
  end
@@ -1,25 +1,26 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
3
+ require 'bundler/setup'
4
4
  require 'pathname'
5
- require "comtec-dr"
5
+ require 'comtec-dr'
6
6
 
7
7
  ARGV.each do |arg|
8
8
  path = Pathname arg
9
9
  if path.file? && path.basename.to_s.end_with?('.MOV')
10
10
  gpx = ComtecDR::GpxGenerator.new "#{path.basename.to_s.gsub('.MOV','')}.gpx"
11
11
  csv = ComtecDR::UdatAnalyzer.analyze(ComtecDR::MovDemuxer.demux path.to_s).map do |line|
12
- log = GpsLog.new *line
12
+ log = ComtecDR::GpsLog.new *line
13
13
  log.csv_line
14
14
  end
15
- gpx.add_trkseg csv
15
+ gpx.add_track csv
16
16
  gpx.write
17
17
  elsif path.directory?
18
18
  gpx = ComtecDR::GpxGenerator.new "#{path.basename.to_s}.gpx"
19
+ gpx.add_track
19
20
  path.children.each do |child_path|
20
21
  if child_path.file? && child_path.basename.to_s.end_with?('.MOV')
21
22
  csv = ComtecDR::UdatAnalyzer.analyze(ComtecDR::MovDemuxer.demux child_path.to_s).map do |line|
22
- log = GpsLog.new *line
23
+ log = ComtecDR::GpsLog.new *line
23
24
  log.csv_line
24
25
  end
25
26
  gpx.add_trkseg csv
@@ -1,57 +1,59 @@
1
- class GpsLog
2
- def initialize lat, lat_s, lon, lon_s, speed, jst, msec, x_a, y_a, z_a
3
- @lat = lat
4
- @lat_sign = lat_s
5
- @lon = lon
6
- @lon_sign = lon_s
7
- @speed = speed
8
- @jst = jst
9
- @msec = msec
10
- @x_acceleration = x_a
11
- @y_acceleration = y_a
12
- @z_acceleration = z_a
13
- end
14
-
15
- def lat
16
- (dmm_to_dms(@lat) * (@lat_sign == 'N' ? 1 : -1)).to_f
17
- end
18
-
19
- def lon
20
- (dmm_to_dms(@lon) * (@lon_sign == 'E' ? 1 : -1)).to_f
21
- end
22
-
23
- def speed
24
- @speed.to_i
25
- end
26
-
27
- def jst
28
- Time.parse "20#{@jst}}+0900"
29
- end
30
-
31
- def msec
32
- @msec.to_i
33
- end
34
-
35
- def x_acceleration
36
- @x_acceleration.to_f/1000
37
- end
38
-
39
- def y_acceleration
40
- @y_acceleration.to_f/1000
41
- end
42
-
43
- def z_acceleration
44
- @z_acceleration.to_f/1000
45
- end
46
-
47
- def csv_line
48
- [lat, lon, speed, jst, msec, x_acceleration, y_acceleration, z_acceleration]
49
- end
50
-
51
- private
52
- # DMM形式から変換
53
- def dmm_to_dms str
54
- number, fractional = str.split('.')
55
- number[0...-2].to_r + "#{number[-2..-1]}.#{fractional}".to_r / 60
1
+ module ComtecDR
2
+ class GpsLog
3
+ def initialize lat, lat_s, lon, lon_s, speed, jst, msec, x_a, y_a, z_a
4
+ @lat = lat
5
+ @lat_sign = lat_s
6
+ @lon = lon
7
+ @lon_sign = lon_s
8
+ @speed = speed
9
+ @jst = jst
10
+ @msec = msec
11
+ @x_acceleration = x_a
12
+ @y_acceleration = y_a
13
+ @z_acceleration = z_a
14
+ end
15
+
16
+ def lat
17
+ (dmm_to_dms(@lat) * (@lat_sign == 'N' ? 1 : -1)).to_f
18
+ end
19
+
20
+ def lon
21
+ (dmm_to_dms(@lon) * (@lon_sign == 'E' ? 1 : -1)).to_f
22
+ end
23
+
24
+ def speed
25
+ @speed.to_i
26
+ end
27
+
28
+ def jst
29
+ Time.parse "20#{@jst}}+0900"
30
+ end
31
+
32
+ def msec
33
+ @msec.to_i
34
+ end
35
+
36
+ def x_acceleration
37
+ @x_acceleration.to_f/1000
38
+ end
39
+
40
+ def y_acceleration
41
+ @y_acceleration.to_f/1000
42
+ end
43
+
44
+ def z_acceleration
45
+ @z_acceleration.to_f/1000
46
+ end
47
+
48
+ def csv_line
49
+ [lat, lon, speed, jst, msec, x_acceleration, y_acceleration, z_acceleration]
50
+ end
51
+
52
+ private
53
+ # DMM形式から変換
54
+ def dmm_to_dms str
55
+ number, fractional = str.split('.')
56
+ number[0...-2].to_r + "#{number[-2..-1]}.#{fractional}".to_r / 60
57
+ end
56
58
  end
57
59
  end
@@ -13,9 +13,19 @@ module ComtecDR
13
13
  'xsi:schemaLocation' => 'http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd'
14
14
  })
15
15
  @doc.add_element(@gpx)
16
+ end
16
17
 
18
+ def add_track csv = nil
17
19
  @trk = REXML::Element.new('trk')
18
20
  @gpx.add_element(@trk)
21
+
22
+ trkseg = REXML::Element.new('trkseg')
23
+ @trk.add_element(trkseg)
24
+ csv.each do |line|
25
+ trkpt = REXML::Element.new('trkpt')
26
+ trkpt.add_attributes({'lat' => line[0], 'lon' => line[1]})
27
+ trkseg.add_element(trkpt)
28
+ end if !csv.nil?
19
29
  end
20
30
 
21
31
  def add_trkseg csv
@@ -28,7 +38,6 @@ module ComtecDR
28
38
  end
29
39
  end
30
40
 
31
-
32
41
  def write
33
42
  File.open(@filename, 'w') do |file|
34
43
  @doc.write(file, indent=2)
@@ -15,7 +15,7 @@ module ComtecDR
15
15
 
16
16
  class << self
17
17
  def analyze udat
18
- udat.gsub(/[[:cntrl:]]/,"").scan(LOG_PATTERN)
18
+ udat.to_s.gsub(/[[:cntrl:]]/,"").scan(LOG_PATTERN)
19
19
  end
20
20
  end
21
21
  end
@@ -1,6 +1,6 @@
1
1
  module ComtecDR
2
2
  MAJOR = 0
3
- MINOR = 7
3
+ MINOR = 8
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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shogo Kawaguchi
@@ -56,6 +56,7 @@ description: comtec drive recorder analyzer
56
56
  email:
57
57
  - platycod0n.ramosa@gmail.com
58
58
  executables:
59
+ - comtec_csv_to_gps
59
60
  - comtec_mov_demux
60
61
  - comtec_mov_to_csv
61
62
  - comtec_mov_to_gpx
@@ -71,6 +72,7 @@ files:
71
72
  - bin/console
72
73
  - bin/setup
73
74
  - comtec-dr.gemspec
75
+ - exe/comtec_csv_to_gps
74
76
  - exe/comtec_mov_demux
75
77
  - exe/comtec_mov_to_csv
76
78
  - exe/comtec_mov_to_gpx