Skip to content

Commit

Permalink
fix: sync keep error
Browse files Browse the repository at this point in the history
  • Loading branch information
abinnz committed Oct 24, 2020
1 parent 6369d52 commit 47e9e10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 8 additions & 8 deletions scripts/keep_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ def parse_points_to_gpx(run_points_data, start_time):
# future to support heart rate
points_dict_list = []
for point in run_points_data:
points_dict_list.append(
{
"latitude": point["latitude"],
"longitude": point["longitude"],
"elevation": point["verticalAccuracy"] if "verticalAccuracy" in point.keys() else None,
"time": datetime.utcfromtimestamp((point["timestamp"] * 100 + start_time) / 1000),
}
)
points_dict = {
"latitude": point["latitude"],
"longitude": point["longitude"],
"time": datetime.utcfromtimestamp((point["timestamp"] * 100 + start_time) / 1000),
}
if "verticalAccuracy" in point:
points_dict["elevation"] = point["verticalAccuracy"]
points_dict_list.append(points_dict)
gpx = gpxpy.gpx.GPX()
gpx.nsmap["gpxtpx"] = "http://www.garmin.com/xmlschemas/TrackPointExtension/v1"
gpx_track = gpxpy.gpx.GPXTrack()
Expand Down
7 changes: 5 additions & 2 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const scrollToMap = () => {
const locationForRun = (run) => {
const location = run.location_country;
let [city, province, country] = ['', '', ''];
if (location && location != "None") {
if (location) {
// Only for Chinese now
const cityMatch = location.match(/[\u4e00-\u9fa5]*市/);
const provinceMatch = location.match(/[\u4e00-\u9fa5]*省/);
Expand All @@ -46,7 +46,10 @@ const locationForRun = (run) => {
}
const l = location.split(',');
// or to handle keep location format
const countryMatch = l[l.length - 1].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/) || l[2].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/);
let countryMatch = l[l.length - 1].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/);
if (!countryMatch && l.length >= 3) {
countryMatch = l[2].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/);
}
if (countryMatch) {
[country] = countryMatch;
}
Expand Down

0 comments on commit 47e9e10

Please sign in to comment.