gpx 0.4 → 0.5

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.
@@ -0,0 +1,132 @@
1
+ 2009-07-07 02:51 dougfales
2
+
3
+ * lib/gpx/gpx.rb: Revving to version 0.5.
4
+
5
+ 2009-07-07 02:43 dougfales
6
+
7
+ * README: Changing my contact email address.
8
+
9
+ 2009-07-07 02:41 dougfales
10
+
11
+ * lib/gpx/gpx_file.rb, tests/gpx_file_test.rb,
12
+ tests/gpx_files/with_or_without_elev.gpx: Patches from Tom
13
+ Verbeure (mtbguru.com) to work with libxml-ruby 1.x.
14
+
15
+ 2009-06-17 14:20 dougfales
16
+
17
+ * lib/gpx/point.rb: Patch from Kang-min Liu to support speed
18
+ element.
19
+
20
+ 2008-02-19 04:09 dougfales
21
+
22
+ * lib/gpx/gpx.rb: Revving to 0.4.
23
+
24
+ 2008-02-19 04:06 dougfales
25
+
26
+ * lib/gpx/gpx.rb, lib/gpx/gpx_file.rb, lib/gpx/point.rb,
27
+ lib/gpx/route.rb, lib/gpx/track.rb, lib/gpx/waypoint.rb,
28
+ tests/gpx_file_test.rb, tests/gpx_files, tests/gpx_files/big.gpx,
29
+ tests/output, tests/output_test.rb, tests/track_test.rb: Adding
30
+ some new unit tests and fixing several file export bugs reported
31
+ by Jochen Topf.
32
+ New unit tests also uncovered a bug where the number of
33
+ trackpoints reported in a file was twice the actual number.
34
+
35
+ 2008-02-11 21:20 dougfales
36
+
37
+ * lib/gpx/gpx.rb: Going to version 0.3.
38
+
39
+ 2008-02-11 21:13 dougfales
40
+
41
+ * tests/gpx10_test.rb, tests/gpx_files/routes.gpx,
42
+ tests/gpx_files/waypoints.gpx, tests/magellan_test.rb,
43
+ tests/route_test.rb, tests/segment_test.rb,
44
+ tests/track_file_test.rb, tests/track_test.rb,
45
+ tests/waypoint_test.rb: Updating unit tests in light of recent
46
+ fixes to routes and waypoints code.
47
+
48
+ 2008-02-08 23:26 dougfales
49
+
50
+ * lib/gpx/gpx.rb, lib/gpx/point.rb, lib/gpx/route.rb,
51
+ lib/gpx/waypoint.rb: Thanks to Mike Gauland for discovering some
52
+ route- and waypoint-related bugs. I've fixed them and also added
53
+ #to_s on Waypoint so it's easier to debug.
54
+
55
+ 2007-12-04 17:58 dougfales
56
+
57
+ * lib/gpx/waypoint.rb: Thanks to Christian Koerner for finding and
58
+ fixing these bugs in the waypoint
59
+ code.
60
+
61
+ 2007-12-04 17:52 dougfales
62
+
63
+ * lib/gpx/gpx_file.rb, tests/gpx_file_test.rb: Another patch from
64
+ Gaku Ueda. This one allows you to pass in a string of GPX
65
+ data using the :gpx_date => option. Thanks Gaku!
66
+
67
+ 2007-11-30 06:29 dougfales
68
+
69
+ * lib/gpx/gpx.rb: Updating the version #.
70
+
71
+ 2007-11-30 06:26 dougfales
72
+
73
+ * lib/gpx/gpx.rb, lib/gpx/gpx_file.rb, lib/gpx/point.rb,
74
+ lib/gpx/route.rb, lib/gpx/segment.rb, lib/gpx/track.rb,
75
+ tests/gpx10_test.rb, tests/gpx_files/gpx10.gpx: Updates courtesy
76
+ of Gaku Ueda:
77
+ * Adding support for GPX 1.0 as well as 1.1 (since libxml
78
+ namespace parsing
79
+ was hard-coded to 1.1. previously).
80
+ * Adding a GPX 1.0 unit test file.
81
+ * Miscellaneous updates to make it work with Ruby 1.8.6.
82
+
83
+ 2006-12-04 06:47 dougfales
84
+
85
+ * README, lib/gpx.rb, lib/gpx/bounds.rb, lib/gpx/gpx.rb,
86
+ lib/gpx/gpx_file.rb, lib/gpx/point.rb, lib/gpx/route.rb,
87
+ lib/gpx/segment.rb, lib/gpx/track.rb, lib/gpx/waypoint.rb,
88
+ tests/segment_test.rb: First stab at using libxml-ruby instead of
89
+ REXML. I'm seeing the unit tests
90
+ finish in under 14 seconds. That is compared to 2 minutes using
91
+ REXML.
92
+
93
+ 2006-12-03 07:31 dougfales
94
+
95
+ * lib/gpx/point.rb, lib/gpx/segment.rb: Fixing more nil time
96
+ exceptions.
97
+
98
+ 2006-12-03 06:59 dougfales
99
+
100
+ * lib/gpx/segment.rb: Fixing an exception in contains_time?.
101
+
102
+ 2006-11-28 15:35 dougfales
103
+
104
+ * lib/gpx/bounds.rb, lib/gpx/gpx_file.rb: A couple of fixes to make
105
+ the library comply with the different attribute names
106
+ possible on the bounds element.
107
+
108
+ Formerly, a bounds element with a minlat or minLat attribute
109
+ (instead of
110
+ min_lat) would not be properly parsed. Now all three styles of
111
+ attribute name
112
+ are accepted.
113
+
114
+ 2006-10-28 22:09 dougfales
115
+
116
+ * lib/gpx/segment.rb: Fixing nil time bug.
117
+
118
+ 2006-10-14 13:20 dougfales
119
+
120
+ * ., README, Rakefile, bin, docs, lib, lib/gpx, lib/gpx.rb,
121
+ lib/gpx/bounds.rb, lib/gpx/gpx.rb, lib/gpx/gpx_file.rb,
122
+ lib/gpx/magellan_track_log.rb, lib/gpx/point.rb,
123
+ lib/gpx/route.rb, lib/gpx/segment.rb, lib/gpx/track.rb,
124
+ lib/gpx/trackpoint.rb, lib/gpx/waypoint.rb, tests,
125
+ tests/gpx_files, tests/gpx_files/arches.gpx,
126
+ tests/gpx_files/magellan_track.log,
127
+ tests/gpx_files/one_segment.gpx, tests/gpx_files/one_track.gpx,
128
+ tests/gpx_files/routes.gpx, tests/gpx_files/tracks.gpx,
129
+ tests/gpx_files/waypoints.gpx, tests/magellan_test.rb,
130
+ tests/segment_test.rb, tests/track_file_test.rb,
131
+ tests/track_test.rb: Initial import of gpx gem.
132
+
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  = GPX Gem
2
2
  Copyright (C) 2006 Doug Fales
