-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from dougfales/chores/bump-nokogiri-and-ruby-deps
Release 0.9.0, which updates a dep on Nokogiri, which updates a dep on Ruby
- Loading branch information
Showing
4 changed files
with
27 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,6 @@ | |
[<img src="https://travis-ci.org/dougfales/gpx.svg" alt="Build Status" />](https://travis-ci.org/dougfales/gpx) | ||
[![Code Climate](https://codeclimate.com/github/dougfales/gpx/badges/gpa.svg)](https://codeclimate.com/github/dougfales/gpx) | ||
|
||
Copyright (C) 2006 Doug Fales [email protected] | ||
|
||
Released under the MIT License. | ||
|
||
## What It Does | ||
|
||
This library reads GPX files and provides an API for reading and manipulating | ||
|
@@ -19,9 +15,14 @@ rectangular areas within a file, and it also calculates some meta-data about | |
the tracks and points in a file (such as distance, duration, average speed, | ||
etc). | ||
|
||
## Requirements | ||
|
||
As of `0.9.0`, `gpx` requires at least Ruby 2.1 to run. | ||
|
||
## Examples | ||
|
||
Reading a GPX file, and cropping its contents to a given area: | ||
|
||
```ruby | ||
gpx = GPX::GPXFile.new(:gpx_file => filename) # Read GPX file | ||
bounds = GPX::Bounds.new(params) # Create a rectangular area to crop | ||
|
@@ -41,28 +42,28 @@ Exporting an ActiveRecord to GPXFile (as Waypoints) | |
# | ||
# Our active record in this example is called stop | ||
# | ||
# models/stop.rb | ||
|
||
# models/stop.rb | ||
class Stop < ActiveRecord::Base | ||
# This model has the following attributes: | ||
# name | ||
# lat | ||
# lon | ||
# updated_at | ||
|
||
def self.to_gpx | ||
require 'GPX' | ||
gpx = GPX::GPXFile.new | ||
all.each do |stop| | ||
gpx.waypoints << GPX::Waypoint.new({name: stop.name, lat: stop.lat, lon: stop.lon, time: stop.updated_at}) | ||
end | ||
end | ||
gpx.to_s | ||
end | ||
end # class | ||
|
||
|
||
# controllers/stops.rb | ||
def index | ||
def index | ||
@stops = Stop.all | ||
respond_to do |format| | ||
format.html {render :index} | ||
|
@@ -73,8 +74,8 @@ end | |
|
||
# Add this line to config/initializers/mime_types.rb | ||
Mime::Type.register "application/gpx+xml", :gpx | ||
|
||
|
||
# To get the xml file: | ||
# http://localhost:3000/stops.gpx | ||
``` | ||
|
@@ -88,13 +89,17 @@ This library was written to bridge the gap between my Garmin Geko | |
and my website, WalkingBoss.org (RIP). For that reason, it has always been more of a | ||
work-in-progress than an attempt at full GPX compliance. The track side of the | ||
library has seen much more use than the route/waypoint side, so if you're doing | ||
something with routes or waypoints, you may need to tweak some things. | ||
something with routes or waypoints, you may need to tweak some things. | ||
|
||
Since this code uses XML to read an entire GPX file into memory, it is not | ||
the fastest possible solution for working with GPX data, especially if you are | ||
working with tracks from several days or weeks. | ||
working with tracks from several days or weeks. | ||
|
||
Finally, it should be noted that none of the distance/speed calculation or | ||
crop/delete code has been tested under International Date Line-crossing | ||
conditions. That particular part of the code will likely be unreliable if | ||
you're zig-zagging across 180 degrees longitude routinely. | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module GPX | ||
VERSION = "0.8.3" | ||
VERSION = "0.9.0" | ||
end |