open_gpx_2_kml 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.rbenv-version +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +46 -0
- data/README.md +17 -0
- data/Rakefile +2 -0
- data/bin/openGpx2Kml +21 -0
- data/example/config.csv +57 -0
- data/example/windowsconfig.csv +57 -0
- data/harness.rb +16 -0
- data/input/test.gpx +724 -0
- data/lib/tf1_converter/config.rb +63 -0
- data/lib/tf1_converter/csv_file.rb +19 -0
- data/lib/tf1_converter/gpx/track.rb +30 -0
- data/lib/tf1_converter/gpx/trackpoint.rb +22 -0
- data/lib/tf1_converter/gpx/waypoint.rb +76 -0
- data/lib/tf1_converter/gpx_file.rb +19 -0
- data/lib/tf1_converter/kml/track_color.rb +28 -0
- data/lib/tf1_converter/kml/track_node.rb +36 -0
- data/lib/tf1_converter/kml_file.rb +80 -0
- data/lib/tf1_converter/kmz_file.rb +27 -0
- data/lib/tf1_converter/translation.rb +34 -0
- data/lib/tf1_converter/version.rb +3 -0
- data/lib/tf1_converter.rb +3 -0
- data/openGpx2Kml.gemspec +30 -0
- data/output/test.kml +329 -0
- data/spec/fixtures/expected.kml +329 -0
- data/spec/fixtures/ftwood2.gpx +7481 -0
- data/spec/fixtures/ftwood2_expected.kml +1 -0
- data/spec/fixtures/test.gpx +724 -0
- data/spec/fixtures/waypoint-by-name.gpx +709 -0
- data/spec/lib/tf1_converter/gpx/track_spec.rb +20 -0
- data/spec/lib/tf1_converter/gpx/waypoint_spec.rb +70 -0
- data/spec/lib/tf1_converter/kml/track_color_spec.rb +29 -0
- data/spec/lib/tf1_converter/kmz_file_spec.rb +18 -0
- data/spec/lib/tf1_converter/translation_spec.rb +48 -0
- metadata +242 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
require_relative '../../../../lib/tf1_converter/gpx/track'
|
2
|
+
|
3
|
+
module TF1Converter::Gpx
|
4
|
+
describe Track do
|
5
|
+
describe '#display_color' do
|
6
|
+
it 'gets the mapped color name from the config' do
|
7
|
+
color_map = {'Orange' => 'aabbccdd' }
|
8
|
+
node = double(xpath: double(first: double(text: 'Orange')))
|
9
|
+
track = Track.new(node, color_map)
|
10
|
+
track.display_color.should == 'aabbccdd'
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'returns a default color for nil' do
|
14
|
+
node = double(xpath: double(first: nil))
|
15
|
+
track = Track.new(node, {})
|
16
|
+
track.display_color.should == 'f0000080'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require_relative '../../../../lib/tf1_converter/gpx/waypoint'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module TF1Converter::Gpx
|
5
|
+
describe Waypoint do
|
6
|
+
let(:icon_map) { {} }
|
7
|
+
let(:node) { double }
|
8
|
+
let(:waypoint) { Waypoint.new(node, icon_map) }
|
9
|
+
|
10
|
+
|
11
|
+
let(:waypoint_by_name_fragment) do
|
12
|
+
%Q{
|
13
|
+
<wpt lat="38.9199972" lon="-92.2972443">
|
14
|
+
<name>icon_name_42</name>
|
15
|
+
</wpt>
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:default_fragment) do
|
20
|
+
%Q{<wpt lat="38.9199972" lon="-92.2972443"></wpt>}
|
21
|
+
end
|
22
|
+
|
23
|
+
def waypoint_from(fragment)
|
24
|
+
node = Nokogiri::XML.fragment(fragment).xpath('wpt').first
|
25
|
+
Waypoint.new(node, icon_map)
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#icon_name' do
|
29
|
+
it 'returns a matching name from the map' do
|
30
|
+
node.stub_chain(:children, :select, :first, :text){ 'meaningoflife' }
|
31
|
+
icon_map['meaningoflife'] = {'icon' => '42.png'}
|
32
|
+
waypoint.icon_name.should == '42.png'
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can find a waypoint by name' do
|
36
|
+
waypoint = waypoint_from(waypoint_by_name_fragment)
|
37
|
+
icon_map['meaningoflife'] = { 'icon' => '42.png', 'name' => 'icon_name_42' }
|
38
|
+
waypoint.icon_name.should == '42.png'
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns a default value if there is no sym node' do
|
42
|
+
waypoint = waypoint_from(default_fragment)
|
43
|
+
waypoint.icon_name.should == 'default.png'
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'gives a default value if there is no hash match' do
|
47
|
+
node.stub_chain(:children, :select, :first, :text){ '' }
|
48
|
+
waypoint.icon_name.should == 'default.png'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#icon_meaning' do
|
53
|
+
it 'returns a matching meaning from the map' do
|
54
|
+
node.stub_chain(:children, :select, :first, :text){ 'meaningoflife' }
|
55
|
+
icon_map['meaningoflife'] = {'meaning' => 'life'}
|
56
|
+
waypoint.icon_meaning.should == 'life'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'gives a default if no sym node' do
|
60
|
+
node.stub_chain(:children, :select){ [] }
|
61
|
+
waypoint.icon_meaning.should == 'Default'
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'gives a default value if there is no hash match' do
|
65
|
+
node.stub_chain(:children, :select, :first, :text){ '' }
|
66
|
+
waypoint.icon_meaning.should == 'Default'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative '../../../../lib/tf1_converter/config'
|
2
|
+
require_relative '../../../../lib/tf1_converter/kml/track_color'
|
3
|
+
|
4
|
+
module TF1Converter::Kml
|
5
|
+
describe TrackColor do
|
6
|
+
before(:each) do
|
7
|
+
::TF1Converter::Config.stub(:colors){ {'Blue'=>'1', 'Red'=>'2', 'Yellow'=>'3'}}
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:each) do
|
11
|
+
::TF1Converter::Config.unstub!(:use_constant_color)
|
12
|
+
::TF1Converter::Config.unstub!(:colors)
|
13
|
+
end
|
14
|
+
|
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]
|
19
|
+
end
|
20
|
+
|
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)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../../../lib/tf1_converter/config'
|
2
|
+
require_relative '../../../lib/tf1_converter/kmz_file'
|
3
|
+
|
4
|
+
module TF1Converter
|
5
|
+
describe KmzFile do
|
6
|
+
describe '.full_filepath' do
|
7
|
+
it 'paths correctly when config ends with slash' do
|
8
|
+
TF1Converter::Config.stub(:icon_path){ '/some/path/'}
|
9
|
+
KmzFile.full_filepath('filename').should == '/some/path/filename'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'paths correctly when config ends without slash' do
|
13
|
+
TF1Converter::Config.stub(:icon_path){ '/some/path'}
|
14
|
+
KmzFile.full_filepath('filename').should == '/some/path/filename'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'timecop'
|
2
|
+
require_relative '../../../lib/tf1_converter'
|
3
|
+
|
4
|
+
module TF1Converter
|
5
|
+
describe Translation do
|
6
|
+
before do
|
7
|
+
execution_time = Time.local(2008, 9, 1, 12, 0, 0)
|
8
|
+
Timecop.freeze(execution_time)
|
9
|
+
Kml::TrackColor.uncache!
|
10
|
+
end
|
11
|
+
|
12
|
+
after do
|
13
|
+
Timecop.return
|
14
|
+
end
|
15
|
+
|
16
|
+
let(:local_dir) { File.dirname(__FILE__) }
|
17
|
+
let(:path) { File.expand_path('../../fixtures', local_dir) }
|
18
|
+
let(:config_file) { File.expand_path('../../../example/config.csv', local_dir) }
|
19
|
+
|
20
|
+
it "translates a file correctly" do
|
21
|
+
input = File.open("#{path}/test.gpx", 'r')
|
22
|
+
output = File.open("#{path}/test.kml", 'w')
|
23
|
+
expected = File.open("#{path}/expected.kml", 'r')
|
24
|
+
TF1Converter::Config.load(config_file)
|
25
|
+
TF1Converter::Translation.from(input).into(output)
|
26
|
+
|
27
|
+
result = File.open("#{path}/test.kml", 'r')
|
28
|
+
result.read.should == expected.read
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'translates a tracks-only file' do
|
32
|
+
input = File.open("#{path}/ftwood2.gpx", 'r')
|
33
|
+
output = File.open("#{path}/ftwood2.kml", 'w')
|
34
|
+
TF1Converter::Config.load(config_file)
|
35
|
+
#should not raise error
|
36
|
+
TF1Converter::Translation.from(input).into(output)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'translates waypoints by name' do
|
40
|
+
input = File.open("#{path}/waypoint-by-name.gpx", 'r')
|
41
|
+
output = File.open("#{path}/waypoint-by-name.kml", 'w')
|
42
|
+
TF1Converter::Config.load(config_file)
|
43
|
+
TF1Converter::Translation.from(input).into(output)
|
44
|
+
result = File.open("#{path}/waypoint-by-name.kml", 'r')
|
45
|
+
result.read.should_not =~ /default\.png/
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: open_gpx_2_kml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ethan Vizitei
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 10.0.3
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 10.0.3
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.12.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.12.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: pry
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - '='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.9.11.4
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.11.4
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: timecop
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.5.9.2
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - '='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.5.9.2
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: thor
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - '='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 0.17.0
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - '='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.17.0
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: nokogiri
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - '='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.5.6
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - '='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.5.6
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: builder
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.1.4
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - '='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 3.1.4
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: geo_swap
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - '='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 0.2.1
|
134
|
+
type: :runtime
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - '='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 0.2.1
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: rubyzip
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - '='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 0.9.9
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - '='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: 0.9.9
|
158
|
+
description: A GPX to KML converter for FEMA US&R
|
159
|
+
email:
|
160
|
+
- ethan.vizitei@gmail.com
|
161
|
+
executables:
|
162
|
+
- openGpx2Kml
|
163
|
+
extensions: []
|
164
|
+
extra_rdoc_files: []
|
165
|
+
files:
|
166
|
+
- .gitignore
|
167
|
+
- .rbenv-version
|
168
|
+
- Gemfile
|
169
|
+
- Gemfile.lock
|
170
|
+
- README.md
|
171
|
+
- Rakefile
|
172
|
+
- bin/openGpx2Kml
|
173
|
+
- example/config.csv
|
174
|
+
- example/windowsconfig.csv
|
175
|
+
- harness.rb
|
176
|
+
- input/test.gpx
|
177
|
+
- lib/tf1_converter.rb
|
178
|
+
- lib/tf1_converter/config.rb
|
179
|
+
- lib/tf1_converter/csv_file.rb
|
180
|
+
- lib/tf1_converter/gpx/track.rb
|
181
|
+
- lib/tf1_converter/gpx/trackpoint.rb
|
182
|
+
- lib/tf1_converter/gpx/waypoint.rb
|
183
|
+
- lib/tf1_converter/gpx_file.rb
|
184
|
+
- lib/tf1_converter/kml/track_color.rb
|
185
|
+
- lib/tf1_converter/kml/track_node.rb
|
186
|
+
- lib/tf1_converter/kml_file.rb
|
187
|
+
- lib/tf1_converter/kmz_file.rb
|
188
|
+
- lib/tf1_converter/translation.rb
|
189
|
+
- lib/tf1_converter/version.rb
|
190
|
+
- openGpx2Kml.gemspec
|
191
|
+
- output/test.kml
|
192
|
+
- spec/fixtures/expected.kml
|
193
|
+
- spec/fixtures/ftwood2.gpx
|
194
|
+
- spec/fixtures/ftwood2_expected.kml
|
195
|
+
- spec/fixtures/test.gpx
|
196
|
+
- spec/fixtures/waypoint-by-name.gpx
|
197
|
+
- spec/lib/tf1_converter/gpx/track_spec.rb
|
198
|
+
- spec/lib/tf1_converter/gpx/waypoint_spec.rb
|
199
|
+
- spec/lib/tf1_converter/kml/track_color_spec.rb
|
200
|
+
- spec/lib/tf1_converter/kmz_file_spec.rb
|
201
|
+
- spec/lib/tf1_converter/translation_spec.rb
|
202
|
+
homepage: ''
|
203
|
+
licenses: []
|
204
|
+
post_install_message:
|
205
|
+
rdoc_options: []
|
206
|
+
require_paths:
|
207
|
+
- lib
|
208
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
210
|
+
requirements:
|
211
|
+
- - ! '>='
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
segments:
|
215
|
+
- 0
|
216
|
+
hash: 3980550496165662237
|
217
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
218
|
+
none: false
|
219
|
+
requirements:
|
220
|
+
- - ! '>='
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
segments:
|
224
|
+
- 0
|
225
|
+
hash: 3980550496165662237
|
226
|
+
requirements: []
|
227
|
+
rubyforge_project:
|
228
|
+
rubygems_version: 1.8.23
|
229
|
+
signing_key:
|
230
|
+
specification_version: 3
|
231
|
+
summary: A GPX to KML converter for FEMA US&R
|
232
|
+
test_files:
|
233
|
+
- spec/fixtures/expected.kml
|
234
|
+
- spec/fixtures/ftwood2.gpx
|
235
|
+
- spec/fixtures/ftwood2_expected.kml
|
236
|
+
- spec/fixtures/test.gpx
|
237
|
+
- spec/fixtures/waypoint-by-name.gpx
|
238
|
+
- spec/lib/tf1_converter/gpx/track_spec.rb
|
239
|
+
- spec/lib/tf1_converter/gpx/waypoint_spec.rb
|
240
|
+
- spec/lib/tf1_converter/kml/track_color_spec.rb
|
241
|
+
- spec/lib/tf1_converter/kmz_file_spec.rb
|
242
|
+
- spec/lib/tf1_converter/translation_spec.rb
|