功能:导航测试中,安卓APP使用GT模拟以达到测试的目的,但是使用RD提供的Demo生成的文件,速度不够快,模拟不了超速的场景,故需要把速度值调高

腾讯GT使用的GPS文件格式:

116.28499730,40.04132990,5.0,77.9,40.000000,2018-03-06 15:25:49,1520321149.574,0.0
116.28502120,40.04133370,5.0,77.9,2.077989,2018-03-06 15:25:50,1520321150.574,0.0
116.28504460,40.04133760,5.0,77.9,2.038668,2018-03-06 15:25:51,1520321151.574,0.0
116.28506850,40.04134140,5.0,77.9,2.077989,2018-03-06 15:25:52,1520321152.574,0.0
116.28509210,40.04134520,5.0,77.9,2.052990,2018-03-06 15:25:53,1520321153.574,0.0
116.28511580,40.04134910,5.0,77.9,2.063629,2018-03-06 15:25:54,1520321154.574,0.0

如上所示:第五个逗号前的数字(如:第一行的40.000000)就是我们需要改变的速度值

第一版代码如下:

#被修改的速度值与实际时速相差大概4倍
def chang_velocity() :
velocity = input("请输入要改变的速度:")
with open('befor.gps' ,'r') as f,open('after.gps' ,'a') as f1:
for line in f:
data = line.strip().split(',')
data[4] = velocity
new_data = ",".join(data)#对join方法理解的还是不好,需要加深理解,此处用法是把切割的列表转换成字符串,通过逗号连接,以前知道通过join转为字符串,但是不知道引号内可以加入分隔符
f1.write(new_data+"\n")
f1.close()
f.close()
if __name__ == '__main__':
runner = chang_velocity()
使用该代码通过pyinstaller工具打包成Windows下的可执行文件输入速度值即可!
该工具下一步可以在给定速度范围内随机生成速度值,并对速度值位数加以限制
顺便感谢滴滴地图的测开们,是你们的懒惰,才有了我的进步!
11-27 22:13