diff --git a/core/models/survex.py b/core/models/survex.py
index a27ed45..cb5c26e 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -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"{sign}{diff:.0f}"
-
+
+ if ref >= throw:
+ colour = "grey"
+ weight = "normal"
+ diff = "XX"
+ ref = float("nan")
+ diff_str = f"XX"
+
return diff_str, ref
diff --git a/core/utils.py b/core/utils.py
index b46e341..0e0dfcc 100644
--- a/core/utils.py
+++ b/core/utils.py
@@ -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)