首页 > 其他分享 >轨迹脚本

轨迹脚本

时间:2025-01-02 14:30:32浏览次数:1  
标签:脚本 distance 轨迹 point route path import data

直线轨迹脚本

 1 import json
 2 import time
 3 import random
 4 import requests
 5 from geopy import Point
 6 from geopy.distance import Geodesic
 7 from datetime import datetime, timedelta
 8 
 9 
10 def get_distance(point1, point2):
11     """根据经纬度获得两点之间的距离"""
12     return Geodesic.WGS84.Inverse(point1[0], point1[1], point2[0], point2[1])['s12']
13 
14 
15 def simulate_path(starting_point, finishing_point, move_distance):
16     """模拟一段路径"""
17     total_distance = get_distance(starting_point, finishing_point)
18     distance_covered = 0
19 
20     current_point = Point(starting_point)
21     path = [current_point]
22 
23     while distance_covered < total_distance:
24         inv = Geodesic.WGS84.Inverse(current_point[0], current_point[1], finishing_point[0], finishing_point[1])
25         bearing = inv['azi1']
26         new_point = Geodesic.WGS84.Direct(current_point[0], current_point[1], bearing, move_distance)
27         current_point = Point(new_point['lat2'], new_point['lon2'])
28         path.append(current_point)
29         distance_covered += move_distance
30 
31     path.append(Point(finishing_point))
32     return path
33 
34 
35 if __name__ == '__main__':
36     start_point = (31.38544, 121.71109)
37     end_point = (31.276376, 121.412926)
38     step = 100  # 每个点之间的距离(米)
39 
40     path = simulate_path(start_point, end_point, step)
41     now = datetime.now()  # 获取当前时间
42 
43     allowed_location_type = [0, 1, 2, 3, 4, 5, 6, 8, 9, 11]
44     url = "https://qa-b.51kuafu.com/tiger/kms/api/attendance/dailyPointTraceUpload"
45     token='eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzIiwianRpIjoiNzk1OTFhYWExZjI2MTVjOWY1YjBlMDkwZmZkZGU3Y2Y0YWIyMDdhMDgyNmQzNDNjMjViNTAzMzJkMjFiZTZhNWNjNDMxM2NiZWE0Y2NkODYiLCJpYXQiOjE2ODM3MDY1MzgsIm5iZiI6MTY4MzcwNjUzOCwiZXhwIjoxNjg2Mjk4NTM4LCJzdWIiOiIyODMwIiwic2NvcGVzIjpbIioiXSwiaXAiOiI1OC4zNC4xNjMuMTY2IiwidXNlcl9pZCI6IjI4MzAiLCJ0eXBlIjoia21zIn0.KvjU9LdshcB2t-LBg032uDJ3yeH4yJB1IWsfW5CzOfz1SMhPmaP5No-wlZJ4wsVCZ1lP4OCC_0pdhqvgByKi8PU15-6q7ixgtHrziw9xDSh3MNcNvJGw6cgBl06M-WOTmwc8x6JvrPP8Bda9jthC8gjWcBhI2s0D5OlCwqty4QGDkl9Hkxfv0679jkfvuNOV0wEeYvgjhPZgLwN20nyPyrIB7z6Ks0_dI0JzdWq80lKwMBkT0DseCfCmOLbdNQhqLALKOd8jKLj0HH6mYv0VK1ch2dljvKR_JpOihTImASvLK-cVq_BZ5dVg6hJSpvTadO6Y7gjd58elQIt8CQW_jcPEVAaKBwl2YmqAJL9uPCKD1ZSx4BgbJG6Ltpf7NCyXMM9UTM1yWeb6iLgSCzoUVGDW-PpAW2VI0Fsxi0MEUxVMJTaOBBK8qEyD3IX1c0ioAuVB5fQ0B34gM5YUVZ8f3HYaPQ4Vlgw6KLokSGwLaurK3s5k_a7JQdjSUqg6-GgW-pxHvURkLOFARbEa48s5vySxec6bUtBy5jeIwD_kmm4ye_E7bNzngtAOyhg16luhxz5-t-kGYVMEcB--Kbo4cT-bNTCXIoaRzKGtVmel8jLsu8YYhLgwzP_sk338-1SYdi8WdvXxFJoddMIZ7QSDWh6QoZlr5l7ByUsdjIA9nFU'
46     headers = {
47         'version': '1.2.1',
48         'Content-Type': 'application/json',
49         'Authorization': 'Bearer ' + token
50     }
51     payload = {
52         "tracePoints": []
53     }
54 
55     # 打印路径上的经纬度
56     for point in path:
57         tracePoints_data = {
58                 "gpsSwitch": 1,
59                 "wifiSwitch": 1,
60                 "cellularNetworkSwitch": 0,
61                 "dumpEnergy": 13,
62                 "longitude": str(round(point.longitude, 6)),
63                 "latitude":  str(round(point.latitude, 6)),
64                 "tracePointTime": now.strftime('%Y-%m-%d %H:%M:%S'),
65                 "deviceModel": "RMX3372",
66                 "deviceSystem": "Android 13",
67                 "deviceSerialNumber": "6094f9b4b180deb76cc2bf9498613ab1644e94ef",
68                 "extra": {
69                     "time": 1683683139015,
70                     "speed": 0,
71                     "offset": True,
72                     "heading": 0,
73                     "version": "1.4.1",
74                     "accuracy": random.uniform(1, 100),
75                     "altitude": 0,
76                     "latitude": round(point.latitude, 6),
77                     "provider": "lbs",
78                     "coordType": "GCJ02",
79                     "errorCode": 0,
80                     "errorInfo": "success",
81                     "is_mocked": False,
82                     "longitude": round(point.longitude, 6),
83                     "locationType": random.choice(allowed_location_type),
84                     "locationDetail": "#id:SbWpoaWxwc29oZmRkY2k3Nzg4ZTloZGQ2MmVlZjNkLA==#csid:a42807ea334b4735bc03eb1f911b8ea2#pm111111",
85                     "speed_accuracy": 0,
86                     "isFixLastLocation": False
87                 }
88             }
89         payload['tracePoints'].append(tracePoints_data)
90         now += timedelta(seconds=random.randint(1, 60))  # 随机增加30秒
91     # print(payload)
92     response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
93     print(response.json())

