diff --git a/ChangeLog b/ChangeLog index f034193..12f1d0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,132 +1,60 @@ -2009-07-07 02:51 dougfales +2010-02-27 Doug Fales + * Putting the gem building stuff into a gemspec. + * Fixing some tests since git does not believe in empty directories. + * Fixing README formatting. - * lib/gpx/gpx.rb: Revving to version 0.5. +2010-02-27 Doug Fales + * README edits. + * More rdoc tweaks. + * Changing README to rdoc ext for github. -2009-07-07 02:43 dougfales +2009-10-13 Doug Fales + * Adding the ability to write GPX to a string in addition to a file. Thanks to Douglas Robertson for the patch. - * README: Changing my contact email address. +2009-09-27 Doug Fales + * Adding a patch from Douglas Robertson that allows using version 1.0 of the schema for output. -2009-07-07 02:41 dougfales +2009-07-07 Doug Fales + * Adding changelog. + * Revving to version 0.5. + * Changing my contact email address. + * Patches from Tom Verbeure (mtbguru.com) to work with libxml-ruby 1.x. - * lib/gpx/gpx_file.rb, tests/gpx_file_test.rb, - tests/gpx_files/with_or_without_elev.gpx: Patches from Tom - Verbeure (mtbguru.com) to work with libxml-ruby 1.x. +2009-06-17 Doug Fales + * Patch from Kang-min Liu to support speed element. -2009-06-17 14:20 dougfales +2008-02-19 Doug Fales + * Revving to 0.4. + * Adding some new unit tests and fixing several file export bugs reported by Jochen Topf. New unit tests also uncovered a bug where the number of trackpoints reported in a file was twice the actual number. - * lib/gpx/point.rb: Patch from Kang-min Liu to support speed - element. +2008-02-11 Doug Fales + * Going to version 0.3. + * Updating unit tests in light of recent fixes to routes and waypoints code. -2008-02-19 04:09 dougfales +2008-02-08 Doug Fales + * Thanks to Mike Gauland for discovering some route- and waypoint-related bugs. I've fixed them and also added #to_s on Waypoint so it's easier to debug. - * lib/gpx/gpx.rb: Revving to 0.4. +2007-12-04 Doug Fales + * Thanks to Christian Koerner for finding and fixing these bugs in the waypoint code. + * Another patch from Gaku Ueda. This one allows you to pass in a string of GPX data using the :gpx_date => option. Thanks Gaku! -2008-02-19 04:06 dougfales +2007-11-30 Doug Fales + * Updating the version #. + * Updates courtesy of Gaku Ueda: * Adding support for GPX 1.0 as well as 1.1 (since libxml namespace parsing was hard-coded to 1.1. previously). * Adding a GPX 1.0 unit test file. * Miscellaneous updates to make it work with Ruby 1.8.6. - * lib/gpx/gpx.rb, lib/gpx/gpx_file.rb, lib/gpx/point.rb, - lib/gpx/route.rb, lib/gpx/track.rb, lib/gpx/waypoint.rb, - tests/gpx_file_test.rb, tests/gpx_files, tests/gpx_files/big.gpx, - tests/output, tests/output_test.rb, tests/track_test.rb: Adding - some new unit tests and fixing several file export bugs reported - by Jochen Topf. - New unit tests also uncovered a bug where the number of - trackpoints reported in a file was twice the actual number. +2006-12-04 Doug Fales + * First stab at using libxml-ruby instead of REXML. I'm seeing the unit tests finish in under 14 seconds. That is compared to 2 minutes using REXML. -2008-02-11 21:20 dougfales +2006-12-03 Doug Fales + * Fixing more nil time exceptions. + * Fixing an exception in contains_time?. - * lib/gpx/gpx.rb: Going to version 0.3. +2006-11-28 Doug Fales + * A couple of fixes to make the library comply with the different attribute names possible on the bounds element. -2008-02-11 21:13 dougfales +2006-10-28 Doug Fales + * Fixing nil time bug. - * tests/gpx10_test.rb, tests/gpx_files/routes.gpx, - tests/gpx_files/waypoints.gpx, tests/magellan_test.rb, - tests/route_test.rb, tests/segment_test.rb, - tests/track_file_test.rb, tests/track_test.rb, - tests/waypoint_test.rb: Updating unit tests in light of recent - fixes to routes and waypoints code. - -2008-02-08 23:26 dougfales - - * lib/gpx/gpx.rb, lib/gpx/point.rb, lib/gpx/route.rb, - lib/gpx/waypoint.rb: Thanks to Mike Gauland for discovering some - route- and waypoint-related bugs. I've fixed them and also added - #to_s on Waypoint so it's easier to debug. - -2007-12-04 17:58 dougfales - - * lib/gpx/waypoint.rb: Thanks to Christian Koerner for finding and - fixing these bugs in the waypoint - code. - -2007-12-04 17:52 dougfales - - * lib/gpx/gpx_file.rb, tests/gpx_file_test.rb: Another patch from - Gaku Ueda. This one allows you to pass in a string of GPX - data using the :gpx_date => option. Thanks Gaku! - -2007-11-30 06:29 dougfales - - * lib/gpx/gpx.rb: Updating the version #. - -2007-11-30 06:26 dougfales - - * lib/gpx/gpx.rb, lib/gpx/gpx_file.rb, lib/gpx/point.rb, - lib/gpx/route.rb, lib/gpx/segment.rb, lib/gpx/track.rb, - tests/gpx10_test.rb, tests/gpx_files/gpx10.gpx: Updates courtesy - of Gaku Ueda: - * Adding support for GPX 1.0 as well as 1.1 (since libxml - namespace parsing - was hard-coded to 1.1. previously). - * Adding a GPX 1.0 unit test file. - * Miscellaneous updates to make it work with Ruby 1.8.6. - -2006-12-04 06:47 dougfales - - * README, lib/gpx.rb, lib/gpx/bounds.rb, lib/gpx/gpx.rb, - lib/gpx/gpx_file.rb, lib/gpx/point.rb, lib/gpx/route.rb, - lib/gpx/segment.rb, lib/gpx/track.rb, lib/gpx/waypoint.rb, - tests/segment_test.rb: First stab at using libxml-ruby instead of - REXML. I'm seeing the unit tests - finish in under 14 seconds. That is compared to 2 minutes using - REXML. - -2006-12-03 07:31 dougfales - - * lib/gpx/point.rb, lib/gpx/segment.rb: Fixing more nil time - exceptions. - -2006-12-03 06:59 dougfales - - * lib/gpx/segment.rb: Fixing an exception in contains_time?. - -2006-11-28 15:35 dougfales - - * lib/gpx/bounds.rb, lib/gpx/gpx_file.rb: A couple of fixes to make - the library comply with the different attribute names - possible on the bounds element. - - Formerly, a bounds element with a minlat or minLat attribute - (instead of - min_lat) would not be properly parsed. Now all three styles of - attribute name - are accepted. - -2006-10-28 22:09 dougfales - - * lib/gpx/segment.rb: Fixing nil time bug. - -2006-10-14 13:20 dougfales - - * ., README, Rakefile, bin, docs, lib, lib/gpx, lib/gpx.rb, - lib/gpx/bounds.rb, lib/gpx/gpx.rb, lib/gpx/gpx_file.rb, - lib/gpx/magellan_track_log.rb, lib/gpx/point.rb, - lib/gpx/route.rb, lib/gpx/segment.rb, lib/gpx/track.rb, - lib/gpx/trackpoint.rb, lib/gpx/waypoint.rb, tests, - tests/gpx_files, tests/gpx_files/arches.gpx, - tests/gpx_files/magellan_track.log, - tests/gpx_files/one_segment.gpx, tests/gpx_files/one_track.gpx, - tests/gpx_files/routes.gpx, tests/gpx_files/tracks.gpx, - tests/gpx_files/waypoints.gpx, tests/magellan_test.rb, - tests/segment_test.rb, tests/track_file_test.rb, - tests/track_test.rb: Initial import of gpx gem. +2006-10-14 Doug Fales + * Initial import of gpx gem. diff --git a/lib/gpx/waypoint.rb b/lib/gpx/waypoint.rb index 85b44eb..f1d00a6 100644 --- a/lib/gpx/waypoint.rb +++ b/lib/gpx/waypoint.rb @@ -23,74 +23,74 @@ module GPX - # This class supports the concept of a waypoint. Beware that this class has - # not seen much use yet, since WalkingBoss does not use waypoints right now. - class Waypoint < Point + # This class supports the concept of a waypoint. Beware that this class has + # not seen much use yet, since WalkingBoss does not use waypoints right now. + class Waypoint < Point - SUB_ELEMENTS = %w{ magvar geoidheight name cmt desc src link sym type fix sat hdop vdop pdop ageofdgpsdata dgpsid extensions } + SUB_ELEMENTS = %w{ magvar geoidheight name cmt desc src link sym type fix sat hdop vdop pdop ageofdgpsdata dgpsid extensions } - attr_reader :gpx_file - SUB_ELEMENTS.each { |sub_el| attr_accessor sub_el.to_sym } + attr_reader :gpx_file + SUB_ELEMENTS.each { |sub_el| attr_accessor sub_el.to_sym } - # Not implemented - def crop(area) + # Not implemented + def crop(area) + end + + # Not implemented + def delete_area(area) + end + + # Initializes a waypoint from a XML::Node. + def initialize(opts = {}) + if(opts[:element] and opts[:gpx_file]) + wpt_elem = opts[:element] + @gpx_file = opts[:gpx_file] + super(:element => wpt_elem, :gpx_file => @gpx_file) + instantiate_with_text_elements(wpt_elem, SUB_ELEMENTS, @gpx_file.ns) + else + opts.each do |key, value| + assignment_method = "#{key}=" + if self.respond_to?(assignment_method) + self.send(assignment_method, value) + end + end end + end - # Not implemented - def delete_area(area) + # Prints out a friendly summary of this track (sans points). Useful for + # debugging and sanity checks. + def to_s + result = "Waypoint \n" + result << "\tName: #{name}\n" + result << "\tLatitude: #{lat} \n" + result << "\tLongitude: #{lon} \n" + result << "\tElevation: #{elevation}\n " + result << "\tTime: #{time}\n" + SUB_ELEMENTS.each do |sub_element_attribute| + val = self.send(sub_element_attribute) + result << "\t#{sub_element_attribute}: #{val}\n" unless val.nil? end + result + end - # Initializes a waypoint from a XML::Node. - def initialize(opts = {}) - if(opts[:element] and opts[:gpx_file]) - wpt_elem = opts[:element] - @gpx_file = opts[:gpx_file] - super(:element => wpt_elem, :gpx_file => @gpx_file) - instantiate_with_text_elements(wpt_elem, SUB_ELEMENTS, @gpx_file.ns) - else - opts.each do |key, value| - assignment_method = "#{key}=" - if self.respond_to?(assignment_method) - self.send(assignment_method, value) - end - end - end + # Converts a waypoint to a XML::Node. + def to_xml(elem_name = 'wpt') + wpt = Node.new(elem_name) + wpt['lat'] = lat.to_s + wpt['lon'] = lon.to_s + SUB_ELEMENTS.each do |sub_element_name| + if(self.respond_to?(sub_element_name) and (!self.send(sub_element_name).nil?)) + sub_elem_node = Node.new(sub_element_name) + sub_elem_node << self.send(sub_element_name) + wpt << sub_elem_node + end end - - # Prints out a friendly summary of this track (sans points). Useful for - # debugging and sanity checks. - def to_s - result = "Waypoint \n" - result << "\tName: #{name}\n" - result << "\tLatitude: #{lat} \n" - result << "\tLongitude: #{lon} \n" - result << "\tElevation: #{elevation}\n " - result << "\tTime: #{time}\n" - SUB_ELEMENTS.each do |sub_element_attribute| - val = self.send(sub_element_attribute) - result << "\t#{sub_element_attribute}: #{val}\n" unless val.nil? - end - result + unless(self.elevation.nil?) + ele_node = Node.new('ele') + ele_node << self.elevation + wpt << ele_node end - - # Converts a waypoint to a XML::Node. - def to_xml(elem_name = 'wpt') - wpt = Node.new(elem_name) - wpt['lat'] = lat.to_s - wpt['lon'] = lon.to_s - SUB_ELEMENTS.each do |sub_element_name| - if(self.respond_to?(sub_element_name) and (!self.send(sub_element_name).nil?)) - sub_elem_node = Node.new(sub_element_name) - sub_elem_node << self.send(sub_element_name) - wpt << sub_elem_node - end - end - unless(self.elevation.nil?) - ele_node = Node.new('ele') - ele_node << self.elevation - wpt << ele_node - end - wpt - end - end + wpt + end + end end