41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
import json
|
|
import numpy as np
|
|
|
|
# 中心点的坐标以及每个中心的点的数目
|
|
map_center = (112.945311, 28.178169)
|
|
points = []
|
|
all_data = []
|
|
|
|
count_max = 1000
|
|
|
|
num_points = 100
|
|
lng_center, lat_center = map_center
|
|
for _ in range(num_points):
|
|
# 正态分布生成
|
|
lng = np.random.normal(lng_center, 0.05)
|
|
lat = np.random.normal(lat_center, 0.05)
|
|
|
|
up = np.random.randint(0, 2)
|
|
if (up == 1):
|
|
count = np.random.randint(1, 200)
|
|
else:
|
|
count = np.random.randint(800, 1000)
|
|
points.append({'lng': lng, 'lat': lat, 'count': count, 'up': up})
|
|
|
|
for time in range(24):
|
|
data = []
|
|
for point in points:
|
|
count = np.random.randint(1, 100)
|
|
if (point['up'] == 0):
|
|
count = -count
|
|
point['count'] = point['count'] + count
|
|
if (point['count'] < 0):
|
|
point['count'] = 0
|
|
elif (point['count'] > 1000):
|
|
point['count'] = 1000
|
|
data.append({'lng': point['lng'], 'lat': point['lat'], 'count': point['count']})
|
|
all_data.append(data)
|
|
|
|
with open('data.json', 'w') as f:
|
|
json.dump(all_data, f)
|