Add sample lat-lon data
This commit is contained in:
parent
8fc58e0bcf
commit
ea64a531e3
@ -744,6 +744,24 @@ fn st_to_ij(s: f64) -> u32 {
|
||||
}
|
||||
----
|
||||
|
||||
== Sample Data [[sample-data]]
|
||||
|
||||
In order to test this algorithm out, I want to ensure the conversions are not incorrect.
|
||||
I will generate sample data and test against the link:https://github.com/google/s2geometry/[S2 C++ Source Code^] to ensure the CellIDs match for every tested latitude longitude.
|
||||
|
||||
.Types of test data
|
||||
|
||||
* Standard latitude/longitude in the range (-90,90) and (-180,180) - Randomly selected
|
||||
* Non-normalized latitude/longitude in the range [-1000,1000] and [-1000,1000] - Used to make sure latitude/longitude normalization logic is correct
|
||||
* Corner-cases - 0, ±1, ±90, and ±180, plus some variation
|
||||
|
||||
All of these cases are generated with this code:
|
||||
|
||||
[source,python]
|
||||
----
|
||||
include::./generate-test-data.py[]
|
||||
----
|
||||
|
||||
== Interfaces [[interfaces]]
|
||||
|
||||
Goal 2 of this project is to provide many interfaces that are easy to use.
|
||||
|
27
docs/generate-test-data.py
Normal file
27
docs/generate-test-data.py
Normal file
@ -0,0 +1,27 @@
|
||||
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")
|
20121
test-data/sample-lat-lon.csv
Normal file
20121
test-data/sample-lat-lon.csv
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user