高德模拟行进轨迹脚本

  1 import json
  2 import time
  3 import random
  4 import requests
  5 from geopy import Point
  6 from geopy.distance import Geodesic
  7 from datetime import datetime, timedelta
  8 
  9 
 10 def find_route(api_key, origin, destination, mode="driving"):
 11     """获取路径规划"""
 12     url = "https://restapi.amap.com/v3/direction/{mode}".format(mode=mode)
 13     params = {
 14         "key": api_key,
 15         "origin": origin,
 16         "destination": destination,
 17         "output": "json"
 18     }
 19 
 20     response = requests.get(url, params=params)
 21     data = response.json()
 22     # print(data)
 23     return data
 24 
 25 
 26 def extract_route_coordinates(route_data):
 27     coordinates = []
 28 
 29     if "route" in route_data and "paths" in route_data["route"]:
 30         for path in route_data["route"]["paths"]:
 31             if "steps" in path:
 32                 for step in path["steps"]:
 33                     if "polyline" in step:
 34                         polyline = step["polyline"]
 35                         coords = polyline.split(";")
 36                         for coord in coords:
 37                             lng, lat = coord.split(",")
 38                             coordinates.append((float(lng), float(lat)))
 39     return coordinates
 40 
 41 
 42 if __name__ == "__main__":
 43     api_key = "01b1f9293f48232c84d845207ade02ce"
 44     origin = "121.81499,31.15708"  # 经纬度格式 lon,lat(经度,纬度)
 45     destination = "121.25340,31.01064"
 46     mode = "driving"  # 可选值:driving(驾车)、walking(步行)、bicycling(骑行)、transit(公交)
 47     route_data = find_route(api_key, origin, destination, mode)
 48     route_coordinates = extract_route_coordinates(route_data)
 49     # print(route_coordinates)
 50 
 51     now = datetime.now()  # 获取当前时间
 52     allowed_location_type = [1, 2, 4, 5, 6, 8, 9, 11]
 53 
 54     url = "https://qa-b.51kuafu.com/tiger/kms/api/attendance/dailyPointTraceUpload"
 55     token='eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIzIiwianRpIjoiYmJjOWFlMjhlYmE5MGFkMWRmOTcwMDM1YWYwNjlkMjczNjA4OGJiMDU1MzgzNWY1NTY1YjM5NzI4ZmUyOTk4OTEyYmYzNzJhNTUwOTAxNjMiLCJpYXQiOjE2ODM4NzMzNDMsIm5iZiI6MTY4Mzg3MzM0MywiZXhwIjoxNjg2NDY1MzQzLCJzdWIiOiI2NyIsInNjb3BlcyI6WyIqIl0sImlwIjoiNTguMzQuMTYzLjE2NiIsInVzZXJfaWQiOiI2NyIsInR5cGUiOiJrbXMifQ.QkFKC0R1qKvFemfxflvsfu6GSZF6uho8lqUFsg7DVNhqCoSLg3a9FkreNDuCCMh6u9PzCxZ9nsQjCno_alM7wf1KVBvmfxJOGW-ag4-fB32rbd7IadECyKhzpnUepafYPU80ScQt9UwgluexSAjgbGjXZv__iIrb59YtiGyv_gStunvy5shFdDU--rkG41rA2Fp3yMVeB6JM-2-f_N387TfNf-ZcLMePxrdjjU1gF5PRHLnZJOOKqzXOmyiNxy9S4zNlBgx6wOiFn9tIMv6grtQae-YW3-skHi0fX4NZuJpPOX7OyYo--5-Ks3p0LJqz1sXV6V-wwgcXnRx1Xo8Um0TltQwcxJKYK3IpZbUWgeMRG6owX79ydVdHJNBaYzWzRS_bq7FQ1UWo2Ppw-Gi_gbIuAgS3kvLuFurA0yggWPSDfCCyFvgTPqBPve8ukWBGozXMawSz-FnBS0DuGep99mH8etazOh5JUFVAesRb69-wUCnLM7Axce5sZbzv7sx_js_ugHv0jBzgITOHuWqFkOxKCVJfPf5e1AR6WHZEFPjlDHOMTT2Iy7GWepgFGXahyWU7o0gOLH2zPSO5BR0hUCGeosuUf4q4moRmadaMOjpk_hAGnMCSJu3sTWb9ADianJ6YJX76fbvHNu3VZz3sxXqWewp7wevRfjoxjPcwD_E'
 56     headers = {
 57         'version': '1.2.1',
 58         'Content-Type': 'application/json',
 59         'Authorization': 'Bearer ' + token
 60     }
 61     payload = {
 62         "tracePoints": []
 63     }
 64 
 65     # 打印路径上的经纬度
 66     for point in route_coordinates:
 67         # print(point)
 68         tracePoints_data = {
 69             "gpsSwitch": 1,
 70             "wifiSwitch": 1,
 71             "cellularNetworkSwitch": 0,
 72             "dumpEnergy": 13,
 73             "longitude": str(round(point[0], 6)),
 74             "latitude": str(round(point[1], 6)),
 75             "tracePointTime": now.strftime('%Y-%m-%d %H:%M:%S'),
 76             "deviceModel": "RMX3372",
 77             "deviceSystem": "Android 13",
 78             "deviceSerialNumber": "6094f9b4b180deb76cc2bf9498613ab1644e94ef",
 79             "extra": {
 80                 "time": 1683683139015,
 81                 "speed": 0,
 82                 "offset": True,
 83                 "heading": 0,
 84                 "version": "1.4.1",
 85                 "accuracy": random.uniform(1, 50),
 86                 "altitude": 0,
 87                 "latitude": str(round(point[1], 6)),
 88                 "provider": "lbs",
 89                 "coordType": "GCJ02",
 90                 "errorCode": 0,
 91                 "errorInfo": "success",
 92                 "is_mocked": False,
 93                 "longitude": str(round(point[0], 6)),
 94                 "locationType": random.choice(allowed_location_type),
 95                 "locationDetail": "#id:SbWpoaWxwc29oZmRkY2k3Nzg4ZTloZGQ2MmVlZjNkLA==#csid:a42807ea334b4735bc03eb1f911b8ea2#pm111111",
 96                 "speed_accuracy": 0,
 97                 "isFixLastLocation": False
 98             }
 99         }
