gpx2exif 0.0.1 → 0.0.2

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/Gemfile CHANGED
@@ -2,6 +2,7 @@ source "http://rubygems.org"
2
2
 
3
3
  gem 'nokogiri'
4
4
  gem 'mini_exiftool'
5
+ gem 'builder'
5
6
 
6
7
  group :development do
7
8
  gem "rspec", "~> 2.3.0"
data/Gemfile.lock CHANGED
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ builder (3.0.0)
4
5
  diff-lcs (1.1.3)
5
6
  git (1.2.5)
6
7
  jeweler (1.6.4)
@@ -8,7 +9,7 @@ GEM
8
9
  git (>= 1.2.5)
9
10
  rake
10
11
  mini_exiftool (1.3.1)
11
- multi_json (1.1.0)
12
+ multi_json (1.2.0)
12
13
  nokogiri (1.5.2)
13
14
  rake (0.9.2.2)
14
15
  rspec (2.3.0)
@@ -28,6 +29,7 @@ PLATFORMS
28
29
  ruby
29
30
 
30
31
  DEPENDENCIES
32
+ builder
31
33
  bundler (~> 1.0.0)
32
34
  jeweler (~> 1.6.4)
33
35
  mini_exiftool
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
1
  gpx2xif
2
2
  =======
3
3
 
4
- Geotag your photos using stored GPX files. At this moment it support only Garmin eTrex devices.
4
+ Geotagging
5
+ ----------
6
+
7
+ Geotag your photos using stored GPX files. At this moment it supports only Garmin eTrex devices.
5
8
 
6
9
 
7
10
  Disclaimer
@@ -9,8 +12,9 @@ Disclaimer
9
12
 
10
13
  This gem add one executable which overwrite JPG files. BACKUP IS NEEDED!
11
14
 
15
+
12
16
  How to use it
13
- ------
17
+ -------------
14
18
 
15
19
  1. gem install gpx2exif
16
20
 
@@ -28,6 +32,25 @@ How to use it
28
32
  If something is not working send me e-mail and I'll fix it.
29
33
 
30
34
 
35
+ Create waypoint files
36
+ ---------------------
37
+
38
+ You can prepare your own list of waypoints and then store into eTrex using GPX file. At this moment there is
39
+ only possible to convert data from YAML file to GPX. It is also possible to integrate with other (web)apps.
40
+
41
+ How to use it
42
+ -------------
43
+
44
+ 1. Check samples/sample_yaml_pois.yml as a template.
45
+
46
+ 2. Modify it, add yours POIs.
47
+
48
+ 3. Run command
49
+
50
+ generate_garmin_waypoints -y input_file.yml > output.gpx
51
+
52
+
53
+
31
54
  Contributing to gpx2xif
32
55
  -------------------------------
33
56
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'gpx2exif'
5
+ require 'optparse'
6
+
7
+ options = {}
8
+ OptionParser.new do |opts|
9
+ opts.banner = "Usage: generate_garmin_waypoints [options]"
10
+
11
+ opts.on("-y", "--yaml FILE", "Add points from yaml file") do |v|
12
+ options[:yaml] = v
13
+ end
14
+ end.parse!
15
+
16
+ g = GarminUtils::WaypointListGenerator.new
17
+ if options[:yaml]
18
+ g.add_yaml_file(options[:yaml])
19
+ end
20
+
21
+ # result
22
+ puts xml = g.to_xml
@@ -6,9 +6,13 @@ require 'gpx2exif'
6
6
  puts "Are you sure? It is evil script which probably eat photos of your dog and family. Uppercase 'yes' and enter if you want to continue."
7
7
  str = gets
8
8
 
9
+ puts "Do you want to add offset to image time? Default is 0 seconds."
10
+ time_offset = gets
11
+ time_offset = time_offset.to_i
12
+
9
13
  exit(0) unless str.strip == 'YES'
10
14
 
11
15
  g = Gpx2exif::GeoManager.new
12
- g.add_all_files
16
+ g.add_all_files(time_offset)
13
17
  g.match_up
14
18
  g.save!
data/bin/geotag_simulate CHANGED
@@ -7,7 +7,11 @@ require 'gpx2exif'
7
7
  #str = gets
8
8
  #exit(0) unless str.strip == 'YES'
9
9
 
10
+ puts "Do you want to add offset to image time? Default is 0 seconds."
11
+ time_offset = gets
12
+ time_offset = time_offset.to_i
13
+
10
14
  g = Gpx2exif::GeoManager.new
11
- g.add_all_files
15
+ g.add_all_files(time_offset)
12
16
  g.match_up
13
17
  g.simulate