3
- Doug Fales mailto:doug.fales@gmail.com
3
+ Doug Fales mailto:doug@falesafeconsulting.com
4
4
 
5
5
  == What It Does
6
6
  This library reads GPX files and provides an API for reading and manipulating
@@ -28,7 +28,7 @@ Converting a Magellan track log to GPX:
28
28
 
29
29
  == Notes
30
30
  This library was written to bridge the gap between my Garmin Geko
31
- and my website, WalkingBoss.org. For that reason, it has always been more of a
31
+ and my website, WalkingBoss.org (RIP). For that reason, it has always been more of a
32
32
  work-in-progress than an attempt at full GPX compliance. The track side of the
33
33
  library has seen much more use than the route/waypoint side, so if you're doing
34
34
  something with routes or waypoints, you may need to tweak some things.
@@ -21,7 +21,7 @@
21
21
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  #++
23
23
  module GPX
24
- VERSION = "0.4"
24
+ VERSION = "0.5"
25
25
 
26
26
  # A common base class which provides a useful initializer method to many
27
27
  # class in the GPX library.
@@ -54,13 +54,12 @@ module GPX
54
54
  gpx_file = gpx_file.name if gpx_file.is_a?(File)
55
55
  @xml = XML::Document.file(gpx_file)
56
56
  else
57
- parser = XML::Parser.new
58
- parser.string = opts[:gpx_data]
57
+ parser = XML::Parser.string(opts[:gpx_data])
59
58
  @xml = parser.parse
60
59
  end
61
60
  # set XML namespace for XML find
62
- if @xml.root.namespace_node
63
- @ns = 'gpx:' + @xml.root.namespace_node.href
61
+ if @xml.root.namespaces.namespace
62
+ @ns = 'gpx:' + @xml.root.namespaces.namespace.href
64
63
  else
