this_algorithm/test-data/00-generate-test-data.py

41 lines
1.2 KiB
Python
Raw Normal View History

2023-02-24 00:27:06 -05:00
#!/usr/bin/env python3
2023-02-22 18:42:14 -05:00
from random import random
2023-02-24 00:27:06 -05:00
with open("./00-sample-latlon.csv", "w") as f:
2023-02-22 18:42:14 -05:00
f.write("lat,lon\n")
2023-02-25 11:14:15 -05:00
seen_coords = set()
2023-02-22 18:42:14 -05:00
2023-02-24 00:27:06 -05:00
# Normalized
for i in range(10000):
lat = (random() - .5) * 2 * 90
lon = (random() - .5) * 2 * 180
2023-02-25 11:14:15 -05:00
s = f"{lat},{lon}\n"
if s not in seen_coords:
seen_coords.add(s)
f.write(s)
2023-02-24 00:27:06 -05:00
2023-02-22 18:42:14 -05:00
# Edge cases
# Do both positive and negative
2023-02-24 00:27:06 -05:00
for neg in (1, -1):
2023-02-22 18:42:14 -05:00
# Add a little bit of variation
2023-02-24 00:27:06 -05:00
for dec in (0, .1, .5, .05, .9999):
2023-02-22 18:42:14 -05:00
# Possibly strange latitudes
for lat_i in (0, 1, 90):
# Possibly strong longitudes
for lon_i in (0, 1, 90, 180):
2023-02-24 00:27:06 -05:00
lat = neg * (lat_i - dec)
lon = neg * (lon_i - dec)
2023-02-22 18:42:14 -05:00
2023-02-25 11:14:15 -05:00
s = f"{lat:f},{lon:f}\n"
if s not in seen_coords:
seen_coords.add(s)
f.write(s)
2023-02-22 18:42:14 -05:00
2023-02-24 00:27:06 -05:00
# # Non-normalized
# for i in range(10000):
# lat = (random() - .5) * 2 * 1000
# lon = (random() - .5) * 2 * 1000
2023-02-25 11:14:15 -05:00
# s = f"{lat},{lon}\n"
# if s not in seen_coords:
# seen_coords.add(s)
# f.write(s)