@@ -0,0 +1,6 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+
3
+ require 'garmin_utils/waypoint_list_generator'
4
+
5
+ module GarminUtils
6
+ end
@@ -0,0 +1,111 @@
1
+ require 'rubygems'
2
+ require 'builder'
3
+ require 'yaml'
4
+
5
+ $:.unshift(File.dirname(__FILE__))
6
+
7
+ module GarminUtils
8
+ class WaypointListGenerator
9
+
10
+ def initialize
11
+ @pois = Array.new
12
+ @etrex_model = "eTrex 30"
13
+ end
14
+
15
+ def add_yaml_file(y)
16
+ @pois += YAML::load_file(y)
17
+ end
18
+
19
+ def add(lat, lon, name, cmt = nil, time = nil, ele = nil, sym = nil)
20
+ @pois << {
21
+ :lat => lat,
22
+ :lon => lon,
23
+ :name => name,
24
+ :cmt => cmt,
25
+ :time => time,
26
+ :ele => ele,
27
+ :sym => sym
28
+ }
29
+ end
30
+
31
+ def to_xml
32
+ #xml = Builder::XmlMarkup.new(:indent => 2)
33
+ string = ""
34
+ xml = Builder::XmlMarkup.new(:target => string, :indent => 0)
35
+ xml.instruct! :xml, :encoding => "UTF-8", :standalone => 'no'
36
+ xml.gpx(
37
+ 'xmlns' => "http://www.topografix.com/GPX/1/1",
38
+ 'xmlns:gpxx' => "http://www.garmin.com/xmlschemas/GpxExtensions/v3",
39
+ 'xmlns:wptx1' => "http://www.garmin.com/xmlschemas/WaypointExtension/v1",
40
+ 'xmlns:gpxtpx' => "http://www.garmin.com/xmlschemas/TrackPointExtension/v1",
41
+ 'creator' => @etrex_model,
42
+ 'version' => "1.1",
43
+ 'xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance",
44
+ 'xsi:schemaLocation' => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www8.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd"
45
+
46
+
47
+ ) do |g|
48
+ g.metadata do |meta|
49
+ meta.link('href' => "http://www.garmin.com") do |link|
50
+ link.text 'Garmin International'
51
+ end
52
+ meta.time process_time(Time.now) # 2012-03-24T15:41:34Z
53
+ end
54
+
55
+ # coords
56
+ # <wpt lat="52.484444" lon="16.893056"><ele>113.286499</ele><time>2012-03-18T16:42:47Z</time><name>GORA MORASKO</name><cmt>DUZY</cmt><sym>Flag, Blue</sym></wpt>
57
+ @pois.each do |poi|
58
+ g.wpt('lat' => poi[:lat], 'lon' => poi[:lon]) do |wp|
59
+ wp.ele poi[:elevation] unless poi[:elevation].nil?
60
+ wp.ele poi[:ele] unless poi[:ele].nil?
61
+
62
+ unless poi[:time].nil?
63
+ wp.time process_time(poi[:time])
64
+ else
65
+ wp.time process_time(Time.now)
66
+ end
67
+ wp.name poi[:name]
68
+
69
+ wp.cmt poi[:comment] unless poi[:comment].nil?
70
+ wp.cmt poi[:cmt] unless poi[:cmt].nil?
71
+
72
+ wp.sym poi[:sym] || "Flag, Blue" # default garmin symbol
73
+ end
74
+ end
75
+ end
76
+
77
+ #return string
78
+ return string.gsub(/\n/, '').gsub(/\r/, '')
79
+
80
+ end
81
+
82
+ attr_reader :pois
83
+
84
+ def self.symbols
85
+ # http://freegeographytools.com/2008/garmin-gps-unit-waypoint-icons-table
86
+ [
87
+ "Flag, Blue",
88
+ "Flag, Green",
89
+ "Flag, Red",
90
+
91
+ "Pin, Blue",
92
+ "Pin, Green",
93
+ "Pin, Red",
94
+
95
+ "Block, Blue",
96
+ "Block, Green",
97
+ "Block, Red",
98
+
99
+ "Summit",
100
+ "Trail Head"
101
+ # ...
102
+
103
+ ]
104
+ end
105
+
106
+ def process_time(time)
107
+ time.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
108
+ end
109
+
110
+ end
111
+ end
data/lib/gpx2exif.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  $:.unshift(File.dirname(__FILE__))
2
2
 
3
+ require 'garmin_utils'
4
+
3
5
  require 'gpx2exif/gpx_parser'
4
6
  require 'gpx2exif/exif_editor'
5
7
  require 'gpx2exif/geo_manager'
@@ -8,16 +8,16 @@ module Gpx2exif
8
8
 
9
9
  def initialize
10
10
  @images = Array.new
11
- @time_offset = 0
11
+ @global_time_offset = 0
12
12
  end
13
13
 
14
14
  attr_reader :images
15
- attr_accessor :time_offset
15
+ attr_accessor :global_time_offset
16
16
 
