diff --git a/core/models/caves.py b/core/models/caves.py
index 293b87f..8714305 100644
--- a/core/models/caves.py
+++ b/core/models/caves.py
@@ -302,7 +302,7 @@ class Entrance(TroggleModel):
def other_location(self):
return self.single(self.other_station)
-
+
def find_location(self):
r = {"": "To be entered ", "?": "To be confirmed:", "S": "", "L": "Lost:", "R": "Refindable:"}[self.findability]
if self.tag_station:
diff --git a/core/models/survex.py b/core/models/survex.py
index 1d5e501..db1b9a9 100644
--- a/core/models/survex.py
+++ b/core/models/survex.py
@@ -113,7 +113,13 @@ class SurvexStation(models.Model):
return diff_str, ref
-
+ def gpx_location(s): # s == self
+ # 1857.90tunnocks
+ latitude, longitude = utmToLatLng(33, s.x, s.y, northernHemisphere=True)
+ if s.name:
+ return f'{s.z:0.0f}{s.name[5:]}\n'
+ else:
+ return ""
def utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.py ?
diff --git a/core/views/caves.py b/core/views/caves.py
index a415448..1008b7a 100644
--- a/core/views/caves.py
+++ b/core/views/caves.py
@@ -5,6 +5,7 @@ import tempfile
import urllib
import zipfile
from pathlib import Path
+from datetime import datetime, timezone
import django
from bs4 import BeautifulSoup
@@ -20,6 +21,7 @@ from troggle.core.forms import CaveForm, EntranceForm, EntranceLetterForm # Cav
from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup, get_cave_leniently
from troggle.core.models.logbooks import QM
from troggle.core.models.wallets import Wallet
+from troggle.core.models.survex import SurvexStation
from troggle.core.utils import (
get_cookie_max_age,
WriteAndCommitError,
@@ -205,6 +207,32 @@ def getnotablecaves():
print(notablecaves)
return notablecaves
+def caves_undropped_gpx(request):
+ caves1623 = Cave.objects.filter(areacode="1623",unexplored="True")
+ caves1626 = Cave.objects.filter(areacode="1626",unexplored="True")
+
+
+ allcaves = list(caves1623) + list(caves1626)
+
+ ent_locations = []
+ for cave in allcaves:
+ ces = CaveAndEntrance.objects.filter(cave=cave)
+ for ce in ces:
+ stations = SurvexStation.objects.filter(entrance=ce.entrance)
+ for station in stations:
+ if gpx := station.gpx_location():
+ ent_locations.append(gpx)
+
+
+ return render(
+ request,
+ "cavesundroppedgpx.html",
+
+ {"ent_locations": ent_locations,
+ "now" : datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"), # GPX format and UTC timezone
+ "year": current_expo()},
+ )
+
def caves_undropped(request):
caves1623 = list(Cave.objects.filter(areacode="1623",unexplored="True"))
caves1626 = list(Cave.objects.filter(areacode="1626",unexplored="True"))
diff --git a/templates/cavesallindex - Copy.html:Zone.Identifier b/templates/cavesallindex - Copy.html:Zone.Identifier
deleted file mode 100644
index e69de29..0000000
diff --git a/templates/cavesundropped.html b/templates/cavesundropped.html
index bea81d8..322750f 100644
--- a/templates/cavesundropped.html
+++ b/templates/cavesundropped.html
@@ -10,7 +10,8 @@
See All Caves for all the caves in areas 1623, 1626, 1624, 1627
-See Recent Caves for a full list of recent caves.
+See Recent Caves for a full list of recent caves.
+Download Undropped GPX file (This is only the subset which are fully located.)