65
64
  @ns = 'gpx:http://www.topografix.com/GPX/1/1' # default to GPX 1.1
66
65
  end
@@ -197,8 +196,8 @@ module GPX
197
196
  # you modify the GPX data (i.e. by adding or deleting points) and you
198
197
  # want the meta data to accurately reflect the new data.
199
198
  def update_meta_data(trk, get_bounds = true)
200
- @lowest_point = trk.lowest_point if(@lowest_point.nil? or trk.lowest_point.elevation < @lowest_point.elevation)
201
- @highest_point = trk.highest_point if(@highest_point.nil? or trk.highest_point.elevation > @highest_point.elevation)
199
+ @lowest_point = trk.lowest_point if(@lowest_point.nil? or (!trk.lowest_point.nil? and trk.lowest_point.elevation < @lowest_point.elevation))
200
+ @highest_point = trk.highest_point if(@highest_point.nil? or (!trk.highest_point.nil? and trk.highest_point.elevation > @highest_point.elevation))
202
201
  @bounds.add(trk.bounds) if get_bounds
203
202
  @distance += trk.distance
204
203
  end
@@ -236,7 +235,7 @@ module GPX
236
235
  waypoints.each { |w| gpx_elem << w.to_xml } unless waypoints.nil?
237
236
  routes.each { |r| gpx_elem << r.to_xml } unless routes.nil?
238
237
 
239
- doc.save(filename, true)
238
+ doc.save(filename, :indent => true)
240
239
  end
241
240
 
242
241
  private
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright (c) 2006 Doug Fales
2
+ # Copyright (c) 2006 Doug Fales
3
3
  #
4
4
  # Permission is hereby granted, free of charge, to any person obtaining
5
5
  # a copy of this software and associated documentation files (the
@@ -25,7 +25,7 @@ module GPX
25
25
  # The base class for all points. Trackpoint and Waypoint both descend from this base class.
26
26
  class Point < Base
27
27
  D_TO_R = PI/180.0;
28
- attr_accessor :lat, :lon, :time, :elevation, :gpx_file
28
+ attr_accessor :lat, :lon, :time, :elevation, :gpx_file, :speed
29
29
 
30
30
  # When you need to manipulate individual points, you can create a Point
31
31
  # object with a latitude, a longitude, an elevation, and a time. In
@@ -33,18 +33,20 @@ module GPX
33
33
  # relevant info will be parsed out.
34
34
  def initialize(opts = {:lat => 0.0, :lon => 0.0, :elevation => 0.0, :time => Time.now } )
35
35
  @gpx_file = opts[:gpx_file]
36
- if (opts[:element])
36
+ if (opts[:element])
37
37
  elem = opts[:element]
38
38
  @lat, @lon = elem["lat"].to_f, elem["lon"].to_f
39
39
  @latr, @lonr = (D_TO_R * @lat), (D_TO_R * @lon)
40
40
  #'-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?
41
41
  @time = (Time.xmlschema(elem.find("gpx:time", @gpx_file.ns).first.content) rescue nil)
42
42
  @elevation = elem.find("gpx:ele", @gpx_file.ns).first.content.to_f unless elem.find("gpx:ele", @gpx_file.ns).empty?
43
+ @speed = elem.find("gpx:speed", @gpx_file.ns).first.content.to_f unless elem.find("gpx:speed", @gpx_file.ns).empty?
43
44
  else
44
45
  @lat = opts[:lat]
45
46
  @lon = opts[:lon]
46
47
  @elevation = opts[:elevation]
47
48
  @time = opts[:time]
49
+ @speed = opts[:speed]
48
50
  end
49
51
 
50
52
  end
@@ -4,6 +4,7 @@ require File.dirname(__FILE__) + '/../lib/gpx'
4
4
  class GPXFileTest < Test::Unit::TestCase
5
5
 
6
6
  ONE_TRACK_FILE = File.join(File.dirname(__FILE__), "gpx_files/one_track.gpx")
7
+ WITH_OR_WITHOUT_ELEV_FILE = File.join(File.dirname(__FILE__), "gpx_files/with_or_without_elev.gpx")
7
8
  BIG_FILE = File.join(File.dirname(__FILE__), "gpx_files/big.gpx")
8
9
 
9
10
  def test_load_data_from_string
@@ -38,4 +39,10 @@ class GPXFileTest < Test::Unit::TestCase
38
39
  assert_equal(7968, gpx_file.tracks.first.points.size)
