summaryrefslogtreecommitdiffstats
path: root/core/models
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-09-16 22:46:17 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-09-16 22:46:17 +0300
commit017f916ef922bd11b1e745ccc4fa4bccd843f1d4 (patch)
tree36ca99a86ffc550f4b4203a6f16b6f870c510707 /core/models
parenta85f859f886ac2a22a94a604f2ce46395c148476 (diff)
downloadtroggle-017f916ef922bd11b1e745ccc4fa4bccd843f1d4.tar.gz
troggle-017f916ef922bd11b1e745ccc4fa4bccd843f1d4.tar.bz2
troggle-017f916ef922bd11b1e745ccc4fa4bccd843f1d4.zip
Entrance locations showing lat long screwups
Diffstat (limited to 'core/models')
-rw-r--r--core/models/caves.py29
-rw-r--r--core/models/survex.py5
2 files changed, 27 insertions, 7 deletions
diff --git a/core/models/caves.py b/core/models/caves.py
index ea6fe9a..949c089 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -10,7 +10,7 @@ from django.template import loader
import settings
from troggle.core.models.logbooks import QM
-from troggle.core.models.survex import SurvexStation
+from troggle.core.models.survex import SurvexStation, utmToLatLng
from troggle.core.models.troggle import DataIssue, TroggleModel
from troggle.core.utils import TROG, writetrogglefile
@@ -123,7 +123,7 @@ class Cave(TroggleModel):
pass
else:
self.official_name.lower()
- return Path(settings.URL_ROOT) / self.url # not good Django style.. NEEDS actual URL
+ return Path(settings.URL_ROOT) / self.url # not good Django style? NEEDS actual URL
def url_parent(self):
if self.url:
@@ -232,7 +232,7 @@ class Entrance(TroggleModel):
alt = models.TextField(blank=True, null=True)
approach = models.TextField(blank=True, null=True)
bearings = models.TextField(blank=True, null=True)
- easting = models.TextField(blank=True, null=True)
+ easting = models.TextField(blank=True, null=True) # apparently? manually entered not calculated
entrance_description = models.TextField(blank=True, null=True)
exact_station = models.TextField(blank=True, null=True)
explorers = models.TextField(blank=True, null=True)
@@ -240,14 +240,14 @@ class Entrance(TroggleModel):
findability = models.CharField(max_length=1, choices=FINDABLE_CHOICES, blank=True, null=True)
findability_description = models.TextField(blank=True, null=True)
lastvisit = models.TextField(blank=True, null=True)
- lat_wgs84 = models.TextField(blank=True, null=True)
+ lat_wgs84 = models.TextField(blank=True, null=True) # manually entered not calculated
location_description = models.TextField(blank=True, null=True)
- long_wgs84 = models.TextField(blank=True, null=True)
+ long_wgs84 = models.TextField(blank=True, null=True) # manually entered not calculated
map_description = models.TextField(blank=True, null=True)
marking = models.CharField(max_length=2, choices=MARKING_CHOICES)
marking_comment = models.TextField(blank=True, null=True)
name = models.CharField(max_length=100, blank=True, null=True)
- northing = models.TextField(blank=True, null=True)
+ northing = models.TextField(blank=True, null=True) # apparently? manually entered not calculated
other_description = models.TextField(blank=True, null=True)
other_station = models.TextField(blank=True, null=True)
photo = models.TextField(blank=True, null=True)
@@ -410,6 +410,12 @@ class Entrance(TroggleModel):
return ""
def latlong(self):
+ """Gets lat long assuming that it has to get it from the associated stations, but in fact the Entrance itself
+ has easting/northing and lat/long fields which perhaps we should try first...
+ """
+ if self.easting and self.northing:
+ return utmToLatLng(33, float(self.easting), float(self.northing), northernHemisphere=True)
+
station = None
if self.other_station:
try:
@@ -429,6 +435,17 @@ class Entrance(TroggleModel):
if station:
return station.latlong()
+ def lat(self):
+ if self.latlong():
+ return self.latlong()[0]
+ else:
+ return None
+
+ def long(self):
+ if self.latlong():
+ return self.latlong()[1]
+ else:
+ return None
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 9a5145c..1c6a1fe 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -67,7 +67,10 @@ class SurvexStation(models.Model):
def latlong(self):
return utmToLatLng(33, self.x, self.y, northernHemisphere=True)
-
+ def lat(self):
+ 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 utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.py ?