natour 0.5.0 → 0.6.0
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/CHANGELOG.adoc +7 -0
- data/lib/natour/gps_track.rb +4 -0
- data/lib/natour/gpx_file.rb +16 -13
- data/lib/natour/image.rb +2 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c599b25a1b97e3eb894161d80065d2359a7530371e40335702100b79510b013
|
4
|
+
data.tar.gz: '0892297dde6afb7de1a193d0bfe903ce6810d17b5a10c23bd5d0433b4cbde702'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce5fd7ebedd87c7c4dcf529a90878cdeab5dac805362407b9be3becee524aaa3d616d44f62f6bf4d4d8fc694741f607cdff2bb69a134407cbe7d4ac9c70330bf
|
7
|
+
data.tar.gz: 6f92ed19ec2f32eb4933630937ecb2d0fe597e466b6c3057aacfe070f971820d0e03a0dff28eb3d61e1ffea4db6bfd61091da8830c005a7cc8f3a184e450612a
|
data/CHANGELOG.adoc
CHANGED
@@ -6,6 +6,13 @@ The format is based on https://keepachangelog.com/en/1.0.0/[Keep a Changelog^],
|
|
6
6
|
|
7
7
|
== Unreleased
|
8
8
|
|
9
|
+
== 0.6.0 - 2021-11-20
|
10
|
+
|
11
|
+
=== Fixed
|
12
|
+
|
13
|
+
- Support GPX files containing only mandatory elements (i.e. no extensions)
|
14
|
+
- Consider also the image dimensions to determine the orientation, even if the tag is present
|
15
|
+
|
9
16
|
== 0.5.0 - 2021-08-16
|
10
17
|
|
11
18
|
=== Added
|
data/lib/natour/gps_track.rb
CHANGED
@@ -71,10 +71,14 @@ module Natour
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def round_duration(duration, hours: 0, minutes: 0, seconds: 0)
|
74
|
+
return unless duration
|
75
|
+
|
74
76
|
Duration.new(round_multiple_of(duration.to_i, (hours * 60 + minutes) * 60 + seconds))
|
75
77
|
end
|
76
78
|
|
77
79
|
def round_time(time, hours: 0, minutes: 0, seconds: 0)
|
80
|
+
return unless time
|
81
|
+
|
78
82
|
Time.at(round_multiple_of(time.to_i, (hours * 60 + minutes) * 60 + seconds))
|
79
83
|
end
|
80
84
|
end
|
data/lib/natour/gpx_file.rb
CHANGED
@@ -1,26 +1,29 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'duration'
|
3
|
-
require '
|
4
|
-
require 'time'
|
3
|
+
require 'timeliness'
|
5
4
|
|
6
5
|
module Natour
|
7
6
|
class GPXFile < GPSTrack
|
7
|
+
GPX_XMLNS = {
|
8
|
+
'xmlns' => 'http://www.topografix.com/GPX/1/1',
|
9
|
+
'xmlns:gpxtrkx' => 'http://www.garmin.com/xmlschemas/TrackStatsExtension/v1'
|
10
|
+
}.freeze
|
11
|
+
|
8
12
|
def initialize(filename)
|
9
13
|
@doc = Nokogiri.XML(File.read(filename, mode: 'r:utf-8'))
|
10
14
|
|
11
|
-
|
12
|
-
stats = @doc.at('/xmlns:gpx/xmlns:trk/xmlns:extensions/gpxtrkx:TrackStatsExtension')
|
15
|
+
stats = @doc.at('/xmlns:gpx/xmlns:trk/xmlns:extensions/gpxtrkx:TrackStatsExtension', GPX_XMLNS)
|
13
16
|
if stats
|
14
|
-
ascent = stats.at('./gpxtrkx:Ascent').text.to_i
|
15
|
-
descent = stats.at('./gpxtrkx:Descent').text.to_i
|
16
|
-
distance = stats.at('./gpxtrkx:Distance').text.to_i
|
17
|
-
duration = Duration.new(stats.at('./gpxtrkx:TotalElapsedTime').text.to_i)
|
17
|
+
ascent = stats.at('./gpxtrkx:Ascent', GPX_XMLNS).text.to_i
|
18
|
+
descent = stats.at('./gpxtrkx:Descent', GPX_XMLNS).text.to_i
|
19
|
+
distance = stats.at('./gpxtrkx:Distance', GPX_XMLNS).text.to_i
|
20
|
+
duration = Duration.new(stats.at('./gpxtrkx:TotalElapsedTime', GPX_XMLNS).text.to_i)
|
18
21
|
end
|
19
22
|
|
20
|
-
start_point = to_track_point(@doc.at('/xmlns:gpx/xmlns:trk/xmlns:trkseg[1]/xmlns:trkpt[1]'))
|
21
|
-
end_point = to_track_point(@doc.at('/xmlns:gpx/xmlns:trk/xmlns:trkseg[last()]/xmlns:trkpt[last()]'))
|
23
|
+
start_point = to_track_point(@doc.at('/xmlns:gpx/xmlns:trk/xmlns:trkseg[1]/xmlns:trkpt[1]', GPX_XMLNS))
|
24
|
+
end_point = to_track_point(@doc.at('/xmlns:gpx/xmlns:trk/xmlns:trkseg[last()]/xmlns:trkpt[last()]', GPX_XMLNS))
|
22
25
|
|
23
|
-
super(filename,
|
26
|
+
super(filename, start_point.time&.to_date, ascent, descent, distance, duration, start_point, end_point)
|
24
27
|
end
|
25
28
|
|
26
29
|
def to_gpx
|
@@ -33,8 +36,8 @@ module Natour
|
|
33
36
|
GPSTrackPoint.new(
|
34
37
|
trkpt['lat'].to_f,
|
35
38
|
trkpt['lon'].to_f,
|
36
|
-
trkpt.at('./xmlns:ele')
|
37
|
-
|
39
|
+
trkpt.at('./xmlns:ele')&.text&.to_f,
|
40
|
+
Timeliness.parse(trkpt.at('./xmlns:time')&.text)
|
38
41
|
)
|
39
42
|
end
|
40
43
|
end
|
data/lib/natour/image.rb
CHANGED
@@ -11,12 +11,9 @@ module Natour
|
|
11
11
|
def initialize(path, image)
|
12
12
|
@path = path
|
13
13
|
@image = image
|
14
|
+
@landscape = image.width >= image.height
|
14
15
|
orientation = get_field('exif-ifd0-Orientation')
|
15
|
-
@landscape = if orientation
|
16
|
-
orientation[/^(\d) \(/, 1].to_i.between?(1, 4)
|
17
|
-
else
|
18
|
-
image.width >= image.height
|
19
|
-
end
|
16
|
+
@landscape = !@landscape if orientation && orientation[/^(\d) \(/, 1].to_i.between?(5, 8)
|
20
17
|
date_time = get_field('exif-ifd0-DateTime')
|
21
18
|
@date_time = Timeliness.parse(date_time[/^(.*?) \(/, 1], format: 'yyyy:mm:dd hh:nn:ss') if date_time
|
22
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: natour
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Gysi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|