open_gpx_2_kml 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- open_gpx_2_kml (0.9.2)
4
+ open_gpx_2_kml (0.10.0)
5
5
  builder (= 3.1.4)
6
6
  geo_swap (= 0.2.1)
7
7
  nokogiri (= 1.5.6)
data/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  3) install the converter by running this at the command prompt:
11
11
 
12
- gem install tf1_converter
12
+ gem install open_gpx_2_kml
13
13
 
14
14
 
15
15
  4) add a config file to a convenient location (see example/config.csv)
data/bin/openGpx2Kml CHANGED
@@ -8,7 +8,7 @@ input_path = TF1Converter::Config.input
8
8
  output_path = TF1Converter::Config.output
9
9
 
10
10
  Dir.foreach(input_path) do |file|
11
- unless ['.', '..'].include? file
11
+ if TF1Converter::Translation.can_translate?(file)
12
12
  input = File.open("#{input_path}/#{file}", 'r')
13
13
  outfile = file.gsub(/\.gpx$/, '.kml')
14
14
  output = File.open("#{output_path}/#{outfile}", 'w')
data/example/config.csv CHANGED
@@ -12,30 +12,30 @@ ICON_PATH
12
12
 
13
13
  Table of Icons (symbol/filename/meaning/custom_name)
14
14
  ICONS
15
- Custom 0,01.png,Search Start,icon_name_1
16
- Custom 1,02.png,Search Stop,icon_name_2
17
- Custom 2,03.png,Victim Detected,icon_name_3
18
- Custom 3,04.png,Victim Confirmed,icon_name_4
19
- Custom 4,05.png,Meaning 5,icon_name_5
20
- Custom 5,06.png,Meaning 6,icon_name_6
21
- Custom 6,07.png,Meaning 7,icon_name_7
22
- Custom 7,08.png,Meaning 8,icon_name_8
23
- Custom 8,09.png,Meaning 9,icon_name_9
24
- Custom 9,10.png,Meaning 10,icon_name_10
25
- Custom 10,11.png,Collection Point,icon_name_11
26
- Custom 11,12.png,Meaning 12,icon_name_12
27
- Custom 12,13.png,Command Post,icon_name_13
28
- Custom 13,14.png,Staging Area,icon_name_14
29
- Custom 14,15.png,Criminal Activity,icon_name_15
30
- Custom 15,16.png,Meaning 16,icon_name_16
31
- Custom 16,17.png,Water Level,icon_name_17
32
- Custom 17,18.png,Structure Damage / Safe,icon_name_18
33
- Custom 18,19.png,Meaning 19,icon_name_19
34
- Custom 19,20.png,Structure Not Safe,icon_name_20
35
- Custom 20,21.png,Extra 21,icon_name_21
36
- Custom 21,22.png,Extra 22,icon_name_22
37
- Custom 22,23.png,Extra 23,icon_name_23
38
- Residence,default.png,Default,icon_name_24
15
+ Custom 0,01.png,Search Start,C01
16
+ Custom 1,02.png,Search Stop,C02
17
+ Custom 2,03.png,Victim Detected,C03
18
+ Custom 3,04.png,Victim Confirmed,C04
19
+ Custom 4,05.png,Meaning 5,C05
20
+ Custom 5,06.png,Meaning 6,C06
21
+ Custom 6,07.png,Meaning 7,C07
22
+ Custom 7,08.png,Meaning 8,C08
23
+ Custom 8,09.png,Meaning 9,C09
24
+ Custom 9,10.png,Meaning 10,C10
25
+ Custom 10,11.png,Collection Point,C11
26
+ Custom 11,12.png,Meaning 12,C12
27
+ Custom 12,13.png,Command Post,C13
28
+ Custom 13,14.png,Staging Area,C14
29
+ Custom 14,15.png,Criminal Activity,C15
30
+ Custom 15,16.png,Meaning 16,C16
31
+ Custom 16,17.png,Water Level,C17
32
+ Custom 17,18.png,Structure Damage / Safe,C18
33
+ Custom 18,19.png,Meaning 19,C19
34
+ Custom 19,20.png,Structure Not Safe,C20
35
+ Custom 20,21.png,Extra 21,C21
36
+ Custom 21,22.png,Extra 22,C22
37
+ Custom 22,23.png,Extra 23,C23
38
+ Residence,default.png,Default,C24
39
39
 
