mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 08:57:24 +00:00
undropped caves code -> GPX
This commit is contained in:
@@ -113,7 +113,13 @@ class SurvexStation(models.Model):
|
|||||||
|
|
||||||
return diff_str, ref
|
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 ?
|
def utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.py ?
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import tempfile
|
|||||||
import urllib
|
import urllib
|
||||||
import zipfile
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
import django
|
import django
|
||||||
from bs4 import BeautifulSoup
|
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.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup, get_cave_leniently
|
||||||
from troggle.core.models.logbooks import QM
|
from troggle.core.models.logbooks import QM
|
||||||
from troggle.core.models.wallets import Wallet
|
from troggle.core.models.wallets import Wallet
|
||||||
|
from troggle.core.models.survex import SurvexStation
|
||||||
from troggle.core.utils import (
|
from troggle.core.utils import (
|
||||||
get_cookie_max_age,
|
get_cookie_max_age,
|
||||||
WriteAndCommitError,
|
WriteAndCommitError,
|
||||||
@@ -205,6 +207,32 @@ def getnotablecaves():
|
|||||||
print(notablecaves)
|
print(notablecaves)
|
||||||
return 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):
|
def caves_undropped(request):
|
||||||
caves1623 = list(Cave.objects.filter(areacode="1623",unexplored="True"))
|
caves1623 = list(Cave.objects.filter(areacode="1623",unexplored="True"))
|
||||||
caves1626 = list(Cave.objects.filter(areacode="1626",unexplored="True"))
|
caves1626 = list(Cave.objects.filter(areacode="1626",unexplored="True"))
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
See <em><a href="/caves">All Caves</a></em> for all the caves in areas 1623, 1626, 1624, 1627 <br />
|
See <em><a href="/caves">All Caves</a></em> for all the caves in areas 1623, 1626, 1624, 1627 <br />
|
||||||
See <em><a href="/caves_recent">Recent Caves</a></em> for a full list of recent caves.
|
See <em><a href="/caves_recent">Recent Caves</a></em> for a full list of recent caves.<br />
|
||||||
|
Download <em><a href="/caves_undropped_gpx" download="undropped.gpx">Undropped GPX file</a></em> (This is only the subset which are fully located.)
|
||||||
|
|
||||||
<p style="text-align:right">
|
<p style="text-align:right">
|
||||||
<a href="{% url "newcave" %}">New Cave</a><br>
|
<a href="{% url "newcave" %}">New Cave</a><br>
|
||||||
|
|||||||
5
templates/cavesundroppedgpx.html
Normal file
5
templates/cavesundroppedgpx.html
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<gpx version="1.0" creator="troggle https://expo.survex.com/troggle" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.topografix.com/GPX/1/0" xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
|
||||||
|
<name>Expo undropped caves</name>
|
||||||
|
<time>{{now}}</time>
|
||||||
|
{% for e in ent_locations %}{{e|safe}}{% endfor %}</gpx>
|
||||||
2
urls.py
2
urls.py
@@ -12,6 +12,7 @@ from troggle.core.views.caves import (
|
|||||||
cave_debug,
|
cave_debug,
|
||||||
caves_recent,
|
caves_recent,
|
||||||
caves_undropped,
|
caves_undropped,
|
||||||
|
caves_undropped_gpx,
|
||||||
cavesall,
|
cavesall,
|
||||||
cavepage,
|
cavepage,
|
||||||
caveQMs,
|
caveQMs,
|
||||||
@@ -161,6 +162,7 @@ trogglepatterns = [
|
|||||||
path('caveslist', caveslist, name="caveslist"),
|
path('caveslist', caveslist, name="caveslist"),
|
||||||
path('caves_recent', caves_recent, name="caves_recent"),
|
path('caves_recent', caves_recent, name="caves_recent"),
|
||||||
path('caves_undropped', caves_undropped, name="caves_undropped"),
|
path('caves_undropped', caves_undropped, name="caves_undropped"),
|
||||||
|
path('caves_undropped_gpx', caves_undropped_gpx, name="caves_undropped_gpx"),
|
||||||
|
|
||||||
path('entrances', entranceindex, name="entranceindex"),
|
path('entrances', entranceindex, name="entranceindex"),
|
||||||
path('enttags', entrancetags, name="entrancetags"),
|
path('enttags', entrancetags, name="entrancetags"),
|
||||||
|
|||||||
Reference in New Issue
Block a user