-
Notifications
You must be signed in to change notification settings - Fork 3
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 #3 from felt/waypoints-and-routes
Add support for waypoints and routes
- Loading branch information
Showing
9 changed files
with
216 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
defmodule GpxEx.Gpx do | ||
@type t :: %__MODULE__{tracks: list(GpxEx.Track.t)} | ||
@typedoc """ | ||
A struct representing a fully parsed GPX file. | ||
defstruct tracks: nil | ||
GPX files may contain zero or more: | ||
- Tracks—ordered lists of points describing a path someone traveled. | ||
- Routes—ordered lists of waypoints representing a series of turn points | ||
leading to a destination. Whereas a track might sample the GPS location | ||
of actual movements at some interval, a route represents directions | ||
such as you might get from a routing application. | ||
- Waypoints—a point of interest or named feature on a map. | ||
""" | ||
@type t :: %__MODULE__{ | ||
tracks: list(GpxEx.Track.t()), | ||
waypoints: list(GpxEx.Waypoint.t()), | ||
routes: list(GpxEx.Route.t()) | ||
} | ||
|
||
defstruct tracks: [], waypoints: [], routes: [] | ||
end |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
defmodule GpxEx.Route do | ||
@typedoc """ | ||
A struct representing a route, an idealized list of turn points that describe | ||
the directions one should follow to go from one place to another. | ||
""" | ||
@type t :: %__MODULE__{points: list(GpxEx.Waypoint.t()), name: String.t() | nil} | ||
|
||
defstruct points: [], name: nil | ||
end |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
defmodule GpxEx.Waypoint do | ||
@enforce_keys [:lat, :lon] | ||
defstruct @enforce_keys ++ | ||
[ | ||
ele: nil, | ||
name: nil, | ||
symbol: nil, | ||
description: nil, | ||
url: nil | ||
] | ||
|
||
@typedoc """ | ||
A single waypoint, which may be part of a route or | ||
a standalone point-of-interest or named feature. | ||
- Lon and lat are in decimal degrees | ||
- Elevation is in meters (presumably above mean sea level) | ||
""" | ||
@type t :: %__MODULE__{ | ||
lat: float(), | ||
lon: float(), | ||
ele: float() | nil, | ||
name: String.t() | nil, | ||
symbol: String.t() | nil, | ||
description: String.t() | nil, | ||
url: String.t() | nil | ||
} | ||
end |
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 @@ | ||
%{ | ||
"sweet_xml": {:hex, :sweet_xml, "0.6.6", "fc3e91ec5dd7c787b6195757fbcf0abc670cee1e4172687b45183032221b66b8", [:mix], [], "hexpm", "2e1ec458f892ffa81f9f8386e3f35a1af6db7a7a37748a64478f13163a1f3573"}, | ||
"sweet_xml": {:hex, :sweet_xml, "0.7.3", "debb256781c75ff6a8c5cbf7981146312b66f044a2898f453709a53e5031b45b", [:mix], [], "hexpm", "e110c867a1b3fe74bfc7dd9893aa851f0eed5518d0d7cad76d7baafd30e4f5ba"}, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0"?> | ||
<gpx xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:gpx="http://www.topografix.com/GPX/1/0" version="1.0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> | ||
<rte> | ||
<name><![CDATA[Sample route]]></name> | ||
<desc>Fake route</desc> | ||
<rtept lat="39.2" lon="-94.5"> | ||
<ele>388.1</ele> | ||
<name>Point 1</name> | ||
</rtept> | ||
<rtept lat="-19.9" lon="120.4"> | ||
<name>Point 2</name> | ||
</rtept> | ||
<rtept lat="-0.2" lon="-0.1"> | ||
<name>Point 3</name> | ||
</rtept> | ||
<rtept lat="0.4" lon="0.2"> | ||
<name>Point 4</name> | ||
<ele>-0.1</ele> | ||
</rtept> | ||
</rte> | ||
</gpx> |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0"?> | ||
<gpx xmlns="http://www.topografix.com/GPX/1/0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:gpx="http://www.topografix.com/GPX/1/0" version="1.0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd"> | ||
<wpt lat="39.2" lon="-94.5"> | ||
<name>Kansas City, MO</name> | ||
<sym>City</sym> | ||
<desc>Midwestern city</desc> | ||
<url>https://www.visitkc.com</url> | ||
<ele>308.15</ele> | ||
</wpt> | ||
<wpt lat="32.7" lon="-117.2"> | ||
<sym>City</sym> | ||
<name>San Diego, CA</name> | ||
<url>https://www.sandiego.gov/</url> | ||
<desc>Port city</desc> | ||
</wpt> | ||
<wpt lat="36.4" lon="-94.2"> | ||
<ele>395</ele> | ||
<url>http://bentonvillear.com/</url> | ||
<name>Bentonville, AR</name> | ||
<sym>Town</sym> | ||
</wpt> | ||
</gpx> |