columbus_cli 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/columbus_cli.rb +19 -0
- data/lib/columbus_cli/track.rb +45 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fa611c35dd118713f57bb829db0ca5e2591f4f08
|
4
|
+
data.tar.gz: 0f866822dd5addbd8050cbe1d6af76e65cdaf8b4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4055d9700641d0a49f30870b842ca8ce1c32b44f837d2587f8627f1ee9ada302679ff927a3c24165e577b54df3987548c358e4465e2e021641d4320d050a63b
|
7
|
+
data.tar.gz: 2761afe40c6e75892eb100390ae10a197ab3695e7baa4d07ecfbff8c89e569a0b9a587d181582bd7ab3875ab41b4189cdf9fa6221fb66d137450535d5248677a
|
data/lib/columbus_cli.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
class ColumbusCli < Thor
|
4
|
+
|
5
|
+
desc 'csv2gpx CSV_FILE', 'Convert a CSV file created by a Columbus Tracklogger to GPX'
|
6
|
+
option :output, desc: 'Output file', required: true
|
7
|
+
def csv2gpx(csv_file)
|
8
|
+
puts "Converting #{csv_file} to #{options[:output]}..."
|
9
|
+
|
10
|
+
track = Track.new File.expand_path(csv_file)
|
11
|
+
gpx = GPX::GPXFile.new tracks: [track.to_gpx]
|
12
|
+
gpx.write(File.expand_path(options[:output]))
|
13
|
+
|
14
|
+
puts "Conversion complete"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'columbus_cli/track.rb'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'gpx'
|
2
|
+
|
3
|
+
class ColumbusCli::Track
|
4
|
+
|
5
|
+
def initialize(file)
|
6
|
+
@points = []
|
7
|
+
CSV.foreach(file, headers: true) do |p|
|
8
|
+
tag = p["TAG"]
|
9
|
+
|
10
|
+
date = "20#{p['DATE'].scan(/../).join('-')}"
|
11
|
+
time = "#{p['TIME'].length == 6 ? p['TIME'] : '0' + p['TIME']}".scan(/../).join(':')
|
12
|
+
|
13
|
+
ts = Time.parse "#{date}T#{time}"
|
14
|
+
lat = parse_lat p["LATITUDE N/S"]
|
15
|
+
lon = parse_lon p["LONGITUDE E/W"]
|
16
|
+
speed = p["SPEED"].to_i
|
17
|
+
alt = p["HEIGHT"].to_i
|
18
|
+
@points << { time: ts, lat: lat, lon: lon, speed: speed, elevation: alt, waypoint: (tag == 'C') }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_gpx
|
23
|
+
segment = GPX::Segment.new
|
24
|
+
@points.each do |p|
|
25
|
+
point = GPX::TrackPoint.new(p)
|
26
|
+
segment.append_point point
|
27
|
+
end
|
28
|
+
|
29
|
+
track = GPX::Track.new
|
30
|
+
track.append_segment segment
|
31
|
+
|
32
|
+
track
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def parse_lat str
|
38
|
+
str[-1] == 'N' ? str.to_f : -str.to_f
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_lon str
|
42
|
+
str[-1] == 'E' ? str.to_f : -str.to_f
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: columbus_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Ciaghi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Tools to use with Columbus Trackloggers
|
14
|
+
email: aaron.ciaghi@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/columbus_cli.rb
|
20
|
+
- lib/columbus_cli/track.rb
|
21
|
+
homepage:
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.4.5.1
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Columbus CLI
|
45
|
+
test_files: []
|