100         # print(tracePoints_data)
101         payload['tracePoints'].append(tracePoints_data)
102         now += timedelta(seconds=random.randint(30, 90))  # 随机增加30秒
103     print(payload)
104     response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
105     print(response.json())

 

标签:脚本,distance,轨迹,point,route,path,import,data
From: https://www.cnblogs.com/CSgarcia/p/18647626

相关文章

  • 批量检测多个微信小程序封禁状态的 PHP 脚本及使用说明
    随着微信小程序的日益普及,管理小程序的运营状态变得尤为重要。若某个小程序因违规被封禁,开发者需要第一时间了解其状态。本文将介绍如何使用PHP脚本批量检测多个微信小程序的封禁状态,并通过第三方接口获取小程序的最新状态信息。项目目标通过调用第三方API,基于小程序的A......
  • worker加载js脚本如何解决跨域?
    在前端开发中,当你尝试从一个域(例如:http://example.com)的Web页面加载另一个域(例如:http://api.another-example.com)的JavaScript脚本时,可能会遇到跨域问题。这是由浏览器的同源策略(Same-OriginPolicy)导致的,它限制了一个源的文档或脚本与另一个源的资源进行交互。为了解决跨域......
  • ; 自动设置电脑快捷键的AutoHotkey脚本程序源代码 2025年1月1日
     ;自动设置电脑快捷键的AutoHotkey脚本程序源代码2025年1月1日 ;自动设置电脑快捷键的AutoHotkey脚本程序源代码2025年1月1日;========设置显示或者隐藏MasterSeeker和TotalCommander主窗口的快捷键的AutoHotkey脚本2024.10.21=========;此脚本从此行开始;D:\a......
  • Godot引擎开发:GDScript脚本编写_控制流和循环
    控制流和循环在Godot引擎开发中,控制流和循环是编写GDScript脚本的核心概念之一。通过控制流,我们可以决定程序的执行顺序,而循环则允许我们重复执行特定的代码块,直到满足特定条件。本节将详细介绍这些概念,并提供具体的代码示例,帮助你更好地理解和应用它们。条件语句条件语......
  • Godot引擎开发:GDScript脚本编写_类和对象
    类和对象在Godot引擎中,GDScript是一种面向对象的脚本语言,它允许开发者通过定义类和创建对象来构建游戏。面向对象编程的核心概念包括类、对象、继承、封装和多态。本节将详细介绍这些概念,并通过具体的例子来展示如何在Godot引擎中使用GDScript编写类和对象。类的基本概念......
  • Godot引擎开发:GDScript脚本编写_类和继承
    类和继承在Godot引擎中,GDScript是一种类似于Python的脚本语言,专门用于游戏开发。类和继承是面向对象编程的核心概念,掌握这些概念对于编写高效、可维护的代码至关重要。本节将详细介绍如何在GDScript中使用类和继承,包括类的定义、属性和方法的使用,以及如何通过继承来扩......
  • Godot引擎开发:GDScript脚本编写_类和继承
    类和继承在Godot引擎中,GDScript是一种类似于Python的脚本语言,专门用于游戏开发。类和继承是面向对象编程的核心概念,掌握这些概念对于编写高效、可维护的代码至关重要。本节将详细介绍如何在GDScript中使用类和继承,包括类的定义、属性和方法的使用,以及如何通过继承来扩......
  • jenkins 的脚本部署
    前沿Jenkins是一款开源的自动化服务器,主要用于实现持续集成(ContinuousIntegration,CI)和持续交付(ContinuousDelivery,CD)。它通过插件的方式扩展功能,支持几乎所有主流的开发、构建、测试和部署工具。 一、Jenkins的核心概念1.什么是持续集成(CI)和持续交付(CD)?持续集成(CI):......
  • 交互式 Node 脚本
    在Node.js环境中,交互式脚本可以帮助开发者与程序之间进行实时互动。这类脚本通常用于命令行工具、配置管理、自动化任务或与用户的即时对话。交互式脚本通过提供输入提示、实时反馈以及灵活的交互方式,能够大大提升用户体验和操作效率。本文将深入探讨如何使用Node.js编......
  • Cleo 远程代码执行漏洞复现(CVE-2024-50623)(附脚本)
    0x01产品描述:        ‌Cleo‌是一款专为Z世代设计的AI理财小助手,自2016年成立以来,已经实现了1.5亿美元的年经常性收入。它不仅帮助用户追踪开销和存款目标,还通过数据分析提供深入的理财建议和个性化的财务指导。Cleo的AI驱动界面可以根据用户的行为进行调整,帮助用户......