gpx2png 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'mini_exiftool'
4
+ gem 'rmagick'
5
+ # removed
6
+ #gem 'chunky_png'
7
+ gem 'gpx_utils'
8
+
9
+ group :development do
10
+ gem "rspec"
11
+ gem "bundler"
12
+ gem "jeweler"
13
+ gem "simplecov"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ diff-lcs (1.2.5)
7
+ docile (1.1.1)
8
+ faraday (0.8.8)
9
+ multipart-post (~> 1.2.0)
10
+ git (1.2.6)
11
+ github_api (0.10.1)
12
+ addressable
13
+ faraday (~> 0.8.1)
14
+ hashie (>= 1.2)
15
+ multi_json (~> 1.4)
16
+ nokogiri (~> 1.5.2)
17
+ oauth2
18
+ gpx_utils (0.0.1)
19
+ builder
20
+ nokogiri
21
+ hashie (2.0.5)
22
+ highline (1.6.20)
23
+ httpauth (0.2.0)
24
+ jeweler (1.8.8)
25
+ builder
26
+ bundler (~> 1.0)
27
+ git (>= 1.2.5)
28
+ github_api (= 0.10.1)
29
+ highline (>= 1.6.15)
30
+ nokogiri (= 1.5.10)
31
+ rake
32
+ rdoc
33
+ json (1.8.1)
34
+ jwt (0.1.8)
35
+ multi_json (>= 1.5)
36
+ mini_exiftool (2.3.0)
37
+ multi_json (1.8.2)
38
+ multi_xml (0.5.5)
39
+ multipart-post (1.2.0)
40
+ nokogiri (1.5.10)
41
+ oauth2 (0.9.2)
42
+ faraday (~> 0.8)
43
+ httpauth (~> 0.2)
44
+ jwt (~> 0.1.4)
45
+ multi_json (~> 1.0)
46
+ multi_xml (~> 0.5)
47
+ rack (~> 1.2)
48
+ rack (1.5.2)
49
+ rake (10.1.1)
50
+ rdoc (4.0.1)
51
+ json (~> 1.4)
52
+ rmagick (2.13.2)
53
+ rspec (2.14.1)
54
+ rspec-core (~> 2.14.0)
55
+ rspec-expectations (~> 2.14.0)
56
+ rspec-mocks (~> 2.14.0)
57
+ rspec-core (2.14.7)
58
+ rspec-expectations (2.14.4)
59
+ diff-lcs (>= 1.1.3, < 2.0)
60
+ rspec-mocks (2.14.4)
61
+ simplecov (0.8.2)
62
+ docile (~> 1.1.0)
63
+ multi_json
64
+ simplecov-html (~> 0.8.0)
65
+ simplecov-html (0.8.0)
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ bundler
72
+ gpx_utils
73
+ jeweler
74
+ mini_exiftool
75
+ rmagick
76
+ rspec
77
+ simplecov
data/LICENSE.txt ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/README.md ADDED
@@ -0,0 +1,117 @@
1
+ gpx2exif
2
+ =======
3
+
4
+ Geotagging
5
+ ----------
6
+
7
+ Geotag your photos using stored GPX files. At this moment it supports only Garmin eTrex devices.
8
+
9
+
10
+ Disclaimer
11
+ ----------
12
+
13
+ This gem add one executable which overwrite JPG files. BACKUP IS NEEDED!
14
+
15
+
16
+ How to use it
17
+ -------------
18
+
19
+ 1. gem install gpx2exif
20
+
21
+ 2. Go to path where you have JPG/JPEG photos (case insensitive) and GPX files.
22
+
23
+ 3. From 0.0.1 there is 'simulation command'. Type 'geotag_simulate' and enter.
24
+
25
+ 4. WARNING! it will overwrite all your photos so MAKE A BACKUP!
26
+
27
+ 5. Type 'geotag_all_images' and press enter key.
28
+
29
+ 6. See a nice piece of output and now you have geotagged photos :)
30
+
31
+
32
+ If something is not working send me e-mail and I'll fix it.
33
+
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
+ 4. You can check inter-POI distances using
53
+
54
+ generate_garmin_waypoints -y input_file.yml -C
55
+
56
+ Distance conflict does not mean something is wrong. POIs can be close to each other so it
57
+ is a good idea to have your brain turned on ;)
58
+
59
+ 5. You can change inter-POI distances using 'latlon something' distance for distance checking
60
+ explained line before.
61
+
62
+ generate_garmin_waypoints -y samples/sample_yaml_pois.yml -C -t 1
63
+
64
+ 6. You can specify output file if you don't like using >> 'file.gpx'.
65
+
66
+ generate_garmin_waypoints -y samples/sample_yaml_pois.yml -o file.gpx
67
+
68
+
69
+ Render track with OpenStreetMap
70
+ ---------------------
71
+
72
+ You can "convert" your tracks to images using this command.
73
+
74
+ How to use it
75
+ -------------
76
+
77
+ 1. Please check if you have installed RMagick gem.
78
+
79
+ 2. Run command.
80
+
81
+ gpx2png -g [input GPX file] -s [image size, format: WIDTHxHEIGHT] -o [output PPNG file]
82
+
83
+ Example:
84
+
85
+ gpx2png -g spec/fixtures/sample.gpx -s 800x600 -o map.png
86
+
87
+ 3. You can specify zoom.
88
+
89
+ gpx2png -g [input GPX file] -z [zoom, best results between 9 and 15, max 18] -o [output PPNG file]
90
+
91
+ Example:
92
+
93
+ gpx2png -g spec/fixtures/sample.gpx -z 11 -o map.png
94
+
95
+ 4. Adding -u forces using [UMP tiles](http://ump.waw.pl/) .
96
+
97
+
98
+ Contributing to gpx2xif
99
+ -------------------------------
100
+
101
+ [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=bobik314&url=https://github.com/akwiatkowski/gpx2xif&title=gpx2xif&language=en_GB&tags=github&category=software)
102
+
103
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
104
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
105
+ * Fork the project
106
+ * Start a feature/bugfix branch
107
+ * Commit and push until you are happy with your contribution
108
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
109
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
110
+
111
+
112
+ Copyright
113
+ ---------
114
+
115
+ Copyright (c) 2012 Aleksander Kwiatkowski. See LICENSE.txt for
116
+ further details.
117
+
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "gpx2png"
18
+ gem.homepage = "http://github.com/akwiatkowski/gpx2png"
19
+ gem.license = "LGPLv3"
20
+ gem.summary = %Q{Convert routes to image map files using Openstreetmap tileset}
21
+ gem.description = %Q{Convert routes to image map files using Openstreetmap tileset.}
22
+ gem.email = "bobikx@poczta.fm"
23
+ gem.authors = ["Aleksander Kwiatkowski"]
24
+ # dependencies defined in Gemfile
25
+ gem.executables = ['gpx2png']
26
+
27
+ gem.files = FileList[
28
+ "[A-Z]*", "{bin,generators,lib,test}/**/*"
29
+ ]
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ require 'rspec/core'
34
+ require 'rspec/core/rake_task'
35
+ RSpec::Core::RakeTask.new(:spec) do |spec|
36
+ spec.pattern = FileList['spec/**/*_spec.rb']
37
+ end
38
+
39
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
40
+ spec.pattern = 'spec/**/*_spec.rb'
41
+ spec.rcov = true
42
+ end
43
+
44
+ task :default => :spec
45
+
46
+ require 'rdoc/task'
47
+
48
+ desc "Run RSpec with code coverage"
49
+ task :coverage do
50
+ `rake spec COVERAGE=true`
51
+ #`open coverage/index.html`
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
data/bin/gpx2png ADDED
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'gpx2exif'
5
+ require 'gpx2png/osm'
6
+ require 'gpx2png/ump'
7
+ require 'optparse'
8
+
9
+ options = { }
10
+ OptionParser.new do |opts|
11
+ opts.banner = "Usage: gpx2png [options]"
12
+
13
+ opts.on("-g", "--gpx FILE", "Input GPX file") do |v|
14
+ options[:gpx] = v
15
+ end
16
+ opts.on("-z", "--zoom ZOOM", "Set zoom") do |v|
17
+ options[:zoom] = v
18
+ end
19
+ opts.on("-s", "--size WIDTHxHEIGHT", "Set output image size (better result)") do |v|
20
+ options[:size] = v
21
+ end
22
+ opts.on("-o", "--output FILE", "Output image file") do |v|
23
+ options[:output_file] = v
24
+ end
25
+ opts.on("-u", "--ump", "Use UMP tiles rather than OSM") do
26
+ options[:ump] = true
27
+ end
28
+ end.parse!
29
+
30
+ unless options[:gpx]
31
+ puts "Input GPX file needed"
32
+ @fail = true
33
+ end
34
+ unless options[:output_file]
35
+ puts "Output image file needed"
36
+ @fail = true
37
+ end
38
+ if options[:zoom].nil? and options[:size].nil?
39
+ puts "Zoom or image size needed"
40
+ @fail = true
41
+ end
42
+
43
+ unless @fail
44
+ g = GpxUtils::TrackImporter.new
45
+ g.add_file(options[:gpx])
46
+
47
+ if options[:ump]
48
+ e = Gpx2png::Ump.new
49
+ else
50
+ e = Gpx2png::Osm.new
51
+ end
52
+ e.coords = g.coords
53
+
54
+ if options[:size]
55
+ # constant size
56
+ options[:size] =~ /(\d+)x(\d+)/
57
+ e.fixed_size($1.to_i, $1.to_i)
58
+ else
59
+ # constant zoom
60
+ e.zoom = options[:zoom].to_i
61
+ e.renderer_options = {crop_enabled: true}
62
+ end
63
+
64
+ e.save(options[:output_file])
65
+ end
66
+
67
+ # testing
68
+ # ruby -Ilib bin/gpx2png -g spec/fixtures/sample.gpx -s 400x400 -o samples/tmp/cli_test.png -u
@@ -0,0 +1,25 @@
1
+ require 'base64'
2
+
3
+ $:.unshift(File.dirname(__FILE__))
4
+
5
+ # Sample marker useful for everybody :)
6
+ module Gpx2png
7
+ class SampleMarker
8
+
9
+ STRING = "iVBORw0KGgoAAAANSUhEUgAAACAAAAA8CAYAAAAHbrgUAAAACXBIWXMAAAsT
10
+ AAALEwEAmpwYAAAAB3RJTUUH3AoHCwYNWvFiNgAAAYxJREFUWMPtls9KAzEQ
11
+ xr9d//QkgmjxKPQBVDwJYvEPXoQWfQ7Bm48hKL6AIhT6DIp3QaGC4KEnT0q1
12
+ FxE8db2ksIRJNtlM1oPzg1A2O5v5Js23O4A/mwCuAPQB/KjRV3NNRKQOoAcg
13
+ AzBSv/kxnnsCsMidfNmS2CRklSv5gkdyXUSdQ8Ajkdz2F+Sve6HJ1w2JPgC0
14
+ AUyo0QIwMAjbCBFwqS06AvBpiR8Q8dchAl6Jig4t8W0i/i1EAHXAapb4KcMz
15
+ RlIHAToJp7+LBDwTc/uWeOreS4jAM8IBQ4PwRLlDd8JFiIAtgw2H6jBOq3Gg
16
+ 3EHZcNeWIHE8iNRc4jBXmCN1ENAhRLgkygB0OQ5q0+MboI9tLrd8lUj+zWHD
17
+ vBt8Oed8X8yV2IF57qbk1qMhuYvRku14VL8Xqy98L9iFca8QjSOH6o99Fizz
18
+ Zcs410xLCDhltqs3M5btn0VFdIjer4sKWSKqb6BiblTl0V48Razkql/DH3EP
19
+ 4CFkgclAAScMawiCIAiCIAiCIAj/nF9mGvLkWeHRewAAAABJRU5ErkJggg=="
20
+
21
+ BLOB = Base64.decode64(STRING)
22
+
23
+ URL = "http://www.iconspedia.com/icon/map-marker-icon-19842.html"
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ require 'rubygems'
2
+
3
+ $:.unshift(File.dirname(__FILE__))
4
+
5
+ module Gpx2png
6
+ class Base
7
+
8
+ def initialize
9
+ @coords = Array.new
10
+ @zoom = 9
11
+ @verbose = true
12
+ end
13
+
14
+ def add(lat, lon)
15
+ @coords << { lat: lat, lon: lon }
16
+ end
17
+
18
+ attr_accessor :zoom, :color, :coords
19
+
20
+ # Some math stuff
21
+ def self.rad2deg(rad)
22
+ return rad * 180.0 / Math::PI
23
+ end
24
+
25
+ def self.deg2rad(deg)
26
+ return deg * Math::PI / 180.0
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'gpx2png/osm_base'
3
+
4
+ $:.unshift(File.dirname(__FILE__))
5
+
6
+ module Gpx2png
7
+ class Osm < OsmBase
8
+
9
+ DEFAULT_RENDERER = :rmagick
10
+ attr_accessor :renderer
11
+
12
+ def initialize
13
+ super
14
+ @renderer ||= DEFAULT_RENDERER
15
+ @r = nil
16
+ @markers = Array.new
17
+ end
18
+
19
+ def save(filename)
20
+ render
21
+ @r.save(filename)
22
+ end
23
+
24
+ def to_png
25
+ render
26
+ @r.to_png
27
+ end
28
+
29
+ def add_marker(p)
30
+ @markers << p
31
+ end
32
+
33
+ def render
34
+ setup_renderer
35
+ initial_calculations
36
+ download_and_join_tiles
37
+ end
38
+
39
+ attr_accessor :renderer_options
40
+
41
+ # Get proper renderer class
42
+ def setup_renderer
43
+ case @renderer
44
+ when :chunky_png
45
+ require 'gpx2png/renderers/chunky_png_renderer'
46
+ @r = ChunkyPngRenderer.new(@renderer_options)
47
+ when :rmagick
48
+ require 'gpx2png/renderers/rmagick_renderer'
49
+ @r = RmagickRenderer.new(@renderer_options)
50
+ @r.licence_string = self.class.licence_string
51
+ else
52
+ raise ArgumentError
53
+ end
54
+ end
55
+
56
+ end
57
+ end