Skip to content

Commit 40d0c07

Browse files
committed
add trackpoint timestamp none check and reduce logging a bit
1 parent 914b567 commit 40d0c07

File tree

2 files changed

+28
-20
lines changed

2 files changed

+28
-20
lines changed

py/gpximport.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,33 +98,37 @@ def print_gpx_info(gpx, gpx_file,gpx_name,act_type):
9898
print_gpx_part_info(gpx)
9999
add_run(gpx,gpx_name,act_type,gpx_file,"")
100100

101-
def add_run(gpx_part,name,act_type,filename,polyline):
101+
def add_run(gpx_part, name, act_type, filename, polyline):
102102
conn = sqlite3.connect('%s/activities.db' % filebase)
103103
cursor = conn.cursor()
104104
cursor.execute("""CREATE TABLE if not exists activities
105105
(id INTEGER PRIMARY KEY AUTOINCREMENT,name text, act_date text, distance text,
106-
speed text, act_type text,filename text,polyline text)""")
106+
speed text, act_type text, filename text, polyline text)""")
107107
sql = "INSERT INTO activities VALUES (?,?,?,?,?,?,?,?)"
108+
108109
start_time, end_time = gpx_part.get_time_bounds()
109-
#l2d='{:.3f}'.format(gpx.length_2d() / 1000.)
110-
l2d = '{:.3f}'.format(gpx_part.length_2d() / 1000.)
111110
moving_time, stopped_time, moving_distance, stopped_distance, max_speed = gpx_part.get_moving_data()
112-
print(max_speed)
113-
#print('%sStopped distance: %sm' % stopped_distance)
114-
maxspeed = 'Max speed: {:.2f}km/h'.format(max_speed * 60. ** 2 / 1000. if max_speed else 0)
115-
duration = '{:.2f}'.format(gpx_part.get_duration() / 60)
116-
117-
print("-------------------------")
118-
print(name)
119-
print(start_time)
120-
print(l2d)
121-
print(maxspeed)
122-
print("-------------------------")
111+
112+
length_2d = gpx_part.length_2d()
113+
l2d = '{:.3f}'.format(length_2d / 1000. if length_2d is not None else 0)
114+
115+
maxspeed = 'Max speed: {:.2f}km/h'.format(max_speed * 60. ** 2 / 1000. if max_speed is not None else 0)
116+
117+
duration = gpx_part.get_duration()
118+
duration_formatted = '{:.2f}'.format(duration / 60 if duration is not None else 0)
119+
120+
# print("-------------------------")
121+
# print(name)
122+
# print(start_time)
123+
# print(l2d)
124+
# print(maxspeed)
125+
# print("-------------------------")
126+
123127
try:
124-
cursor.execute(sql, [None, name,start_time,l2d,duration,act_type,filename,polyline])
128+
cursor.execute(sql, [None, name, start_time, l2d, duration_formatted, act_type, filename, polyline])
125129
conn.commit()
126130
except sqlite3.Error as er:
127-
print("-------------______---_____---___----____--____---___-----")
131+
print("----sql error----")
128132
print(er)
129133
conn.close()
130134

qml/Main.qml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ MainView {
5353
var seconds = Math.floor((totalNumberOfSeconds - ((hours * 3600) + (minutes * 60))));
5454
var hours2 = (hours == 0 ? "" : (hours < 10 ? "0" + hours +":" : hours+":"))
5555
var result = hours2 + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds < 10 ? "0" + seconds : seconds);
56-
return result
56+
if (result == "00:00" ) {
57+
return "--:--"
58+
} else {
59+
return result
60+
}
5761
}
5862

5963
function formatDist(distance) {
@@ -196,8 +200,8 @@ MainView {
196200

197201
function get_units(result) {
198202
call('geepeeex.get_units', [], function(result){
199-
console.warn("getting units")
200-
console.warn(result[0])
203+
// console.warn("getting units")
204+
// console.warn(result[0])
201205
runits = result[0]
202206
return runits
203207
}

0 commit comments

Comments
 (0)