2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 04:38:16 +00:00

improves stations srtm report

This commit is contained in:
2023-11-02 01:05:36 +02:00
parent 742ccb5f0b
commit cc4a7f04da
3 changed files with 201 additions and 178 deletions

View File

@@ -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