summaryrefslogtreecommitdiffstats
path: root/core/models/survex.py
diff options
context:
space:
mode:
Diffstat (limited to 'core/models/survex.py')
-rw-r--r--core/models/survex.py21
1 files changed, 19 insertions, 2 deletions
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: