gpx_doctor 0.6.1 → 0.6.2
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.
- checksums.yaml +4 -4
- data/README.md +17 -8
- data/lib/gpx_doctor/parser.rb +21 -2
- data/lib/gpx_doctor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '08f52b7255e18952f838ad2b348a8df20059212c1ef8109d19d09d2ac7a9eb64'
|
|
4
|
+
data.tar.gz: 9ad7a941a8e3fa217560e9bf2acc64984ffe33cdb4b639e1288a027a5d8f8714
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f0ba58080565539a3d32e89cfb17f26b8712205e3f62a47dbcb03a61bdac557b3e46b36b634249fc5dd24422f137a8afebddeaed127b908a5d94123ec8a58b17
|
|
7
|
+
data.tar.gz: 523325873b587abd8a951d72d3ef9ec4ec26b5b996ddd2b86518e2c9a4e4fd50fdb7a1beed9d932f91390822ab56c670ef1f701a8f9de90fb98232c3226c9dcf
|
data/README.md
CHANGED
|
@@ -116,19 +116,28 @@ Processing is applied in the following order:
|
|
|
116
116
|
## Accessing data
|
|
117
117
|
|
|
118
118
|
```ruby
|
|
119
|
-
result.points
|
|
120
|
-
result.
|
|
121
|
-
result.
|
|
122
|
-
result.
|
|
123
|
-
result.
|
|
124
|
-
result.
|
|
119
|
+
result.points # => [#<Waypoint lat=…, lon=…, ele=…>, …] (the path)
|
|
120
|
+
result.all_points # => [#<Waypoint …>, …] (the path plus standalone waypoints)
|
|
121
|
+
result.waypoints # => [#<Waypoint …>] (top-level <wpt> elements only)
|
|
122
|
+
result.routes # => [#<Route …>]
|
|
123
|
+
result.tracks # => [#<Track …>]
|
|
124
|
+
result.metadata # => #<Metadata …> (or nil)
|
|
125
|
+
result.pois # => Hash (only when parsed with full_poi_data: true, otherwise nil)
|
|
125
126
|
```
|
|
126
127
|
|
|
127
|
-
`result.points` is a flat array
|
|
128
|
-
- Top-level `<wpt>` elements
|
|
128
|
+
`result.points` is a flat array describing **the path**, in order:
|
|
129
129
|
- `<rtept>` elements inside each `<rte>`
|
|
130
130
|
- `<trkpt>` elements inside each `<trkseg>` inside each `<trk>`
|
|
131
131
|
|
|
132
|
+
Top-level `<wpt>` elements are **not** included. They are points of interest that may
|
|
133
|
+
sit anywhere on — or off — the path, and exporters list them in file order rather than
|
|
134
|
+
path order, so treating them as path points draws straight lines back and forth across
|
|
135
|
+
the map. Read them from `result.waypoints`, or use `result.all_points` (standalone
|
|
136
|
+
waypoints first, then the path) when you genuinely want every geographic point in the
|
|
137
|
+
file. All processing params (`max_points`, `cumulative_distance`, `label_interval`,
|
|
138
|
+
`segment_statistics`, `full_poi_data`) operate on the path only; `enhance_elevation` is
|
|
139
|
+
the exception and fills in elevations for standalone waypoints too.
|
|
140
|
+
|
|
132
141
|
### `result.pois`
|
|
133
142
|
|
|
134
143
|
When parsed with `full_poi_data: true`, `result.pois` contains boundary data for the entire GPX and each track segment:
|
data/lib/gpx_doctor/parser.rb
CHANGED
|
@@ -8,8 +8,25 @@ module GpxDoctor
|
|
|
8
8
|
GPX_NS = 'http://www.topografix.com/GPX/1/1'
|
|
9
9
|
|
|
10
10
|
Result = Struct.new(:waypoints, :routes, :tracks, :metadata, :pois, keyword_init: true) do
|
|
11
|
+
# The path described by the file, in order: <rtept> then <trkpt>.
|
|
12
|
+
#
|
|
13
|
+
# Standalone <wpt> elements are deliberately NOT part of it. They are
|
|
14
|
+
# points of interest scattered anywhere on (or off) the path — exporters
|
|
15
|
+
# such as komoot emit them for highlights like bridges or churches — so
|
|
16
|
+
# folding them in front of the path turns a valid route into a zig-zag of
|
|
17
|
+
# straight lines back and forth across the whole map. Every other stage of
|
|
18
|
+
# the gem (split_segments, select_max_points, enhance_statistics,
|
|
19
|
+
# enhance_cumulative_distance, label_points, build_pois) already walks
|
|
20
|
+
# routes and track segments only; this makes #points agree with them.
|
|
21
|
+
#
|
|
22
|
+
# Use #all_points for every geographic point in the file, waypoints included.
|
|
11
23
|
def points
|
|
12
|
-
|
|
24
|
+
routes.flat_map(&:points) + tracks.flat_map(&:points)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Every geographic point in the file: standalone waypoints followed by the path.
|
|
28
|
+
def all_points
|
|
29
|
+
waypoints + points
|
|
13
30
|
end
|
|
14
31
|
end
|
|
15
32
|
|
|
@@ -224,7 +241,9 @@ module GpxDoctor
|
|
|
224
241
|
config = GpxDoctor.configuration
|
|
225
242
|
return unless config.elevation_server && config.elevation_server_url
|
|
226
243
|
|
|
227
|
-
|
|
244
|
+
# all_points, not points: standalone waypoints are POIs the caller still
|
|
245
|
+
# wants an elevation for, even though they are not part of the path.
|
|
246
|
+
ElevationClient.new.enhance(result.all_points)
|
|
228
247
|
end
|
|
229
248
|
|
|
230
249
|
def effective_max_distance(result)
|
data/lib/gpx_doctor/version.rb
CHANGED