Compare commits
No commits in common. "129f8e6378e6cb09acdfdc2a826a3e2f8455faee" and "6d619592c61964e068339e4a900976f7b7f747d0" have entirely different histories.
129f8e6378
...
6d619592c6
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,5 +0,0 @@
|
|||||||
gpx/
|
|
||||||
old/
|
|
||||||
new/
|
|
||||||
keep/
|
|
||||||
.python-version
|
|
78
huawei.py
78
huawei.py
@ -1,78 +0,0 @@
|
|||||||
import os
|
|
||||||
import gpxpy
|
|
||||||
import gpxpy.gpx
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from geopy.distance import geodesic
|
|
||||||
|
|
||||||
start_time = {
|
|
||||||
'20190625骑行.gpx': '2019-06-25 16:48',
|
|
||||||
'20190627骑行.gpx': '2019-06-27 19:42',
|
|
||||||
'20190705骑行.gpx': '2019-07-05 18:26',
|
|
||||||
'20190706骑行.gpx': '2019-07-06 19:37',
|
|
||||||
'20190709骑行.gpx': '2019-07-09 18:25',
|
|
||||||
'20190912跑步.gpx': '2019-09-12 18:03',
|
|
||||||
'20190915跑步.gpx': '2019-09-15 21:02',
|
|
||||||
'20190916跑步.gpx': '2019-09-16 21:38',
|
|
||||||
'20190920跑步.gpx': '2019-09-20 21:36',
|
|
||||||
'20190928跑步.gpx': '2019-09-28 22:41',
|
|
||||||
'20190930跑步.gpx': '2019-09-30 21:27',
|
|
||||||
'20191001跑步.gpx': '2019-10-01 17:12',
|
|
||||||
'20191006跑步.gpx': '2019-10-06 18:10',
|
|
||||||
'20191010跑步.gpx': '2019-10-10 22:06',
|
|
||||||
'20191011跑步.gpx': '2019-10-11 21:52',
|
|
||||||
'20191020跑步.gpx': '2019-10-20 18:08',
|
|
||||||
'20191030跑步.gpx': '2019-10-30 10:47',
|
|
||||||
'20191103跑步.gpx': '2019-11-03 17:16',
|
|
||||||
'20191107跑步.gpx': '2019-11-07 21:33',
|
|
||||||
'20191108跑步.gpx': '2019-11-08 22:14',
|
|
||||||
'20200321跑步.gpx': '2020-03-21 19:27',
|
|
||||||
'20200828骑行.gpx': '2020-08-28 22:19'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def process(file):
|
|
||||||
gpx_file = open('./old/'+file, 'r', encoding='utf-8')
|
|
||||||
gpx = gpxpy.parse(gpx_file)
|
|
||||||
|
|
||||||
s = 0
|
|
||||||
p = None
|
|
||||||
for track in gpx.tracks:
|
|
||||||
time = float(track.extensions[0].text)
|
|
||||||
for segment in track.segments:
|
|
||||||
for point in segment.points:
|
|
||||||
if p:
|
|
||||||
s += geodesic((point.latitude, point.longitude), (p.latitude, p.longitude)).m
|
|
||||||
p = point
|
|
||||||
|
|
||||||
ngpx = gpxpy.gpx.GPX()
|
|
||||||
|
|
||||||
gpx_track = gpxpy.gpx.GPXTrack()
|
|
||||||
ngpx.tracks.append(gpx_track)
|
|
||||||
|
|
||||||
gpx_segment = gpxpy.gpx.GPXTrackSegment()
|
|
||||||
gpx_track.segments.append(gpx_segment)
|
|
||||||
|
|
||||||
p = None
|
|
||||||
time0 = datetime.strptime(start_time[file], '%Y-%m-%d %H:%M') - timedelta(hours=8)
|
|
||||||
for track in gpx.tracks:
|
|
||||||
for segment in track.segments:
|
|
||||||
for point in segment.points:
|
|
||||||
if p and point.latitude == p.latitude and point.longitude == p.longitude:
|
|
||||||
continue
|
|
||||||
if p:
|
|
||||||
dis = geodesic((point.latitude, point.longitude), (p.latitude, p.longitude)).m
|
|
||||||
dtime += time * dis / s
|
|
||||||
else:
|
|
||||||
dtime = 0
|
|
||||||
gpx_segment.points.append(gpxpy.gpx.GPXTrackPoint(point.latitude, point.longitude,
|
|
||||||
time=time0 + timedelta(seconds=dtime)))
|
|
||||||
# datetime.strftime(time0 + timedelta(seconds=dtime), '%Y-%m-%dT%H:%M:%S.%fZ')
|
|
||||||
p = point
|
|
||||||
|
|
||||||
with open('./new/'+file, 'w', encoding='utf-8') as f:
|
|
||||||
f.write(ngpx.to_xml())
|
|
||||||
|
|
||||||
|
|
||||||
files = os.listdir('./old')
|
|
||||||
for file in files:
|
|
||||||
process(file)
|
|
35
keep.py
35
keep.py
@ -1,35 +0,0 @@
|
|||||||
import os
|
|
||||||
import gpxpy
|
|
||||||
import gpxpy.gpx
|
|
||||||
from ChangeCoordinate import ChangeCoord
|
|
||||||
|
|
||||||
def process(file):
|
|
||||||
gpx_file = open('./keep/'+file, 'r', encoding='utf-8')
|
|
||||||
gpx = gpxpy.parse(gpx_file)
|
|
||||||
|
|
||||||
ngpx = gpxpy.gpx.GPX()
|
|
||||||
|
|
||||||
gpx_track = gpxpy.gpx.GPXTrack()
|
|
||||||
ngpx.tracks.append(gpx_track)
|
|
||||||
|
|
||||||
gpx_segment = gpxpy.gpx.GPXTrackSegment()
|
|
||||||
gpx_track.segments.append(gpx_segment)
|
|
||||||
|
|
||||||
p = None
|
|
||||||
for track in gpx.tracks:
|
|
||||||
for segment in track.segments:
|
|
||||||
for point in segment.points:
|
|
||||||
if p and point.latitude == p.latitude and point.longitude == p.longitude:
|
|
||||||
continue
|
|
||||||
lon, lat = coord.gcj02_to_wgs84(point.longitude, point.latitude)
|
|
||||||
gpx_segment.points.append(gpxpy.gpx.GPXTrackPoint(lat, lon, time=point.time))
|
|
||||||
p = point
|
|
||||||
|
|
||||||
with open('./new/'+file, 'w', encoding='utf-8') as f:
|
|
||||||
f.write(ngpx.to_xml())
|
|
||||||
|
|
||||||
|
|
||||||
coord = ChangeCoord()
|
|
||||||
files = os.listdir('./keep')
|
|
||||||
for file in files:
|
|
||||||
process(file)
|
|
Reference in New Issue
Block a user