39
40
  end
40
41
 
42
+ def test_with_or_with_elev
43
+ gpx_file = GPX::GPXFile.new(:gpx_file => WITH_OR_WITHOUT_ELEV_FILE)
44
+ assert_equal(2, gpx_file.tracks.size)
45
+ #assert_equal(7968, gpx_file.tracks.first.points.size)
46
+ end
47
+
41
48
  end
File without changes
@@ -0,0 +1,29 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
2
+ <gpx xmlns="http://www.topografix.com/GPX/1/1" creator="MapSource 6.5" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
3
+
4
+ <metadata>
5
+ <link href="http://www.garmin.com">
6
+ <text>Garmin International</text>
7
+ </link>
8
+ <time>2007-04-16T18:11:47Z</time>
9
+ <bounds maxlat="40.207429" maxlon="116.670578" minlat="39.876895" minlon="101.636217"/>
10
+ </metadata>
11
+
12
+ <trk>
13
+ <name>ACTIVE LOG</name>
14
+ <trkseg>
15
+ <trkpt lat="40.079434" lon="116.295948">
16
+ <ele>50.606567</ele>
17
+ <time>2007-03-25T05:17:34Z</time>
18
+ </trkpt>
19
+ </trkseg>
20
+ </trk>
21
+
22
+ <trk>
23
+ <name>LINE-13</name>
24
+ <trkseg>
25
+ <trkpt lat="39.949744" lon="116.427398"/>
26
+ </trkseg>
27
+ </trk>
28
+
29
+ </gpx>
@@ -0,0 +1,105 @@
1
+ <?xml version="1.0"?>
2
+ <gpx xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="GPX RubyGem 0.1 Copyright 2006 Doug Fales -- http://walkingboss.com" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
3
+ <metadata>
4
+ <name>new_gpx_file_from_scratch.gpx</name>
5
+ <time>2009-07-06T20:37:26-06:00</time>
6
+ <bounds minlat="90.0" minlon="180.0" maxlat="-90.0" maxlon="-180.0"/>
7
+ </metadata>
8
+ <trk>
9
+ <name/>
10
+ <trkseg>
11
+ <trkpt lat="40.036926" lon="-105.253487">
12
+ <time>2005-12-31T22:01:24Z</time>
13
+ <ele>1737.24</ele>
14
+ </trkpt>
15
+ <trkpt lat="40.036604" lon="-105.253487">
16
+ <time>2005-12-31T22:02:01Z</time>
17
+ <ele>1738.682</ele>
18
+ </trkpt>
19
+ <trkpt lat="40.036347" lon="-105.25383">
20
+ <time>2005-12-31T22:02:08Z</time>
21
+ <ele>1738.682</ele>
22
+ </trkpt>
23
+ <trkpt lat="40.035574" lon="-105.254045">
24
+ <time>2005-12-31T22:02:20Z</time>
25
+ <ele>1737.24</ele>
26
+ </trkpt>
27
+ <trkpt lat="40.035467" lon="-105.254366">
28
+ <time>2005-12-31T22:02:29Z</time>
29
+ <ele>1735.798</ele>
30
+ </trkpt>
31
+ <trkpt lat="40.035317" lon="-105.254388">
32
+ <time>2005-12-31T22:02:33Z</time>
33
+ <ele>1735.798</ele>
34
+ </trkpt>
35
+ <trkpt lat="40.035274" lon="-105.254431">
36
+ <time>2005-12-31T22:02:49Z</time>
37
+ <ele>1736.278</ele>
38
+ </trkpt>
39
+ <trkpt lat="40.035274" lon="-105.254431">
40
+ <time>2005-12-31T22:02:54Z</time>
41
+ <ele>1739.643</ele>
42
+ </trkpt>
43
+ <trkpt lat="40.035317" lon="-105.254431">
44
+ <time>2005-12-31T22:05:08Z</time>
45
+ <ele>1732.433</ele>
46
+ </trkpt>
47
+ <trkpt lat="40.035317" lon="-105.254431">
48
+ <time>2005-12-31T22:05:09Z</time>
49
+ <ele>1726.665</ele>
50
+ </trkpt>
51
+ </trkseg>
52
+ </trk>
53
+ <wpt lat="39.997298" lon="-105.292674">
54
+ <name>GRG-CA</name>
55
+ <sym>Waypoint</sym>
56
+ <ele>1766.535</ele>
57
+ </wpt>
58
+ <wpt lat="33.33019" lon="-111.94611">
59
+ <name>GRMPHX</name>
60
+ <cmt>Hey here's a comment.</cmt>
61
+ <desc>Somewhere in my backyard.</desc>
62
+ <sym>Waypoint</sym>
63
+ <fix>3d</fix>
64
+ <sat>8</sat>
65
+ <hdop>50.5</hdop>
66
+ <vdop>6.8</vdop>
67
+ <pdop>7.6</pdop>
68
+ <ele>361.0981</ele>
69
+ </wpt>
70
+ <wpt lat="25.061783" lon="121.640267">
71
+ <name>GRMTWN</name>
72
+ <sym>Waypoint</sym>
73
+ <ele>38.09766</ele>
74
+ </wpt>
75
+ <wpt lat="39.99984" lon="-105.214696">
76
+ <name>SBDR</name>
77
+ <sym>Waypoint</sym>
78
+ <ele>1612.965</ele>
79
+ </wpt>
80
+ <wpt lat="39.989739" lon="-105.295285">
81
+ <name>TO</name>
82
+ <sym>Waypoint</sym>
83
+ <ele>2163.556</ele>
84
+ </wpt>
85
+ <wpt lat="40.035301" lon="-105.254443">
86
+ <name>VICS</name>
87
+ <sym>Waypoint</sym>
88
+ <ele>1535.34</ele>
89
+ </wpt>
90
+ <rte>
91
+ <name/>
92
+ <rtept lat="40.035467" lon="-105.254366">
93
+ <time>2005-12-31T22:02:29Z</time>
94
+ <ele>1735.798</ele>
95
+ </rtept>
96
+ <rtept lat="40.035317" lon="-105.254388">
97
+ <time>2005-12-31T22:02:33Z</time>
98
+ <ele>1735.798</ele>
99
+ </rtept>
100
+ <rtept lat="40.035274" lon="-105.254431">
101
+ <time>2005-12-31T22:02:49Z</time>
102
+ <ele>1736.278</ele>
103
+ </rtept>
104
+ </rte>
105
+ </gpx>
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpx
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.4"
4
+ version: "0.5"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doug Fales
@@ -9,11 +9,11 @@ autorequire: gpx
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-18 00:00:00 -07:00
12
+ date: 2009-07-06 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: A basic API for reading and writing GPX files.
16
+ description: " A basic API for reading and writing GPX files.\n"
17
17
  email: doug.fales@gmail.com