40
40
  Table of Colors (Name/KML Hex)
41
41
  COLORS
@@ -45,7 +45,7 @@ module TF1Converter
45
45
  end
46
46
  end
47
47
 
48
- last_key = row[0]
48
+ last_key = row[0] ? row[0].upcase : nil
49
49
  end
50
50
  end
51
51
 
@@ -17,7 +17,7 @@ module TF1Converter
17
17
  return map_entry['icon'] if map_entry
18
18
  elsif name
19
19
  @icon_map.values.each do |icon_data|
20
- return icon_data['icon'] if icon_data['name'] == name
20
+ return icon_data['icon'] if icon_data['name'].upcase == name.slice(0,3).upcase
21
21
  end
22
22
  end
23
23
  'default.png'
@@ -1,18 +1,19 @@
1
1
  module TF1Converter::Kml
2
2
  class TrackColor
3
3
  def self.next
4
- if config.use_constant_color
4
+ return_color = if config.use_constant_color
5
5
  config.constant_color
6
6
  else
7
7
  @colors ||= config.colors.values
8
8
  @color_index ||= 0
9
- return_color = @colors[@color_index]
9
+ rc = @colors[@color_index]
10
10
  @color_index += 1
11
11
  if @color_index >= @colors.length
12
12
  @color_index = 0
13
13
  end
14
- return_color
14
+ rc
15
15
  end
16
+ return_color.rjust(8, '0')
16
17
  end
17
18
 
18
19
  def self.uncache!
@@ -11,6 +11,10 @@ module TF1Converter
11
11
  new(file)
12
12
  end
13
13
 
14
+ def self.can_translate?(filename)
15
+ filename =~ /\.gpx$/
16
+ end
17
+
14
18
  def initialize(gpx_file)
15
19
  @filename = File.basename(gpx_file.path).split('.').first
16
20
  parsed_gpx = Nokogiri::XML(gpx_file)
@@ -1,3 +1,3 @@
1
1
  module TF1Converter
2
- VERSION = "0.9.2"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -11,7 +11,7 @@
11
11
 
12
12
  <wpt lat="38.9199972" lon="-92.2972443">
13
13
  <ele>159.7036133</ele>
14
- <name>icon_name_1</name>
14
+ <name>C01_some_icon_name</name>
15
15
  <cmt>18-OCT-09 2:17:38PM</cmt>
16
16
  <desc>18-OCT-09 2:17:38PM</desc>
17
17
  <extensions>
@@ -23,7 +23,7 @@
23
23
 
24
24
  <wpt lat="38.9197762" lon="-92.2969611">
25
25
  <ele>206.8077393</ele>
26
- <name>icon_name_3</name>
26
+ <name>C03_some_icon_name</name>
27
27
  <cmt>18-OCT-09 2:18:07PM</cmt>
28
28
  <desc>18-OCT-09 2:18:07PM</desc>
29
29
  <extensions>
@@ -35,7 +35,7 @@
35
35
 
36
36
  <wpt lat="38.9195040" lon="-92.2971813">
37
37
  <ele>228.6776123</ele>
38
- <name>icon_name_4</name>
38
+ <name>C04_some_icon_name</name>
39
39
  <cmt>18-OCT-09 2:18:36PM</cmt>
40
40
  <desc>18-OCT-09 2:18:36PM</desc>
41
41
  <extensions>
@@ -47,7 +47,7 @@
47
47
 
48
48
  <wpt lat="38.9191455" lon="-92.2977024">
49
49
  <ele>230.8405762</ele>
50
- <name>icon_name_11</name>
50
+ <name>C11_some_icon_name</name>
51
51
  <cmt>18-OCT-09 2:19:49PM</cmt>
52
52
  <desc>18-OCT-09 2:19:49PM</desc>
53
53
  <extensions>
@@ -59,7 +59,7 @@
59
59
 
60
60
  <wpt lat="38.9191831" lon="-92.2973642">
61
61
  <ele>234.6857910</ele>
62
- <name>icon_name_18</name>
62
+ <name>C18_some_icon_name</name>
63
63
  <cmt>18-OCT-09 2:20:33PM</cmt>
64
64
  <desc>18-OCT-09 2:20:33PM</desc>
65
65
  <extensions>
@@ -71,7 +71,7 @@
71
71
 
72
72
  <wpt lat="38.9196337" lon="-92.2967348">
73
73
  <ele>237.3294678</ele>
74
- <name>icon_name_15</name>
74
+ <name>C15_icon_name</name>
75
75
  <cmt>18-OCT-09 2:21:40PM</cmt>
76
76
  <desc>18-OCT-09 2:21:40PM</desc>
77
77
  <extensions>
@@ -83,7 +83,7 @@
83
83
 
84
84
  <wpt lat="38.9193832" lon="-92.2963225">
85
85
  <ele>239.7326660</ele>
86
- <name>icon_name_13</name>
86
+ <name>C13_icon_name</name>
87
87
  <cmt>18-OCT-09 2:22:29PM</cmt>
88
88
  <desc>18-OCT-09 2:22:29PM</desc>
89
89
  <extensions>
@@ -95,7 +95,7 @@
95
95
 
96
96
  <wpt lat="38.9192829" lon="-92.2959630">
97
97
  <ele>239.9730225</ele>
98
- <name>icon_name_14</name>
98
+ <name>C14_icon_name</name>
99
99
  <cmt>18-OCT-09 2:23:14PM</cmt>
100
100
  <desc>18-OCT-09 2:23:14PM</desc>
101
101
  <extensions>
@@ -107,7 +107,7 @@
107
107
 
108
108
  <wpt lat="38.9196773" lon="-92.2965171">
109
109
  <ele>238.5311279</ele>
110
- <name>icon_name_19</name>
110
+ <name>C19_icon_name</name>
111
111
  <cmt>18-OCT-09 2:24:06PM</cmt>
112
112
  <desc>18-OCT-09 2:24:06PM</desc>
113
113
  <extensions>
@@ -119,7 +119,7 @@
119
119
 
120
120
  <wpt lat="38.9202020" lon="-92.2973907">
121
121
  <ele>237.5697021</ele>
122
- <name>icon_name_16</name>
122
+ <name>C16_icon_name</name>
123
123
  <cmt>18-OCT-09 2:25:24PM</cmt>
124
124
  <desc>18-OCT-09 2:25:24PM</desc>
125
125
  <extensions>
@@ -131,7 +131,7 @@
131
131
 
132
132
  <wpt lat="38.9207150" lon="-92.2972759">
133
133
  <ele>236.1278076</ele>
134
- <name>icon_name_21</name>
134
+ <name>C21_icon_name</name>
135
135
  <cmt>18-OCT-09 2:26:20PM</cmt>
136
136
  <desc>18-OCT-09 2:26:20PM</desc>
137
137
  <extensions>
@@ -143,7 +143,7 @@
143
143
 
144
144
  <wpt lat="38.9208083" lon="-92.2974574">
145
145
  <ele>234.9260254</ele>
146
- <name>icon_name_22</name>
146
+ <name>C22_icon_name</name>
147
147
  <cmt>18-OCT-09 2:26:40PM</cmt>
148
148
  <desc>18-OCT-09 2:26:40PM</desc>
149
149
  <extensions>
@@ -155,7 +155,7 @@
155
155
 
156
156
  <wpt lat="38.9205154" lon="-92.2977240">
157
157
  <ele>235.6469727</ele>
158
- <name>icon_name_23</name>
158
+ <name>C23_icon_name</name>
159
159
  <cmt>18-OCT-09 2:27:10PM</cmt>
160
160
  <desc>18-OCT-09 2:27:10PM</desc>
161
161
  <extensions>
@@ -167,7 +167,7 @@
167
167
 
168
168
  <wpt lat="38.9201116" lon="-92.2983951">
169
169
  <ele>234.6857910</ele>
170
- <name>icon_name_2</name>
170
+ <name>C02_icon_name</name>
171
171
  <cmt>18-OCT-09 2:29:16PM</cmt>
172
172
  <desc>18-OCT-09 2:29:16PM</desc>
173
173
  <extensions>
@@ -179,7 +179,7 @@
179
179
 
180
180
  <wpt lat="38.9200473" lon="-92.2983507">
181
181
  <ele>235.8873291</ele>
182
- <name>icon_name_20</name>
182
+ <name>C20_icon_name</name>
183
183
  <cmt>Weber Home</cmt>
184
184
  <desc>Weber Home</desc>
185
185
  <extensions>
@@ -11,7 +11,7 @@ module TF1Converter::Gpx
11
11
  let(:waypoint_by_name_fragment) do
