diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-10-27 22:13:14 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-10-27 22:13:14 +0300 |
commit | 788de853dc67e3ae3562b2957436df3bd2eec266 (patch) | |
tree | 61bb008415c2a7c6100fc969452ab4990853cbdd /core/models | |
parent | 7672de2dd11faa30273cd1749a476681defb014a (diff) | |
download | troggle-788de853dc67e3ae3562b2957436df3bd2eec266.tar.gz troggle-788de853dc67e3ae3562b2957436df3bd2eec266.tar.bz2 troggle-788de853dc67e3ae3562b2957436df3bd2eec266.zip |
ported radosts SRTM altitude tool
Diffstat (limited to 'core/models')
-rw-r--r-- | core/models/caves.py | 5 | ||||
-rw-r--r-- | core/models/survex.py | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/core/models/caves.py b/core/models/caves.py index 9d98e22..60ff8d1 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -442,6 +442,11 @@ class Entrance(TroggleModel): return self.latlong()[1] else: return None + + def best_alt(self): + return self.best_station_object().z + def best_srtm_alt(self): + return self.best_station_object().srtm_alt def GetCaveLookup(): """A very relaxed way of finding probably the right cave given almost any string which might serve to identify it diff --git a/core/models/survex.py b/core/models/survex.py index da35336..7af8570 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -1,3 +1,4 @@ +import math import os import re from urllib.parse import urljoin @@ -6,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.models.troggle import DataIssue # circular import. Hmm @@ -72,7 +73,23 @@ class SurvexStation(models.Model): return utmToLatLng(33, self.x, self.y, northernHemisphere=True)[0] def long(self): return utmToLatLng(33, self.x, self.y, northernHemisphere=True)[1] -import math + + def srtm_alt(self): + return height_from_utm(self.x, self.y) # height, distance from reference point + + def srtm_diff(self): + alt, ref = height_from_utm(self.x, self.y) # height, distance from reference point + + diff = alt - self.z + if diff >= 0: + diff_str = f"<span style='color:blue'>+{diff:.0f}</span>" + else: + diff_str = f"<span style='color:red'>{diff:.0f}</span>" + + return diff_str, ref + + + def utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.py ? if not northernHemisphere: |