Fix incorrect timestamps for Google Location History (mobile device) points

This commit is contained in:
Eugene Burmakin 2024-09-30 23:31:42 +02:00
parent 2681d72463
commit ec793fe4aa
6 changed files with 27 additions and 5 deletions

View file

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
# [0.14.6] - 2024-29-30
### Fixed
- Points imported from Google Location History (mobile devise) now have correct timestamps
# [0.14.5] - 2024-09-28
### Fixed

File diff suppressed because one or more lines are too long

View file

@ -354,10 +354,12 @@ console.log(selectedLayerName);
const timeBetweenPrev = Math.round((startPoint[4] - prevPoint[4]) / 60);
const timeBetweenNext = Math.round((endPoint[4] - nextPoint[4]) / 60);
const pointsNumber = polylineCoordinates.length;
popupContent += `
<b>Prev Route:</b> ${Math.round(distanceToPrev)}m and ${minutesToDaysHoursMinutes(timeBetweenPrev)} away<br>
<b>Next Route:</b> ${Math.round(distanceToNext)}m and ${minutesToDaysHoursMinutes(timeBetweenNext)} away<br>
<b>Points:</b> ${pointsNumber}<br>
`;
}

View file

@ -74,7 +74,7 @@ class GoogleMaps::PhoneTakeoutParser
raw_data:,
accuracy: raw_data['accuracyMeters'],
altitude: raw_data['altitudeMeters'],
velocitu: raw_data['speedMetersPerSecond']
velocity: raw_data['speedMetersPerSecond']
}
end
@ -103,7 +103,9 @@ class GoogleMaps::PhoneTakeoutParser
lat, lon = parse_coordinates(point['point'])
start_time = DateTime.parse(data_point['startTime'])
offset = point['durationMinutesOffsetFromStartTime']
timestamp = offset.nil? ? start_time.to_i : start_time + point['durationMinutesOffsetFromStartTime'].to_i
timestamp = start_time
timestamp += offset.to_i.minutes if offset.present?
point_hash(lat, lon, timestamp, data_point)
end

View file

@ -9,7 +9,7 @@
<li><%= link_to 'Points', points_url, class: "#{active_class?(points_url)}" %></li>
<li><%= link_to 'Stats', stats_url, class: "#{active_class?(stats_url)}" %></li>
<li><%= link_to 'Visits<sup>β</sup>'.html_safe, visits_url(status: :confirmed), class: "#{active_class?(visits_url)}" %></li>
<li><%= link_to 'Places<sup>β</sup>', places_url, class: "#{active_class?(places_url)}" %></li>
<li><%= link_to 'Places<sup>β</sup>'.html_safe, places_url, class: "#{active_class?(places_url)}" %></li>
<li><%= link_to 'Imports', imports_url, class: "#{active_class?(imports_url)}" %></li>
<li><%= link_to 'Exports', exports_url, class: "#{active_class?(exports_url)}" %></li>
</ul>
@ -44,7 +44,7 @@
<li><%= link_to 'Points', points_url, class: "#{active_class?(points_url)}" %></li>
<li><%= link_to 'Stats', stats_url, class: "#{active_class?(stats_url)}" %></li>
<li><%= link_to 'Visits<sup>β</sup>'.html_safe, visits_url(status: :confirmed), class: "#{active_class?(visits_url)}" %></li>
<li><%= link_to 'Places<sup>β</sup>', places_url, class: "#{active_class?(places_url)}" %></li>
<li><%= link_to 'Places<sup>β</sup>'.html_safe, places_url, class: "#{active_class?(places_url)}" %></li>
<li><%= link_to 'Imports', imports_url, class: "#{active_class?(imports_url)}" %></li>
<li><%= link_to 'Exports', exports_url, class: "#{active_class?(exports_url)}" %></li>
</ul>

View file

@ -29,6 +29,18 @@ RSpec.describe GoogleMaps::PhoneTakeoutParser do
it 'creates points' do
expect { parser }.to change { Point.count }.by(8)
end
it 'creates points with correct data' do
parser
expect(Point.all[6].latitude).to eq(27.696576.to_d)
expect(Point.all[6].longitude).to eq(-97.376949.to_d)
expect(Point.all[6].timestamp).to eq(1_693_180_140)
expect(Point.last.latitude).to eq(27.709617.to_d)
expect(Point.last.longitude).to eq(-97.375988.to_d)
expect(Point.last.timestamp).to eq(1_693_180_320)
end
end
end
end