-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
修复同步keep数据出现的错误 #20
修复同步keep数据出现的错误 #20
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/yihong0618/running-page/8778lz4dz |
src/utils/utils.js
Outdated
@@ -34,7 +34,7 @@ const scrollToMap = () => { | |||
const locationForRun = (run) => { | |||
const location = run.location_country; | |||
let [city, province, country] = ['', '', '']; | |||
if (location) { | |||
if (location && location != "None") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest add if
here, and we do not need to compare with the location string
const countryMatch = l[l.length - 1].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/) || l[2].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length of the l variable may be equal to 1, so add the logic to judge the length.
const location = run.location_country;
let [city, province, country] = ['', '', ''];
if (location) {
// Only for Chinese now
const cityMatch = location.match(/[\u4e00-\u9fa5]*市/);
const provinceMatch = location.match(/[\u4e00-\u9fa5]*省/);
if (cityMatch) {
[city] = cityMatch;
}
if (provinceMatch) {
[province] = provinceMatch;
}
const l = location.split(',');
// or to handle keep location format
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;
}
}
scripts/keep_sync.py
Outdated
@@ -171,7 +171,7 @@ def parse_points_to_gpx(run_points_data, start_time): | |||
{ | |||
"latitude": point["latitude"], | |||
"longitude": point["longitude"], | |||
"elevation": point["verticalAccuracy"], | |||
"elevation": point["verticalAccuracy"] if "verticalAccuracy" in point.keys() else None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to get if verticalAccuracy attr first.
if there is no value here
We do not add it to the dict.
only keep the latitude, longitude, time
in the dict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other props may not need to be judged to exist.
# future to support heart rate
points_dict_list = []
for point in run_points_data:
points_dict = {
"latitude": point["latitude"],
"longitude": point["longitude"],
"time": datetime.utcfromtimestamp((point["timestamp"] * 100 + start_time) / 1000),
}
if "verticalAccuracy" in point.keys():
points_dict["verticalAccuracy"] = point["verticalAccuracy"]
points_dict_list.append(points_dict)
gpx = gpxpy.gpx.GPX()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll pr again.
No description provided.