this_algorithm/docs/generate-test-data.py
2023-02-22 18:42:21 -05:00

28 lines
868 B
Python

from random import random
with open("sample-lat-lon.csv", "w") as f:
f.write("lat,lon\n")
# Edge cases
# Do both positive and negative
for neg in ("-", ""):
# Add a little bit of variation
for dec in ("0", "00000001", "5", "05", "9999"):
# Possibly strange latitudes
for lat_i in (0, 1, 90):
# Possibly strong longitudes
for lon_i in (0, 1, 90, 180):
f.write(f"{neg}{lat_i}.{dec},")
f.write(f"{neg}{lon_i}.{dec}\n")
# Normalized
for i in range(10000):
lat = (random() - .5) * 2 * 90
lon = (random() - .5) * 2 * 180
f.write(f"{lat},{lon}\n")
# Non-normalized
for i in range(10000):
lat = (random() - .5) * 2 * 1000
lon = (random() - .5) * 2 * 1000
f.write(f"{lat},{lon}\n")