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.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/models/survex.py b/core/models/survex.py
index 7af8570..4c2c109 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -75,16 +75,25 @@ class SurvexStation(models.Model):
return utmToLatLng(33, self.x, self.y, northernHemisphere=True)[1]
def srtm_alt(self):
- return height_from_utm(self.x, self.y) # height, distance from reference point
+ """Caches the srtm data so that searches are not done twice on the same page"""
+ if not hasattr(self,"srtm"):
+ self.srtm = height_from_utm(self.x, self.y) # height, distance from reference point
+ return self.srtm # (nearest point, nearest distance)
def srtm_diff(self):
- alt, ref = height_from_utm(self.x, self.y) # height, distance from reference point
+ alt, ref = self.srtm_alt()
diff = alt - self.z
if diff >= 0:
- diff_str = f"<span style='color:blue'>+{diff:.0f}</span>"
+ colour = "blue"
else:
- diff_str = f"<span style='color:red'>{diff:.0f}</span>"
+ colour = "red"
+
+ if abs(diff) > 60:
+ weight = "bold"
+ else:
+ weight = "normal"
+ diff_str = f"<span style='color:{colour}; font-weight:{weight}'>{diff:.0f}</span>"
return diff_str, ref