Fix importing of GPX files with empty tracks and reduce number of points created for other GPX files.

This commit is contained in:
Eugene Burmakin 2025-02-08 23:52:37 +01:00
parent 6f7b724fce
commit b8c69c2a76
7 changed files with 11 additions and 8295 deletions

View file

@ -48,6 +48,7 @@ This will select points tracked between January 1st and January 31st 2025. Then
- Fixed a bug where export file was not being deleted from the server after it was deleted. #808
- After an area was drawn on the map, a popup is now being shown to allow user to provide a name and save the area. #740
- Docker entrypoints now use database name to fix problem with custom database names.
- Garmin GPX files with empty tracks are now being imported correctly. #827
### Added

View file

@ -28,7 +28,7 @@ class Gpx::TrackParser
segments = track['trkseg']
segments_array = segments.is_a?(Array) ? segments : [segments]
segments_array.map { |segment| segment['trkpt'] }
segments_array.compact.map { |segment| segment['trkpt'] }
end
def create_point(point, index)

View file

@ -27,5 +27,6 @@
<pdop>8.8</pdop>
</trkpt>
</trkseg>
<trkseg></trkseg>
</trk>
</gpx>

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -13,11 +13,11 @@ RSpec.describe Gpx::TrackParser do
context 'when file has a single segment' do
it 'creates points' do
expect { parser }.to change { Point.count }.by(301)
expect { parser }.to change { Point.count }.by(10)
end
it 'broadcasts importing progress' do
expect_any_instance_of(Imports::Broadcaster).to receive(:broadcast_import_progress).exactly(301).times
expect_any_instance_of(Imports::Broadcaster).to receive(:broadcast_import_progress).exactly(10).times
parser
end
@ -27,11 +27,11 @@ RSpec.describe Gpx::TrackParser do
let(:file_path) { Rails.root.join('spec/fixtures/files/gpx/gpx_track_multiple_segments.gpx') }
it 'creates points' do
expect { parser }.to change { Point.count }.by(558)
expect { parser }.to change { Point.count }.by(43)
end
it 'broadcasts importing progress' do
expect_any_instance_of(Imports::Broadcaster).to receive(:broadcast_import_progress).exactly(558).times
expect_any_instance_of(Imports::Broadcaster).to receive(:broadcast_import_progress).exactly(43).times
parser
end
@ -41,11 +41,11 @@ RSpec.describe Gpx::TrackParser do
let(:file_path) { Rails.root.join('spec/fixtures/files/gpx/gpx_track_multiple_tracks.gpx') }
it 'creates points' do
expect { parser }.to change { Point.count }.by(407)
expect { parser }.to change { Point.count }.by(34)
end
it 'broadcasts importing progress' do
expect_any_instance_of(Imports::Broadcaster).to receive(:broadcast_import_progress).exactly(407).times
expect_any_instance_of(Imports::Broadcaster).to receive(:broadcast_import_progress).exactly(34).times
parser
end