Gpex (gpex v0.8.0)

Summary

Functions

Builds a Gpex struct from a list of attributes and children

Functions

Link to this function

new(attrs, children)

Builds a Gpex struct from a list of attributes and children:

iex> Gpex.new(%{}, []) %Gpex{}

By default, attributes are set to standard values and tracks and waypoints are set to empty lists:

iex> Gpex.new(%{}, []) %Gpex{ creator: "Gpex", version: "1.1", xmlns: "http://www.topografix.com/GPX/1/1", "xmlns:topografix": "http://www.topografix.com/GPX/Private/TopoGrafix/0/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 http://www.topografix.com/GPX/Private/TopoGrafix/0/1 http://www.topografix.com/GPX/Private/TopoGrafix/0/1/topografix.xsd",

tracks: [], waypoints: [] }

All top-level attributes can be overridden:

iex> Gpex.new(%{creator: "Custom Creator"}, []) %Gpex{creator: "Custom Creator"}

Attribute keys can be strings or atoms:

iex> Gpex.new(%{"version" => "1.0"}, []) %Gpex{version: "1.0"}

The children of the GPX element are parsed into tracks and waypoints: iex> Gpex.new(%{}, [ ...> {"trk", %{}, [ ...> {"desc", %{}, ["Track 1"]}, ...> {"trkseg", %{}, [ ...> {"trkpt", %{"lat" => "43.553252", "lon" => "11.707813"}, [ ...> {"ele", %{}, ["307.6000061035156"]}, ...> {"time", %{}, ["2023-10-01T12:00:00Z"]} ...> ]}, ...> {"trkpt", %{"lat" => "43.554252", "lon" => "11.708813"}, [ ...> {"ele", %{}, ["308.6000061035156"]}, ...> {"time", %{}, ["2023-10-01T12:01:00Z"]} ...> ]} ...> ]} ...> ]}, ...> {"wpt", %{"lat" => "43.553252", "lon" => "11.707813"}, [ ...> {"name", %{}, ["A point of interest"]}, ...> {"ele", %{}, ["307.6000061035156"]} ...> ]} ...> ]) %Gpex{ tracks: [

%Gpex.Track{
  description: "Track 1",
  segments: [
    %Gpex.TrackSegment{
      points: [
        %Gpex.Point{latitude: 43.553252, longitude: 11.707813, elevation: 307.6000061035156},
        %Gpex.Point{latitude: 43.554252, longitude: 11.708813, elevation: 308.6000061035156}
      ]
    }
  ]
}

], waypoints: [

%Gpex.Waypoint{
  name: "A point of interest",
  latitude: 43.553252,
  longitude: 11.707813,
  elevation: 307.6000061035156
}

] }