12
12
  %Q{
13
13
  <wpt lat="38.9199972" lon="-92.2972443">
14
- <name>icon_name_42</name>
14
+ <name>C05icon_name_42</name>
15
15
  </wpt>
16
16
  }
17
17
  end
@@ -34,7 +34,7 @@ module TF1Converter::Gpx
34
34
 
35
35
  it 'can find a waypoint by name' do
36
36
  waypoint = waypoint_from(waypoint_by_name_fragment)
37
- icon_map['meaningoflife'] = { 'icon' => '42.png', 'name' => 'icon_name_42' }
37
+ icon_map['meaningoflife'] = { 'icon' => '42.png', 'name' => 'C05' }
38
38
  waypoint.icon_name.should == '42.png'
39
39
  end
40
40
 
@@ -3,6 +3,8 @@ require_relative '../../../../lib/tf1_converter/kml/track_color'
3
3
 
4
4
  module TF1Converter::Kml
5
5
  describe TrackColor do
6
+ let(:colors) { [nil, nil].map{|n| TrackColor.next } }
7
+
6
8
  before(:each) do
7
9
  ::TF1Converter::Config.stub(:colors){ {'Blue'=>'1', 'Red'=>'2', 'Yellow'=>'3'}}
8
10
  end
@@ -12,18 +14,33 @@ module TF1Converter::Kml
12
14
  ::TF1Converter::Config.unstub!(:colors)
13
15
  end
14
16
 
15
- it 'cycles colors when configured that way' do
16
- ::TF1Converter::Config.stub(:use_constant_color){ false }
17
- colors = [nil, nil].map{|n| TrackColor.next }
18
- colors[0].should_not == colors[1]
17
+ describe 'no constant coloring' do
18
+ before { ::TF1Converter::Config.stub(:use_constant_color){ false } }
19
+
20
+ it 'cycles colors when configured that way' do
21
+ colors[0].should_not == colors[1]
22
+ end
23
+
24
+ it 'left pads each color' do
25
+ colors.each{ |v| v.should =~ /^0000000\d$/ }
26
+ end
19
27
  end
20
28
 
21
- it 'generates a constant color when constant color switch flipped in config' do
22
- ::TF1Converter::Config.stub(:use_constant_color){ true }
23
- ::TF1Converter::Config.stub(:constant_color){ 'c12345' }
24
- colors = [nil, nil].map{|n| TrackColor.next }
25
- colors[0].should == colors[1]
26
- ::TF1Converter::Config.unstub!(:constant_color)
29
+ describe 'constant coloring' do
30
+
31
+ before do
32
+ ::TF1Converter::Config.stub(:use_constant_color){ true }
33
+ ::TF1Converter::Config.stub(:constant_color){ 'c12345' }
34
+ end
35
+
36
+ it 'generates a constant color when constant color switch flipped in config' do
37
+ colors[0].should == colors[1]
38
+ end
39
+
40
+ it 'left pads the color' do
41
+ colors[0].should == '00c12345'
42
+ end
27
43
  end
44
+
28
45
  end
29
46
  end
@@ -45,4 +45,19 @@ module TF1Converter
45
45
  result.read.should_not =~ /default\.png/
46
46
  end
47
47
  end
48
+
49
+ describe 'file type checking' do
50
+ it 'likes files with gpx endings' do
51
+ TF1Converter::Translation.can_translate?("big-file.gpx").should be_true
52
+ end
53
+
54
+ it 'wont take files without gpx endings' do
55
+ TF1Converter::Translation.can_translate?("big-file.kml").should be_false
56
+ end
57
+
58
+ it 'wont parse placeholder files' do
59
+ TF1Converter::Translation.can_translate?(".").should be_false
60
+ TF1Converter::Translation.can_translate?("..").should be_false
61
+ end
62
+ end
48
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_gpx_2_kml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-10 00:00:00.000000000 Z
12
+ date: 2013-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -213,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  segments:
215
215
  - 0
216
- hash: -1878133451720708989
216
+ hash: 1834710226190470283
217
217
  required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  none: false
219
219
  requirements:
@@ -222,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  segments:
224
224
  - 0
225
- hash: -1878133451720708989
225
+ hash: 1834710226190470283
226
226
  requirements: []
227
227
  rubyforge_project:
228
228
  rubygems_version: 1.8.23