18
18
  executables: []
19
19
 
@@ -22,7 +22,6 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
- - lib/gpx
26
25
  - lib/gpx/bounds.rb
27
26
  - lib/gpx/gpx.rb
28
27
  - lib/gpx/gpx_file.rb
@@ -36,7 +35,6 @@ files:
36
35
  - lib/gpx.rb
37
36
  - tests/gpx10_test.rb
38
37
  - tests/gpx_file_test.rb
39
- - tests/gpx_files
40
38
  - tests/gpx_files/arches.gpx
41
39
  - tests/gpx_files/big.gpx
42
40
  - tests/gpx_files/gpx10.gpx
@@ -46,18 +44,22 @@ files:
46
44
  - tests/gpx_files/routes.gpx
47
45
  - tests/gpx_files/tracks.gpx
48
46
  - tests/gpx_files/waypoints.gpx
47
+ - tests/gpx_files/with_or_without_elev.gpx
49
48
  - tests/magellan_test.rb
50
- - tests/output
49
+ - tests/output/new_gpx_file_from_scratch.gpx
51
50
  - tests/output_test.rb
52
51
  - tests/route_test.rb
53
52
  - tests/segment_test.rb
54
53
  - tests/track_file_test.rb
55
54
  - tests/track_test.rb
56
55
  - tests/waypoint_test.rb
56
+ - ChangeLog
57
57
  - Rakefile
58
58
  - README
59
59
  has_rdoc: true
60
60
  homepage: http://gpx.rubyforge.com/
61
+ licenses: []
62
+
61
63
  post_install_message:
62
64
  rdoc_options: []
63
65
 
@@ -78,9 +80,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
80
  requirements: []
79
81
 
80
82
  rubyforge_project:
81
- rubygems_version: 1.0.1
83
+ rubygems_version: 1.3.2
82
84
  signing_key:
83
- specification_version: 2
85
+ specification_version: 3
84
86
  summary: A basic API for reading and writing GPX files.
85
87
  test_files: []
86
88