fine tuning search for SRTM point

This commit is contained in:
2023-11-05 22:59:02 +02:00
parent c0687615a4
commit df79bdb711
2 changed files with 20 additions and 6 deletions

View File

@@ -38,6 +38,8 @@ TROG = {"pagecache": {"expedition": {}}, "caves": {"gcavelookup": {}, "gcavecoun
alphabet = []
sha = hashlib.new('sha256')
throw = 35.0
# This is module-level executable. This is a Bad Thing. Especially when it touches the file system.
try:
logging.basicConfig(level=logging.DEBUG, filename=settings.LOGFILE, filemode="w")
@@ -299,21 +301,25 @@ def find_nearest_point(points, target_point):
In our dataset, the survey stations are all within 30m of an srtm reference point.
So we can safely ignore points more than 100m away in either x or y directions.
This is not true for the 1624 and 1627 areas though.
TO DO: store this list twice, once sorted by x and once sorted by y,
do a bounding box search for a set of nearby points before doing the exhaustive pythagorean distance search."""
nearest_distance_squared = float("inf")
nearest_point = None
x_target, y_target = target_point
max_ds = throw * throw # 1089 = 33 x 33
for point in points:
x, y, z = point
if z < 0:
distance_squared = 1000000.0 # ie ignore it
else:
if x - x_target > 100:
distance_squared = 10000
elif y - y_target > 100:
distance_squared = 10000
if x - x_target > throw:
distance_squared = max_ds
elif y - y_target > throw:
distance_squared = max_ds
else:
distance_squared = math.pow(x - x_target, 2) + math.pow(y - y_target, 2)