-
-
Notifications
You must be signed in to change notification settings - Fork 51
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 #374 from Freika/fix/gpx-geojson-speed-recording
Fix/gpx geojson speed recording
- Loading branch information
Showing
9 changed files
with
251 additions
and
30 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 +1 @@ | ||
0.16.0 | ||
0.16.1 |
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
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
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,23 @@ | ||
{ | ||
"features": [ | ||
{ | ||
"geometry": { | ||
"coordinates": [ | ||
106.64234449272531, | ||
10.758321212464024 | ||
], | ||
"type": "Point" | ||
}, | ||
"properties": { | ||
"accuracy": 4.7551565, | ||
"altitude": 17.634344400269068, | ||
"provider": "gps", | ||
"speed": 1.2, | ||
"time": "2024-11-03T16:30:11.331+07:00", | ||
"time_long": 1730626211331 | ||
}, | ||
"type": "Feature" | ||
} | ||
], | ||
"type": "FeatureCollection" | ||
} |
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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<gpx version="1.1" creator="GPSLogger 131 - http://gpslogger.mendhak.com/" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/1" | ||
xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v2" | ||
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd | ||
http://www.garmin.com/xmlschemas/TrackPointExtension/v2 https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd | ||
"> | ||
<metadata> | ||
<time>2024-11-03T16:30:11.331+07:00</time> | ||
</metadata> | ||
<trk> | ||
<name>20241103</name> | ||
<trkseg> | ||
<trkpt lat="10.758321212464024" lon="106.64234449272531"> | ||
<ele>17.634344400269068</ele> | ||
<time>2024-11-03T16:30:11.331+07:00</time> | ||
<extensions> | ||
<gpxtpx:TrackPointExtension> | ||
<gpxtpx:speed>2.8</gpxtpx:speed> | ||
</gpxtpx:TrackPointExtension> | ||
</extensions> | ||
<geoidheight>-1.6</geoidheight> | ||
<src>gps</src> | ||
<sat>3</sat> | ||
<hdop>1.9</hdop> | ||
<vdop>8.6</vdop> | ||
<pdop>8.8</pdop> | ||
</trkpt> | ||
</trkseg> | ||
</trk> | ||
</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,108 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe Geojson::Params do | ||
describe '#call' do | ||
let(:file_path) { Rails.root.join('spec/fixtures/files/geojson/export.json') } | ||
let(:file) { File.read(file_path) } | ||
let(:json) { JSON.parse(file) } | ||
let(:params) { described_class.new(json) } | ||
|
||
subject { params.call } | ||
|
||
it 'returns an array of points' do | ||
expect(subject).to be_an_instance_of(Array) | ||
expect(subject.first).to be_an_instance_of(Hash) | ||
end | ||
|
||
it 'returns the correct data for each point' do | ||
expect(subject.first).to eq( | ||
latitude: '0.0', | ||
longitude: '0.0', | ||
battery_status: nil, | ||
battery: nil, | ||
timestamp: Time.zone.at(1_609_459_201), | ||
altitude: 1, | ||
velocity: 0, | ||
tracker_id: nil, | ||
ssid: nil, | ||
accuracy: 1, | ||
vertical_accuracy: 1, | ||
raw_data: { | ||
'type' => 'Feature', | ||
'geometry' => { | ||
'type' => 'Point', | ||
'coordinates' => [ | ||
'0.0', | ||
'0.0' | ||
] | ||
}, | ||
'properties' => { | ||
'battery_status' => 'unplugged', | ||
'ping' => 'MyString', | ||
'battery' => 1, | ||
'tracker_id' => 'MyString', | ||
'topic' => 'MyString', | ||
'altitude' => 1, | ||
'longitude' => '0.1', | ||
'velocity' => 'MyString', | ||
'trigger' => 'background_event', | ||
'bssid' => 'MyString', | ||
'ssid' => 'MyString', | ||
'connection' => 'wifi', | ||
'vertical_accuracy' => 1, | ||
'accuracy' => 1, | ||
'timestamp' => 1_609_459_201, | ||
'latitude' => '0.1', | ||
'mode' => 1, | ||
'inrids' => [], | ||
'in_regions' => [], | ||
'raw_data' => '', | ||
'city' => nil, | ||
'country' => nil, | ||
'geodata' => {} | ||
} | ||
} | ||
) | ||
end | ||
|
||
context 'when the json is exported from GPSLogger' do | ||
let(:file_path) { Rails.root.join('spec/fixtures/files/geojson/gpslogger_example.json') } | ||
|
||
it 'returns the correct data for each point' do | ||
expect(subject.first).to eq( | ||
latitude: 10.758321212464024, | ||
longitude: 106.64234449272531, | ||
battery_status: nil, | ||
battery: nil, | ||
timestamp: Time.parse('2024-11-03T16:30:11.331+07:00').to_i, | ||
altitude: 17.634344400269068, | ||
velocity: 1.2, | ||
tracker_id: nil, | ||
ssid: nil, | ||
accuracy: 4.7551565, | ||
vertical_accuracy: nil, | ||
raw_data: { | ||
'geometry' => { | ||
'coordinates' => [ | ||
106.64234449272531, | ||
10.758321212464024 | ||
], | ||
'type' => 'Point' | ||
}, | ||
'properties' => { | ||
'accuracy' => 4.7551565, | ||
'altitude' => 17.634344400269068, | ||
'provider' => 'gps', | ||
'speed' => 1.2, | ||
'time' => '2024-11-03T16:30:11.331+07:00', | ||
'time_long' => 1_730_626_211_331 | ||
}, | ||
'type' => 'Feature' | ||
} | ||
) | ||
end | ||
end | ||
end | ||
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