tf1_converter 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/example/config.csv +55 -0
- data/example/windowsconfig.csv +55 -0
- data/harness.rb +1 -1
- data/lib/tf1_converter/config.rb +44 -9
- data/lib/tf1_converter/version.rb +1 -1
- data/lib/tf1_converter.rb +3 -3
- data/spec/lib/tf1_converter/translation_spec.rb +4 -3
- metadata +5 -5
- data/example/config.yml +0 -39
- data/example/windowsconfig.yml +0 -32
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,6 @@
|
|
12
12
|
gem install tf1_converter
|
13
13
|
|
14
14
|
|
15
|
-
4) add a config file to a convenient location (see example/config.
|
15
|
+
4) add a config file to a convenient location (see example/config.csv)
|
16
16
|
|
17
17
|
5) edit the config file in WordPad or similar, make sure the paths match where your files are.
|
data/example/config.csv
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
The path of the directory where you are putting gpx files
|
2
|
+
INPUT
|
3
|
+
input
|
4
|
+
|
5
|
+
The path of the directory where you are wanting the KML files
|
6
|
+
OUTPUT
|
7
|
+
output
|
8
|
+
|
9
|
+
The full path of the directory where your icons are stored
|
10
|
+
ICON_PATH
|
11
|
+
c:\program files\gpx2kml\icon\tf_ge\
|
12
|
+
|
13
|
+
START_PATH
|
14
|
+
c:\program files\gpx2kml\test
|
15
|
+
|
16
|
+
END_PATH
|
17
|
+
c:\program files\gpx2kml\test
|
18
|
+
|
19
|
+
Table of Icons (symbol/filename/meaning/custom_name)
|
20
|
+
ICONS
|
21
|
+
Custom 0,01.png,Search Start,icon_name_1
|
22
|
+
Custom 1,02.png,Search Stop,icon_name_2
|
23
|
+
Custom 2,03.png,Victim Detected,icon_name_3
|
24
|
+
Custom 3,04.png,Victim Confirmed,icon_name_4
|
25
|
+
Custom 4,05.png,Meaning 5,icon_name_5
|
26
|
+
Custom 5,06.png,Meaning 6,icon_name_6
|
27
|
+
Custom 6,07.png,Meaning 7,icon_name_7
|
28
|
+
Custom 7,08.png,Meaning 8,icon_name_8
|
29
|
+
Custom 8,09.png,Meaning 9,icon_name_9
|
30
|
+
Custom 9,10.png,Meaning 10,icon_name_10
|
31
|
+
Custom 10,11.png,Collection Point,icon_name_11
|
32
|
+
Custom 11,12.png,Meaning 12,icon_name_12
|
33
|
+
Custom 12,13.png,Command Post,icon_name_13
|
34
|
+
Custom 13,14.png,Staging Area,icon_name_14
|
35
|
+
Custom 14,15.png,Criminal Activity,icon_name_15
|
36
|
+
Custom 15,16.png,Meaning 16,icon_name_16
|
37
|
+
Custom 16,17.png,Water Level,icon_name_17
|
38
|
+
Custom 17,18.png,Structure Damage / Safe,icon_name_18
|
39
|
+
Custom 18,19.png,Meaning 19,icon_name_19
|
40
|
+
Custom 19,20.png,Structure Not Safe,icon_name_20
|
41
|
+
Custom 20,21.png,Extra 21,icon_name_21
|
42
|
+
Custom 21,22.png,Extra 22,icon_name_22
|
43
|
+
Custom 22,23.png,Extra 23,icon_name_23
|
44
|
+
Residence,default.png,Default,icon_name_24
|
45
|
+
|
46
|
+
Table of Colors (Name/KML Hex)
|
47
|
+
COLORS
|
48
|
+
DarkRed,f0000080
|
49
|
+
Yellow,f000ffff
|
50
|
+
Blue,f0ff0000
|
51
|
+
Red,f01400ff
|
52
|
+
Orange,f014b4ff
|
53
|
+
Green,f000b414
|
54
|
+
Purple,f0ff7878
|
55
|
+
Pink,f0ff78f0
|
@@ -0,0 +1,55 @@
|
|
1
|
+
The path of the directory where you are putting gpx files
|
2
|
+
INPUT
|
3
|
+
c:\Documents and Settings\FEMA\TF1Converter\Input
|
4
|
+
|
5
|
+
The path of the directory where you are wanting the KML files
|
6
|
+
OUTPUT
|
7
|
+
c:\Documents and Settings\FEMA\TF1Converter\Output
|
8
|
+
|
9
|
+
The full path of the directory where your icons are stored
|
10
|
+
ICON_PATH
|
11
|
+
c:\program files\gpx2kml\icon\tf_ge\
|
12
|
+
|
13
|
+
START_PATH
|
14
|
+
c:\program files\gpx2kml\test
|
15
|
+
|
16
|
+
END_PATH
|
17
|
+
c:\program files\gpx2kml\test
|
18
|
+
|
19
|
+
Table of Icons (symbol/filename/meaning/custom_name)
|
20
|
+
ICONS
|
21
|
+
Custom 0,01.png,Search Start,icon_name_1
|
22
|
+
Custom 1,02.png,Search Stop,icon_name_2
|
23
|
+
Custom 2,03.png,Victim Detected,icon_name_3
|
24
|
+
Custom 3,04.png,Victim Confirmed,icon_name_4
|
25
|
+
Custom 4,05.png,Meaning 5,icon_name_5
|
26
|
+
Custom 5,06.png,Meaning 6,icon_name_6
|
27
|
+
Custom 6,07.png,Meaning 7,icon_name_7
|
28
|
+
Custom 7,08.png,Meaning 8,icon_name_8
|
29
|
+
Custom 8,09.png,Meaning 9,icon_name_9
|
30
|
+
Custom 9,10.png,Meaning 10,icon_name_10
|
31
|
+
Custom 10,11.png,Collection Point,icon_name_11
|
32
|
+
Custom 11,12.png,Meaning 12,icon_name_12
|
33
|
+
Custom 12,13.png,Command Post,icon_name_13
|
34
|
+
Custom 13,14.png,Staging Area,icon_name_14
|
35
|
+
Custom 14,15.png,Criminal Activity,icon_name_15
|
36
|
+
Custom 15,16.png,Meaning 16,icon_name_16
|
37
|
+
Custom 16,17.png,Water Level,icon_name_17
|
38
|
+
Custom 17,18.png,Structure Damage / Safe,icon_name_18
|
39
|
+
Custom 18,19.png,Meaning 19,icon_name_19
|
40
|
+
Custom 19,20.png,Structure Not Safe,icon_name_20
|
41
|
+
Custom 20,21.png,Extra 21,icon_name_21
|
42
|
+
Custom 21,22.png,Extra 22,icon_name_22
|
43
|
+
Custom 22,23.png,Extra 23,icon_name_23
|
44
|
+
Residence,default.png,Default,icon_name_24
|
45
|
+
|
46
|
+
Table of Colors (Name/KML Hex)
|
47
|
+
COLORS
|
48
|
+
DarkRed,f0000080
|
49
|
+
Yellow,f000ffff
|
50
|
+
Blue,f0ff0000
|
51
|
+
Red,f01400ff
|
52
|
+
Orange,f014b4ff
|
53
|
+
Green,f000b414
|
54
|
+
Purple,f0ff7878
|
55
|
+
Pink,f0ff78f0
|
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
|
-
TF1Converter::Config.load('example/config.
|
12
|
+
TF1Converter::Config.load('example/config.csv')
|
13
13
|
TF1Converter::Translation.from(input).into(output)
|
data/lib/tf1_converter/config.rb
CHANGED
@@ -1,22 +1,57 @@
|
|
1
|
-
require '
|
1
|
+
require 'csv'
|
2
2
|
|
3
3
|
module TF1Converter
|
4
4
|
class Config
|
5
5
|
|
6
6
|
def self.load(path)
|
7
|
-
|
7
|
+
last_key = nil
|
8
|
+
current_control = nil
|
9
|
+
CSV.read(path).each do |row|
|
10
|
+
if last_key == 'INPUT'
|
11
|
+
@input = row[0]
|
12
|
+
elsif last_key == 'OUTPUT'
|
13
|
+
@output = row[0]
|
14
|
+
elsif last_key == 'ICON_PATH'
|
15
|
+
@icon_path = row[0]
|
16
|
+
elsif last_key == 'START_PATH'
|
17
|
+
@start_path = row[0]
|
18
|
+
elsif last_key == 'END_PATH'
|
19
|
+
@end_path = row[0]
|
20
|
+
elsif last_key == 'ICONS'
|
21
|
+
@icons = {}
|
22
|
+
current_control = 'ICONS'
|
23
|
+
elsif last_key == 'COLORS'
|
24
|
+
@colors = {}
|
25
|
+
current_control = 'COLORS'
|
26
|
+
end
|
27
|
+
|
28
|
+
if current_control == 'ICONS'
|
29
|
+
if row.empty?
|
30
|
+
current_control = nil
|
31
|
+
else
|
32
|
+
@icons[row[0]] = {
|
33
|
+
'icon' => row[1],
|
34
|
+
'meaning' => row[2],
|
35
|
+
'name' => row[3]
|
36
|
+
}
|
37
|
+
end
|
38
|
+
elsif current_control == 'COLORS'
|
39
|
+
if row.empty?
|
40
|
+
current_control = nil
|
41
|
+
else
|
42
|
+
@colors[row[0]] = row[1]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
last_key = row[0]
|
47
|
+
end
|
8
48
|
end
|
9
49
|
|
10
50
|
%w(icon_path start_path end_path icons colors input output).each do |name|
|
11
51
|
define_singleton_method(name.to_sym) do
|
12
|
-
|
52
|
+
instance_variable_get("@#{name}")
|
13
53
|
end
|
14
54
|
end
|
15
55
|
|
16
|
-
private
|
17
|
-
def self.config
|
18
|
-
raise "NO CONFIG LOADED" unless @config
|
19
|
-
@config['tf1_converter']
|
20
|
-
end
|
21
56
|
end
|
22
|
-
end
|
57
|
+
end
|
data/lib/tf1_converter.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative 'tf1_converter/config'
|
2
|
+
require_relative 'tf1_converter/version'
|
3
|
+
require_relative 'tf1_converter/translation'
|
@@ -14,12 +14,13 @@ module TF1Converter
|
|
14
14
|
|
15
15
|
let(:local_dir) { File.dirname(__FILE__) }
|
16
16
|
let(:path) { File.expand_path('../../fixtures', local_dir) }
|
17
|
+
let(:config_file) { File.expand_path('../../../example/config.csv', local_dir) }
|
17
18
|
|
18
19
|
it "translates a file correctly" do
|
19
20
|
input = File.open("#{path}/test.gpx", 'r')
|
20
21
|
output = File.open("#{path}/test.kml", 'w')
|
21
22
|
expected = File.open("#{path}/expected.kml", 'r')
|
22
|
-
TF1Converter::Config.load(
|
23
|
+
TF1Converter::Config.load(config_file)
|
23
24
|
TF1Converter::Translation.from(input).into(output)
|
24
25
|
|
25
26
|
result = File.open("#{path}/test.kml", 'r')
|
@@ -29,7 +30,7 @@ module TF1Converter
|
|
29
30
|
it 'translates a tracks-only file' do
|
30
31
|
input = File.open("#{path}/ftwood2.gpx", 'r')
|
31
32
|
output = File.open("#{path}/ftwood2.kml", 'w')
|
32
|
-
TF1Converter::Config.load(
|
33
|
+
TF1Converter::Config.load(config_file)
|
33
34
|
#should not raise error
|
34
35
|
TF1Converter::Translation.from(input).into(output)
|
35
36
|
end
|
@@ -37,7 +38,7 @@ module TF1Converter
|
|
37
38
|
it 'translates waypoints by name' do
|
38
39
|
input = File.open("#{path}/waypoint-by-name.gpx", 'r')
|
39
40
|
output = File.open("#{path}/waypoint-by-name.kml", 'w')
|
40
|
-
TF1Converter::Config.load(
|
41
|
+
TF1Converter::Config.load(config_file)
|
41
42
|
TF1Converter::Translation.from(input).into(output)
|
42
43
|
result = File.open("#{path}/waypoint-by-name.kml", 'r')
|
43
44
|
result.read.should_not =~ /default\.png/
|
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.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -154,8 +154,8 @@ files:
|
|
154
154
|
- README.md
|
155
155
|
- Rakefile
|
156
156
|
- bin/tf1convert
|
157
|
-
- example/config.
|
158
|
-
- example/windowsconfig.
|
157
|
+
- example/config.csv
|
158
|
+
- example/windowsconfig.csv
|
159
159
|
- harness.rb
|
160
160
|
- input/test.gpx
|
161
161
|
- lib/tf1_converter.rb
|
@@ -192,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
192
|
version: '0'
|
193
193
|
segments:
|
194
194
|
- 0
|
195
|
-
hash:
|
195
|
+
hash: 2030161569308600368
|
196
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
197
|
none: false
|
198
198
|
requirements:
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
segments:
|
203
203
|
- 0
|
204
|
-
hash:
|
204
|
+
hash: 2030161569308600368
|
205
205
|
requirements: []
|
206
206
|
rubyforge_project:
|
207
207
|
rubygems_version: 1.8.23
|
data/example/config.yml
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
tf1_converter:
|
2
|
-
input: input
|
3
|
-
output: output
|
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, name: icon_name_1 },
|
8
|
-
Custom 1: { icon: 02.png, meaning: Search Stop, name: icon_name_2 },
|
9
|
-
Custom 2: { icon: 03.png, meaning: Victim Detected, name: icon_name_3},
|
10
|
-
Custom 3: { icon: 04.png, meaning: Victim Confirmed, name: icon_name_4},
|
11
|
-
Custom 4: { icon: 05.png, meaning: Meaning 5, name: icon_name_5},
|
12
|
-
Custom 5: { icon: 06.png, meaning: Meaning 6, name: icon_name_6},
|
13
|
-
Custom 6: { icon: 07.png, meaning: Meaning 7, name: icon_name_7},
|
14
|
-
Custom 7: { icon: 08.png, meaning: Meaning 8, name: icon_name_8},
|
15
|
-
Custom 8: { icon: 09.png, meaning: Meaning 9, name: icon_name_9},
|
16
|
-
Custom 9: { icon: 10.png, meaning: Meaning 10, name: icon_name_10},
|
17
|
-
Custom 10: { icon: 11.png, meaning: Collection Point , name: icon_name_11},
|
18
|
-
Custom 11: { icon: 12.png, meaning: Meaning 12, name: icon_name_12},
|
19
|
-
Custom 12: { icon: 13.png, meaning: Command Post, name: icon_name_13 },
|
20
|
-
Custom 13: { icon: 14.png, meaning: Staging Area, name: icon_name_14 },
|
21
|
-
Custom 14: { icon: 15.png, meaning: Criminal Activity, name: icon_name_15 },
|
22
|
-
Custom 15: { icon: 16.png, meaning: Meaning 16, name: icon_name_16 },
|
23
|
-
Custom 16: { icon: 17.png, meaning: Water Level, name: icon_name_17 },
|
24
|
-
Custom 17: { icon: 18.png, meaning: Structure Damage / Safe, name: icon_name_18 },
|
25
|
-
Custom 18: { icon: 19.png, meaning: Meaning 19, name: icon_name_19 },
|
26
|
-
Custom 19: { icon: 20.png, meaning: Structure Not Safe, name: icon_name_20 },
|
27
|
-
Custom 20: { icon: 21.png, meaning: Extra 21, name: icon_name_21 },
|
28
|
-
Custom 21: { icon: 22.png, meaning: Extra 22, name: icon_name_22 },
|
29
|
-
Custom 22: { icon: 23.png, meaning: Extra 23, name: icon_name_23 },
|
30
|
-
Residence: { icon: default.png, meaning: Default, name: icon_name_24 } }
|
31
|
-
colors: { DarkRed: f0000080,
|
32
|
-
Yellow: f000ffff,
|
33
|
-
Blue: f0ff0000,
|
34
|
-
Red: f01400ff,
|
35
|
-
Orange: f014b4ff,
|
36
|
-
Green: f000b414,
|
37
|
-
Purple: f0ff7878,
|
38
|
-
Pink: f0ff78f0 }
|
39
|
-
|
data/example/windowsconfig.yml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
tf1_converter:
|
2
|
-
input: c:\Documents and Settings\FEMA\TF1Converter\Input
|
3
|
-
output: c:\Documents and Settings\FEMA\TF1Converter\Output
|
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, name: name1 },
|
8
|
-
Custom 1: { icon: 02.png, meaning: Search Stop, name: name2},
|
9
|
-
Custom 2: { icon: 03.png, meaning: Victim Detected, name: name3},
|
10
|
-
Custom 3: { icon: 04.png, meaning: Victim Confirmed, name: name4},
|
11
|
-
Custom 4: { icon: 05.png, meaning: Meaning 5, name: name5},
|
12
|
-
Custom 5: { icon: 06.png, meaning: Meaning 6, name: name6},
|
13
|
-
Custom 6: { icon: 07.png, meaning: Meaning 7, name: name7},
|
14
|
-
Custom 7: { icon: 08.png, meaning: Meaning 8, name: name8},
|
15
|
-
Custom 8: { icon: 09.png, meaning: Meaning 9, name: name9},
|
16
|
-
Custom 9: { icon: 10.png, meaning: Meaning 10, name: name10},
|
17
|
-
Custom 10: { icon: 11.png, meaning: Collection Point, name: name11 },
|
18
|
-
Custom 11: { icon: 12.png, meaning: Meaning 12, name: name12},
|
19
|
-
Custom 12: { icon: 13.png, meaning: Command Post, name: name13 },
|
20
|
-
Custom 13: { icon: 14.png, meaning: Staging Area, name: name14},
|
21
|
-
Custom 14: { icon: 15.png, meaning: Criminal Activity, name: name15 },
|
22
|
-
Custom 15: { icon: 16.png, meaning: Meaning 16, name: name16},
|
23
|
-
Custom 16: { icon: 17.png, meaning: Water Level, name: name17},
|
24
|
-
Custom 17: { icon: 18.png, meaning: Structure Damage / Safe, name: name18 },
|
25
|
-
Custom 18: { icon: 19.png, meaning: Meaning 19, name: name19},
|
26
|
-
Custom 19: { icon: 20.png, meaning: Structure Not Safe, name: name20 },
|
27
|
-
Custom 20: { icon: 21.png, meaning: Extra 21, name: name21 },
|
28
|
-
Custom 21: { icon: 22.png, meaning: Extra 22, name: name22 },
|
29
|
-
Custom 22: { icon: 23.png, meaning: Extra 23, name: name23},
|
30
|
-
Residence: { icon: default.png, meaning: Default, name: name24 } }
|
31
|
-
colors: { DarkRed: f0000080,
|
32
|
-
Yellow: f000ffff }
|