From 788de853dc67e3ae3562b2957436df3bd2eec266 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Fri, 27 Oct 2023 22:13:14 +0300 Subject: ported radosts SRTM altitude tool --- core/models/survex.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'core/models/survex.py') 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"+{diff:.0f}" + else: + diff_str = f"{diff:.0f}" + + return diff_str, ref + + + def utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.py ? if not northernHemisphere: -- cgit v1.2.3