2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

fine tuning search for SRTM point

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

View File

@ -7,7 +7,7 @@ from pathlib import Path
from django.conf import settings
from django.db import models
from django.urls import reverse
from troggle.core.utils import height_from_utm
from troggle.core.utils import height_from_utm, throw
# from troggle.core.models.troggle import DataIssue # circular import. Hmm
@ -100,8 +100,16 @@ class SurvexStation(models.Model):
weight = "bold"
else:
weight = "normal"
diff_str = f"<span style='color:{colour}; font-weight:{weight}'>{sign}{diff:.0f}</span>"
if ref >= throw:
colour = "grey"
weight = "normal"
diff = "XX"
ref = float("nan")
diff_str = f"<span style='color:{colour}'>XX</span>"
return diff_str, ref

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)