tf1_converter 0.0.1 → 0.1.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.
data/.gitignore CHANGED
@@ -1,2 +1,4 @@
1
1
  *.swp
2
2
  *.DS_Store
3
+ pkg/*
4
+ output/*
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tf1_converter (0.0.1)
4
+ tf1_converter (0.1.0)
5
5
  builder
6
6
  geo_swap (= 0.2.0)
7
7
  nokogiri
data/bin/tf1convert ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'tf1_converter'
4
+
5
+ config_file = ARGV[0]
6
+ TF1Converter::Config.load(config_file)
7
+
8
+ input = File.open(TF1Converter::Config.input, 'r')
9
+ output = File.open(TF1Converter::Config.output, 'w')
10
+ TF1Converter::Translation.from(input).into(output)
@@ -0,0 +1,32 @@
1
+ tf1_converter:
2
+ input: input/test.gpx
3
+ output: output/test.kml
4
+ icon_path: c:\program files\gpx2kml\icon\tf_ge\
5
+ start_path: c:\program files\gpx2kml\test
6
+ end_path: c:\program files\gpx2kml\test
7
+ icons: { Custom 0: { icon: 01.png, meaning: Search Start },
8
+ Custom 1: { icon: 02.png, meaning: Search Stop},
9
+ Custom 2: { icon: 03.png, meaning: Victim Detected},
10
+ Custom 3: { icon: 04.png, meaning: Victim Confirmed},
11
+ Custom 4: { icon: 05.png, meaning: Meaning 5},
12
+ Custom 5: { icon: 06.png, meaning: Meaning 6},
13
+ Custom 6: { icon: 07.png, meaning: Meaning 7},
14
+ Custom 7: { icon: 08.png, meaning: Meaning 8},
15
+ Custom 8: { icon: 09.png, meaning: Meaning 9},
16
+ Custom 9: { icon: 10.png, meaning: Meaning 10},
17
+ Custom 10: { icon: 11.png, meaning: Collection Point },
18
+ Custom 11: { icon: 12.png, meaning: Meaning 12},
19
+ Custom 12: { icon: 13.png, meaning: Command Post },
20
+ Custom 13: { icon: 14.png, meaning: Staging Area},
21
+ Custom 14: { icon: 15.png, meaning: Criminal Activity },
22
+ Custom 15: { icon: 16.png, meaning: Meaning 16},
23
+ Custom 16: { icon: 17.png, meaning: Water Level},
24
+ Custom 17: { icon: 18.png, meaning: Structure Damage / Safe },
25
+ Custom 18: { icon: 19.png, meaning: Meaning 19},
26
+ Custom 19: { icon: 20.png, meaning: Structure Not Safe },
27
+ Custom 20: { icon: 21.png, meaning: Extra 21 },
28
+ Custom 21: { icon: 22.png, meaning: Extra 22 },
29
+ Custom 22: { icon: 23.png, meaning: Extra 23},
30
+ Residence: { icon: default.png, meaning: Default } }
31
+ colors: { DarkRed: f0000080,
32
+ Yellow: f000ffff }
data/harness.rb CHANGED
@@ -9,5 +9,5 @@ require_relative './lib/tf1_converter'
9
9
 
10
10
  input = File.open('input/test.gpx', 'r')
11
11
  output = File.open('output/test.kml', 'w')
12
-
12
+ TF1Converter::Config.load('example/config.yml')
13
13
  TF1Converter::Translation.from(input).into(output)
@@ -0,0 +1,22 @@
1
+ require 'yaml'
2
+
3
+ module TF1Converter
4
+ class Config
5
+
6
+ def self.load(path)
7
+ @config = YAML.load(File.open(path, 'r'))
8
+ end
9
+
10
+ %w(icon_path start_path end_path icons colors input output).each do |name|
11
+ define_singleton_method(name.to_sym) do
12
+ config[name]
13
+ end
14
+ end
15
+
16
+ private
17
+ def self.config
18
+ raise "NO CONFIG LOADED" unless @config
19
+ @config['tf1_converter']
20
+ end
21
+ end
22
+ end
@@ -19,12 +19,8 @@ module TF1Converter
19
19
  output_file.close
20
20
  end
21
21
 
22
- #TODO: Config file
23
- ICON_PATH = "c:\\program files\\gpx2kml\\icon\\tf_ge\\"
24
- START_PATH = "c:\\program files\\gpx2kml\\test"
25
- END_PATH = "c:\\program files\\gpx2kml\\test"
26
-
27
22
  def build_kml_from(gpx)
23
+ icon_path = Config.icon_path
28
24
  Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
29
25
  xml.kml('xmlns' => 'http://www.opengis.net/kml/2.2') do
30
26
  xml.Document do
@@ -47,7 +43,7 @@ module TF1Converter
47
43
  xml.IconStyle do
48
44
  xml.Icon do
49
45
  #TODO: put this path in a config file
50
- xml.href("#{ICON_PATH}#{icon_name_for(waypoint)}")
46
+ xml.href("#{icon_path}#{icon_name_for(waypoint)}")
51
47
  end
52
48
  end
53
49
  end
@@ -100,37 +96,9 @@ module TF1Converter
100
96
  end
101
97
  end
102
98
 
103
- #TODO: put this in a yml file
104
- DATA_MAPPING = {
105
- 'Custom 0' => { icon: '01.png', meaning: 'Search Start' },
106
- 'Custom 1' => { icon: '02.png', meaning: 'Search Stop'},
107
- 'Custom 2' => { icon: '03.png', meaning: 'Victim Detected'},
108
- 'Custom 3' => { icon: '04.png', meaning: 'Victim Confirmed'},
109
- 'Custom 4' => { icon: '05.png', meaning: 'Meaning 5'},
110
- 'Custom 5' => { icon: '06.png', meaning: 'Meaning 6'},
111
- 'Custom 6' => { icon: '07.png', meaning: 'Meaning 7'},
112
- 'Custom 7' => { icon: '08.png', meaning: 'Meaning 8'},
113
- 'Custom 8' => { icon: '09.png', meaning: 'Meaning 9'},
114
- 'Custom 9' => { icon: '10.png', meaning: 'Meaning 10'},
115
- 'Custom 10' => { icon: '11.png', meaning: 'Collection Point' },
116
- 'Custom 11' => { icon: '12.png', meaning: 'Meaning 12'},
117
- 'Custom 12' => { icon: '13.png', meaning: 'Command Post' },
118
- 'Custom 13' => { icon: '14.png', meaning: 'Staging Area'},
119
- 'Custom 14' => { icon: '15.png', meaning: 'Criminal Activity' },
120
- 'Custom 15' => { icon: '16.png', meaning: 'Meaning 16'},
121
- 'Custom 16' => { icon: '17.png', meaning: 'Water Level'},
122
- 'Custom 17' => { icon: '18.png', meaning: 'Structure Damage / Safe' },
123
- 'Custom 18' => { icon: '19.png', meaning: 'Meaning 19'},
124
- 'Custom 19' => { icon: '20.png', meaning: 'Structure Not Safe' },
125
- 'Custom 20' => { icon: '21.png', meaning: 'Extra 21' },
126
- 'Custom 21' => { icon: '22.png', meaning: 'Extra 22' },
127
- 'Custom 22' => { icon: '23.png', meaning: 'Extra 23'},
128
- 'Residence' => { icon: 'default.png', meaning: 'Default' },
129
- }
130
-
131
99
  def icon_name_for(waypoint)
132
100
  sym = field_for(waypoint, 'sym')
133
- DATA_MAPPING[sym][:icon]
101
+ Config.icons[sym]['icon']
134
102
  end
135
103
 
136
104
  def description_for(waypoint, lat, long)
@@ -138,20 +106,15 @@ module TF1Converter
138
106
  usng = GeoSwap.utm_to_usng(utm.easting, utm.northing, utm.zone.number, utm.zone.letter)
139
107
  desc = ""
140
108
  desc << field_for(waypoint, 'cmt')
141
- desc << '<br>' << DATA_MAPPING[field_for(waypoint, 'sym')][:meaning]
109
+ desc << '<br>' << Config.icons[field_for(waypoint, 'sym')]['meaning']
142
110
  desc << '<br>' << "KML file, track, and waypoint comment."
143
111
  desc << "<br>" << "USNG: #{usng}"
144
112
  desc << "<br>" << "UTM: #{utm.to_s}"
145
- desc << "<br>" << "#{START_PATH} - #{END_PATH}"
113
+ desc << "<br>" << "#{Config.start_path} - #{Config.end_path}"
146
114
  end
147
115
 
148
- COLOR_MAP = {
149
- 'DarkRed' => 'f0000080',
150
- 'Yellow' => 'f000ffff'
151
- }
152
-
153
116
  def color_for(color)
154
- COLOR_MAP[color]
117
+ Config.colors[color]
155
118
  end
156
119
 
157
120
  def coordinates_for(track)
@@ -1,3 +1,3 @@
1
1
  module TF1Converter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/tf1_converter.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'tf1_converter/config'
1
2
  require 'tf1_converter/version'
2
3
  require 'tf1_converter/translation'
3
4
  require 'tf1_converter/waypoint'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tf1_converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -126,7 +126,8 @@ dependencies:
126
126
  description: A GPX to KML converter for Missouri Task Force 1
127
127
  email:
128
128
  - ethan.vizitei@gmail.com
129
- executables: []
129
+ executables:
130
+ - tf1convert
130
131
  extensions: []
131
132
  extra_rdoc_files: []
132
133
  files:
@@ -135,9 +136,12 @@ files:
135
136
  - Gemfile
136
137
  - Gemfile.lock
137
138
  - Rakefile
139
+ - bin/tf1convert
140
+ - example/config.yml
138
141
  - harness.rb
139
142
  - input/test.gpx
140
143
  - lib/tf1_converter.rb
144
+ - lib/tf1_converter/config.rb
141
145
  - lib/tf1_converter/translation.rb
142
146
  - lib/tf1_converter/version.rb
143
147
  - lib/tf1_converter/waypoint.rb
@@ -160,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
164
  version: '0'
161
165
  segments:
162
166
  - 0
163
- hash: 4230483580213494511
167
+ hash: 4218751711993075820
164
168
  required_rubygems_version: !ruby/object:Gem::Requirement
165
169
  none: false
166
170
  requirements:
@@ -169,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
173
  version: '0'
170
174
  segments:
171
175
  - 0
172
- hash: 4230483580213494511
176
+ hash: 4218751711993075820
173
177
  requirements: []
174
178
  rubyforge_project:
175
179
  rubygems_version: 1.8.23