mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2026-02-08 11:28:23 +00:00
undropped caves code -> GPX
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -113,7 +113,13 @@ class SurvexStation(models.Model):
|
||||
|
||||
return diff_str, ref
|
||||
|
||||
|
||||
def gpx_location(s): # s == self
|
||||
# <wpt lon="13.82093593" lat="47.69501184"><ele>1857.90</ele><name>tunnocks</name></wpt>
|
||||
latitude, longitude = utmToLatLng(33, s.x, s.y, northernHemisphere=True)
|
||||
if s.name:
|
||||
return f'<wpt lon="{longitude:0.8f}" lat="{latitude:0.8f}"><ele>{s.z:0.0f}</ele><name>{s.name[5:]}</name></wpt>\n'
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.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"))
|
||||
|
||||
Reference in New Issue
Block a user