17
- def read_file(path)
17
+ def read_file(path, time_offset = 0)
18
18
  i = {
19
19
  :path => path,
20
- :time => get_photo_time(path) + @time_offset
20
+ :time => get_photo_time(path) + time_offset + @global_time_offset
21
21
  }
22
22
  @images << i
23
23
  puts "Added file #{path}, time #{i[:time]}"
@@ -10,7 +10,7 @@ module Gpx2exif
10
10
  @gp = GpxParser.new
11
11
  end
12
12
 
13
- def add_all_files
13
+ def add_all_files(time_offset = 0)
14
14
  # add all GPX
15
15
  Dir.glob("**/*.GPX", File::FNM_CASEFOLD).each do |f|
16
16
  add_gpx_file(f)
@@ -18,10 +18,10 @@ module Gpx2exif
18
18
 
19
19
  # add all GPX
20
20
  Dir.glob("**/*.JPG", File::FNM_CASEFOLD).each do |f|
21
- add_image(f)
21
+ add_image(f, time_offset)
22
22
  end
23
23
  Dir.glob("**/*.JPEG", File::FNM_CASEFOLD).each do |f|
24
- add_image(f)
24
+ add_image(f, time_offset)
25
25
  end
26
26
  end
27
27
 
@@ -29,8 +29,8 @@ module Gpx2exif
29
29
  @gp.add_file(path)
30
30
  end
31
31
 
32
- def add_image(path)
33
- @ee.read_file(path)
32
+ def add_image(path, time_offset = 0)
33
+ @ee.read_file(path, time_offset)
34
34
  end
35
35
 
36
36
  def match_up
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpx2exif
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-25 00:00:00.000000000Z
12
+ date: 2012-04-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &15838400 !ruby/object:Gem::Requirement
16
+ requirement: &23556840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *15838400
24
+ version_requirements: *23556840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mini_exiftool
27
- requirement: &15837920 !ruby/object:Gem::Requirement
27
+ requirement: &23130560 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,21 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *15837920
35
+ version_requirements: *23130560
36
+ - !ruby/object:Gem::Dependency
37
+ name: builder
38
+ requirement: &23129980 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *23129980
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rspec
38
- requirement: &15837420 !ruby/object:Gem::Requirement
49
+ requirement: &23129440 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
52
  - - ~>
@@ -43,10 +54,10 @@ dependencies:
43
54
  version: 2.3.0
44
55
  type: :development
45
56
  prerelease: false
46
- version_requirements: *15837420
57
+ version_requirements: *23129440
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: bundler
49
- requirement: &15836940 !ruby/object:Gem::Requirement
60
+ requirement: &23128920 !ruby/object:Gem::Requirement
50
61
  none: false
51
62
  requirements:
52
63
  - - ~>
@@ -54,10 +65,10 @@ dependencies:
54
65
  version: 1.0.0
55
66
  type: :development
56
67
  prerelease: false
57
- version_requirements: *15836940
68
+ version_requirements: *23128920
58
69
  - !ruby/object:Gem::Dependency
59
70
  name: jeweler
60
- requirement: &15836460 !ruby/object:Gem::Requirement
71
+ requirement: &23128320 !ruby/object:Gem::Requirement
61
72
  none: false
62
73
  requirements:
63
74
  - - ~>
@@ -65,10 +76,10 @@ dependencies:
65
76
  version: 1.6.4
66
77
  type: :development
67
78
  prerelease: false
68
- version_requirements: *15836460
79
+ version_requirements: *23128320
69
80
  - !ruby/object:Gem::Dependency
70
81
  name: simplecov
71
- requirement: &15835980 !ruby/object:Gem::Requirement
82
+ requirement: &23127660 !ruby/object:Gem::Requirement
72
83
  none: false
73
84
  requirements:
74
85
  - - ! '>='
@@ -76,7 +87,7 @@ dependencies:
76
87
  version: '0'
77
88
  type: :development
78
89
  prerelease: false
79
- version_requirements: *15835980
90
+ version_requirements: *23127660
80
91
  description: Mass geotagger using GPX files.
81
92
  email: bobikx@poczta.fm
82
93
  executables:
@@ -93,8 +104,11 @@ files:
93
104
  - README.md
94
105
  - Rakefile
95
106
  - VERSION
107
+ - bin/generate_garmin_waypoints
96
108
  - bin/geotag_all_images
97
109
  - bin/geotag_simulate
110
+ - lib/garmin_utils.rb
111
+ - lib/garmin_utils/waypoint_list_generator.rb
98
112
  - lib/gpx2exif.rb
99
113
  - lib/gpx2exif/exif_editor.rb
100
114
  - lib/gpx2exif/geo_manager.rb
@@ -114,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
114
128
  version: '0'
115
129
  segments:
116
130
  - 0
117
- hash: 1534559564307803771
131
+ hash: 336724841387735391
118
132
  required_rubygems_version: !ruby/object:Gem::Requirement
119
133
  none: false
120
134
  requirements: