diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-11-05 22:59:02 +0200 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-11-05 22:59:02 +0200 |
commit | df79bdb71158f11c0217243eaaded89499ed7134 (patch) | |
tree | 9d5e6fede45e1f9e24644828c8a1218dfe0bb4f3 | |
parent | c0687615a46b45ceb755c1c3df2f6bc8cc5dd3da (diff) | |
download | troggle-df79bdb71158f11c0217243eaaded89499ed7134.tar.gz troggle-df79bdb71158f11c0217243eaaded89499ed7134.tar.bz2 troggle-df79bdb71158f11c0217243eaaded89499ed7134.zip |
fine tuning search for SRTM point
-rw-r--r-- | core/models/survex.py | 12 | ||||
-rw-r--r-- | core/utils.py | 14 |
2 files changed, 20 insertions, 6 deletions
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"<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 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) |