2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

stopo prospecting map crashing

This commit is contained in:
Philip Sargent 2021-04-16 21:28:44 +01:00
parent 49277216ba
commit fa1df39923
4 changed files with 120 additions and 81 deletions

View File

@ -15,8 +15,52 @@ from troggle.core.models.caves import Entrance, Area, SurvexStation, Cave
from troggle.core.views.caves import caveKey
''' Generates the prospecting guide document.
Also produces the overlay of points on top of a prospecting_image map - to be deleted.
I have tried to make this work with the version of PIL we have installed but something is missing still.
'''
AREANAMES = [
#('', 'Location unclear'),
('1a', '1a – Plateau: around Top Camp'),
('1b', '1b – Western plateau near 182'),
('1c', '1c – Eastern plateau near 204 walk-in path'),
('1d', '1d – Further plateau around 76'),
('2a', '2a – Southern Schwarzmooskogel near 201 path and the Nipple'),
('2b', '2b – Eishöhle area'),
('2b or 4 (unclear)', '2b or 4 (unclear)'),
('2c', '2c – Kaninchenhöhle area'),
('2d', '2d – Steinbrückenhöhle area'),
('3', '3 – Bräuning Alm'),
('4', '4 – Kratzer valley'),
('5', '5 – Schwarzmoos-Wildensee'),
('6', '6 – Far plateau'),
('1626 or 6 (borderline)', '1626 or 6 (borderline)'),
('7', '7 – Egglgrube'),
('8a', '8a – Loser south face'),
('8b', '8b – Loser below Dimmelwand'),
('8c', '8c – Augst See'),
('8d', '8d – Loser-Hochganger ridge'),
('9', '9 – Gschwandt Alm'),
('10', '10 – Altaussee'),
('11', '11 – Augstbach')
]
def prospecting(request):
'''This produces the multipage 'prospecting guide' document,
intended to be printed and carried into the field - in 1999.
All the formatting and selection clverness is in the template file.
'''
areas = []
for key, name in AREANAMES:
a = Area.objects.get(short_name = key) # assumes unique
caves = list(a.cave_set.all())
caves.sort(key=caveKey)
areas.append((name, a, caves))
return render(request, 'prospecting.html', {"areas": areas})
class MapLocations(object):
p = [
("laser.0_7", "BNase", "Reference", "Bräuning Nase laser point"),
@ -54,48 +98,17 @@ class MapLocations(object):
def __str__(self):
return "{} map locations".format(len(self.p))
AREANAMES = [
#('', 'Location unclear'),
('1a', '1a – Plateau: around Top Camp'),
('1b', '1b – Western plateau near 182'),
('1c', '1c – Eastern plateau near 204 walk-in path'),
('1d', '1d – Further plateau around 76'),
('2a', '2a – Southern Schwarzmooskogel near 201 path and the Nipple'),
('2b', '2b – Eishöhle area'),
('2b or 4 (unclear)', '2b or 4 (unclear)'),
('2c', '2c – Kaninchenhöhle area'),
('2d', '2d – Steinbrückenhöhle area'),
('3', '3 – Bräuning Alm'),
('4', '4 – Kratzer valley'),
('5', '5 – Schwarzmoos-Wildensee'),
('6', '6 – Far plateau'),
('1626 or 6 (borderline)', '1626 or 6 (borderline)'),
('7', '7 – Egglgrube'),
('8a', '8a – Loser south face'),
('8b', '8b – Loser below Dimmelwand'),
('8c', '8c – Augst See'),
('8d', '8d – Loser-Hochganger ridge'),
('9', '9 – Gschwandt Alm'),
('10', '10 – Altaussee'),
('11', '11 – Augstbach')
]
def prospecting(request):
#for key, name in AREANAMES:
#print(key, Area.objects.get(short_name = key))
areas = []
for key, name in AREANAMES:
a = Area.objects.get(short_name = key) # assumes unique
caves = list(a.cave_set.all())
caves.sort(key=caveKey)
areas.append((name, a, caves))
return render(request, 'prospecting.html', {"areas": areas})
# Parameters for big map and zoomed subarea maps:
# big map first (zoom factor ignored)
# These are the values for the url? /prospecting/[mapcode].png ??
maps = {
# id left top right bottom zoom
# G&K G&K G&K G&K factor
@ -157,6 +170,7 @@ TEXTSIZE = 16
CIRCLESIZE =8
LINEWIDTH = 2
myFont = ImageFont.truetype(FONT, TEXTSIZE)
print(f' - myFont {myFont} {FONT} {TEXTSIZE}')
def mungecoord(x, y, mapcode, img):
# Top of Zinken is 73 1201 = dataset 34542 81967
@ -186,7 +200,7 @@ def plot(surveypoint, number, point_type, label, mapcode, draw, img):
E, N = ss.x, ss.y
shortnumber = number.replace("—","")
(x,y) = list(map(int, mungecoord(E, N, mapcode, img)))
#imgmaps[maparea].append( [x-4, y-SIZE/2, x+4+draw.textsize(shortnumber)[0], y+SIZE/2, shortnumber, label] )
imgmaps[maparea].append( [x-4, y-SIZE/2, x+4+draw.textsize(shortnumber)[0], y+SIZE/2, shortnumber, label] )
draw.rectangle([(x+CIRCLESIZE, y-TEXTSIZE/2), (x+CIRCLESIZE*2+draw.textsize(shortnumber)[0], y+TEXTSIZE/2)], fill="#ffffff")
draw.text((x+CIRCLESIZE * 1.5,y-TEXTSIZE/2), shortnumber, fill="#000000")
draw.ellipse([(x-CIRCLESIZE,y-CIRCLESIZE),(x+CIRCLESIZE,y+CIRCLESIZE)], fill=COL_TYPES[point_type], outline="#000000")
@ -195,6 +209,21 @@ def plot(surveypoint, number, point_type, label, mapcode, draw, img):
def prospecting_image(request, name):
# We should replace all this with something that exports an overlay for Google Maps and OpenStreetView
test = os.path.join(settings.EXPOFILES, "location_maps", "testmap.png")
response = HttpResponse(content_type = "image/png")
with Image.open(test) as im:
draw = ImageDraw.Draw(im)
draw.line((0, 0) + im.size, fill=128)
draw.line((0, im.size[1], im.size[0], 0), fill=128)
# write to stdout
#im.save(sys.stdout, "PNG")
img.save(response, "PNG")
return response
mainImage = Image.open(os.path.join(settings.EXPOFILES, "location_maps", "pguidemap.jpg"))
if settings.PUBLIC_SITE and not request.user.is_authenticated:
mainImage = Image.new("RGB", mainImage.size, '#ffffff')
@ -214,7 +243,7 @@ def prospecting_image(request, name):
h = int(round(m[ZOOM] * (m[B] - m[T]) / (M[B] - M[T]) * H))
img = img.resize((w, h), Image.BICUBIC)
draw = ImageDraw.Draw(img)
draw.setfont(myFont)
#draw.setfont(myFont)
if name == "all":
for maparea in list(maps.keys()):
if maparea == "all":
@ -225,7 +254,7 @@ def prospecting_image(request, name):
text = maparea + " map"
textlen = draw.textsize(text)[0] + 3
draw.rectangle([l, t, l+textlen, t+TEXTSIZE+2], fill='#ffffff')
draw.text((l+2, t+1), text, fill="#000000")
draw.text((l+2, t+1), text, fill="#000000", font=myFont)
#imgmaps.append( [l, t, l+textlen, t+SIZE+2, "submap" + maparea, maparea + " subarea map"] )
draw.line([l, t, r, t], fill='#777777', width=LINEWIDTH)
draw.line([l, b, r, b], fill='#777777', width=LINEWIDTH)
@ -242,13 +271,14 @@ def prospecting_image(request, name):
draw.line([10, TEXTSIZE*2, 10+m100, TEXTSIZE*2], fill='#000000', width=LINEWIDTH)
draw.line([10+m100, TEXTSIZE * 3, 10+m100, TEXTSIZE*2], fill='#000000', width=LINEWIDTH)
label = "100m"
draw.text([10 + (m100 - draw.textsize(label)[0]) / 2, TEXTSIZE/2], label, fill='#000000')
draw.text([10 + (m100 - draw.textsize(label)[0]) / 2, TEXTSIZE/2], label, fill='#000000', font=myFont)
for p in MapLocations.points():
ml = MapLocations()
for p in ml.points():
surveypoint, number, point_type, label = p
plot(surveypoint, number, point_type, label, name, draw, img)
for (N, E, D, num) in [(35975.37, 83018.21, 100,"177"), # Calculated from bearings
for (N, E, D, num) in [(35975.37, 83018.21, 100, "177"), # Calculated from bearings
(35350.00, 81630.00, 50, "71"), # From Auer map
(36025.00, 82475.00, 50, "146"), # From mystery map
(35600.00, 82050.00, 50, "35"), # From Auer map
@ -270,4 +300,5 @@ def prospecting_image(request, name):
response = HttpResponse(content_type = "image/png")
del draw
img.save(response, "PNG")
return response

View File

@ -33,7 +33,7 @@
<a href="{% url "surveyscansfolders" %}">Scans</a> |
<a href="{% url "tunneldata" %}">Drawing files</a> |
<a href="/1623/290/290.html">290 (FGH)</a> |
<a href="/1623/291/291.html">291 (GSH)</a> |
<a href="/1623/291/291">291 (GSH)</a> |
<a href="/1623/204/204.html">204 (Steinbrucken)</a> |
<br>

View File

@ -10,8 +10,9 @@
<p>While this page is generated directly from the current data on all the caves listed, it also contains information which has not been curated and updated since about 1999. References to 'top camp' are likely to be to the 'old top camp' which was near the Schwarzmoossattel (the col) and not near Stone Bridge.
<p>Open leads and prospects for discoveries should be looked for in the various <a href="/handbook/troggle/scriptsqms.html">current QMs systems</a> instead.
<p>This report is a relic of the AERW 'spreadsheet+script' days before troggle, and was designed to be printed out to be taken into the field on paper. It should be retired when we eventually get the <a href="/map">clickable map system</a> working with entrances present and labelled (not yet in April 2021).
<p>The sub-ares names: '1a', '2a' etc. have not been in active use for some years as all exploration for at least the past two decades has been on the mid- to far-plateau.
<p>This report is a relic of the AERW 'spreadsheet+script' days before troggle, and was designed to be printed out to be taken into the field on paper. It should be retired as the <a href="/map/map.htm">clickable map system</a> is now working with entrances present and labelled (though not yet hot-linked to the relevant cave and entrance descriptions). This replaces the old prospecting guide map based on <a href="/expofiles/location_maps/pguidemap.jpg">/expofiles/location_maps/pguidemap.jpg</a>. But a much better map to print out is the 2015 contour map with all the caves: <a href="/expofiles/location_maps/Expo%202015%20Poster%20OverviewNorth.pdf">/expofiles/location_maps/Expo 2015 Poster OverviewNorth.pdf</a>.
<p>The sub-areas names: '1a', '2a' etc. have not been in active use for some years as all exploration for at least the past two decades has been on the mid- to far-plateau.
<p><b>Notes:</b></p>
<ul><li>A marking status of "Retag" means a tag is in place but it carries a provisional number, or in some cases an incorrect number, and needs replacing with a new tag.</li>

77
urls.py
View File

@ -7,12 +7,16 @@ from django.contrib import admin
from django.contrib import auth
from django.urls import reverse, resolve
from troggle.core.views import surveys, logbooks, other, caves, statistics, survex
from troggle.core.views import surveys, other, caves, statistics, survex
from troggle.core.views.other import troggle404, frontpage
from troggle.core.views.caves import ent, cavepage
from troggle.core.views.prospect import prospecting_image, prospecting
from troggle.core.views.logbooks import get_logbook_entries, logbookentry, logbookSearch
from troggle.core.views.logbooks import personindex, person, get_people
from troggle.core.views.logbooks import expedition, personexpedition, Expeditions_tsvListView, Expeditions_jsonListView
from troggle.core.views.prospect import prospecting_image
from troggle.core.views.prospect import prospecting
from troggle.core.views.statistics import pathsreport, stats, dataissues
from troggle.core.views.expo import expofiles_redirect, expofilessingle, expopage, editexpopage, mediapage
from troggle.core.views.expo import expofiles_redirect, expofilessingle, expopage, editexpopage, mediapage, map, mapfile
from troggle.core.views.survex import survexcaveslist, survexcavesingle, svx
from troggle.core.views.auth import expologin, expologout
"""This sets the actualurlpatterns[] and urlpatterns[] lists which django uses
@ -56,15 +60,15 @@ else:
# accounts/reset/done/ [name='password_reset_complete']
trogglepatterns = [
url(r'^expofiles/', include(expofilesurls)),
url(r'^expofiles/', include(expofilesurls)),
url(r'^troggle$', other.frontpage, name="frontpage"), # control panel. Shows recent actions.
url(r'^caves$', caves.caveindex, name="caveindex"),
url(r'^indxal.htm$', caves.caveindex, name="caveindex"), # ~420 hrefs to this url in expoweb files
url(r'^people/?$', logbooks.personindex, name="personindex"),
url(r'^people/?$', personindex, name="personindex"),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # needs docutils Python module (http://docutils.sf.net/).
url(r'^admin/', admin.site.urls), # includes admin login & logout urls
url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # needs docutils Python module (http://docutils.sf.net/).
url(r'^admin/', admin.site.urls), # includes admin login & logout urls
# setting LOGIN_URL = '/accounts/login/' is default
# url ENDS WITH this string
@ -72,32 +76,36 @@ trogglepatterns = [
url(r'login/$', expologin, name='expologin'), # higher precedence than /accounts/login
#url(r'^accounts/', include('django.contrib.auth.urls')), # from Dj3.0, see site-packages\registration\auth_urls_classes.py
# url(r'^person/(?P<person_id>\d*)/?$', logbooks.person),
url(r'^person/(?P<first_name>[A-Z]*[a-z\-\'&;]*)[^a-zA-Z]*(?P<last_name>[a-z\-\']*[^a-zA-Z]*[A-Z]*[a-z\-&;]*)/?', logbooks.person, name="person"),
# Persons - nasty surname recognition logic fails for 19 people!
# url(r'^person/(?P<person_id>\d*)/?$', person), makes Ruairidh MacLeod work but kills MacLean
# url(r'^person/(\w+_\w+)$', logbooks.person, name="person"),
url(r'^person/(?P<first_name>[A-Z]*[a-z\-\'&;]*)[^a-zA-Z]*(?P<last_name>[a-z\-\']*[^a-zA-Z]*[A-Z]*[a-z\-&;]*)/?', person, name="person"),
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z&;]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-zA-Z&;]*)/(?P<year>\d+)/?$', personexpedition, name="personexpedition"),
url(r'^expedition/(\d+)$', logbooks.expedition, name="expedition"),
url(r'^api/expeditions_tsv$', logbooks.Expeditions_tsvListView.as_view()),
url(r'^api/expeditions_json$', logbooks.Expeditions_jsonListView.as_view()),
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z&;]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-zA-Z&;]*)/(?P<year>\d+)/?$', logbooks.personexpedition, name="personexpedition"),
# Expedition master page
url(r'^expedition/(\d+)$', expedition, name="expedition"),
url(r'^api/expeditions_tsv$', Expeditions_tsvListView.as_view()),
url(r'^api/expeditions_json$', Expeditions_jsonListView.as_view()),
# Logbook entries
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', logbooks.logbookentry,name="logbookentry"),
url(r'^getLogBookEntries/(?P<expeditionslug>.*)', logbooks.get_logbook_entries, name = "get_logbook_entries"), #works
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', logbookentry,name="logbookentry"),
url(r'^newfile', other.newFile, name="newFile"), # oddly broken, needs investigating more
url(r'^logbooksearch/(.*)/?$', logbooks.logbookSearch),
url(r'^logbooksearch/(.*)/?$', logbookSearch),
url(r'^logbook(?P<year>\d\d\d\d)\.(?P<extension>.*)/?$', other.downloadLogbook),
url(r'^logbook/?$', other.downloadLogbook, name="downloadlogbook"),
# Internal. editfile.html template uses these internally
url(r'^getPeople/(?P<expeditionslug>.*)', get_people, name = "get_people"),
url(r'^getLogBookEntries/(?P<expeditionslug>.*)', get_logbook_entries, name = "get_logbook_entries"),
url(r'^getQMs/(?P<caveslug>.*)', caves.get_qms, name = "get_qms"),
url(r'^getEntrances/(?P<caveslug>.*)', caves.get_entrances, name = "get_entrances"),
# QMs pages
url(r'^cave/qms/([^/]+)/?$', caves.caveQMs), # blank page
# QMs pages - must precede other /caves pages
url(r'^cave/qms/([^/]+)/?$', caves.caveQMs), # blank page usually
url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', caves.qm, name="qm"),
url(r'^cave/(?P<cave_id>[^/]+)/qm\.csv/?$', other.downloadQMs, name="downloadqms"),
url(r'^newqmnumber/?$', other.ajax_QM_number, ),
url(r'^getQMs/(?P<caveslug>.*)', caves.get_qms, name = "get_qms"), # no template "get_qms"?
url(r'^getPeople/(?P<expeditionslug>.*)', logbooks.get_people, name = "get_people"), # fails
url(r'^downloadqms$', other.downloadQMs),
url(r'^newqmnumber/?$', other.ajax_QM_number, ), # blank page if no ch given
# url(r'^downloadqms$', other.downloadQMs), # MultiValueDictKeyError
# Cave description pages
url(r'^cave/new/$', caves.edit_cave, name="newcave"),
@ -105,14 +113,13 @@ trogglepatterns = [
url(r'^cave/(?P<cave_id>[^/]+)/?$', caves.cave, name="cave"),
url(r'^cave/(?P<cave_id>[^/]+)/?(?P<ent_letter>[^/])$', ent), # view_caves.ent
url(r'^cave/(?P<slug>[^/]+)/edit/$', caves.edit_cave, name="edit_cave"),
url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', caves.qm, name="qm"),
url(r'^cave/entrance/([^/]+)/?$', caves.caveEntrance),
url(r'^cave/entrance/([^/]+)/?$', caves.caveEntrance),
url(r'^cave/description/([^/]+)/?$', caves.caveDescription),
url(r'^cave/logbook/([^/]+)/?$', caves.caveLogbook),
url(r'^(?P<karea>\d\d\d\d)(?P<subpath>.*)$', cavepage, name="cavepage"), # shorthand references such as /1623/264
url(r'^cave/logbook/([^/]+)/?$', caves.caveLogbook),
url(r'^(?P<karea>162\d)(?P<subpath>.*)$', cavepage, name="cavepage"), # shorthand /1623/264 BUT url links may break
url(r'^getEntrances/(?P<caveslug>.*)', caves.get_entrances, name = "get_entrances"), #works e.g. /getEntrances/1623-161 # CASE SENSITIVE
# Entrances
url(r'^entrance/(?P<caveslug>[^/]+)/(?P<slug>[^/]+)/edit/', caves.editEntrance, name = "editentrance"),
url(r'^entrance/new/(?P<caveslug>[^/]+)/', caves.editEntrance, name = "newentrance"), # NOT WORKING
@ -124,10 +131,6 @@ trogglepatterns = [
url(r'^controlpanel/?$', other.controlPanel, name="controlpanel"),
url(r'^prospecting_guide/$', prospecting),
url(r'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"),
# The survexfile pages
url(r'^survexfile/(?P<survex_file>.*?)\.svx$', survex.svx, name="svx"),
url(r'^survexfile/(?P<survex_file>.*?)\.3d$', survex.threed, name="threed"),
@ -151,14 +154,18 @@ trogglepatterns = [
# url(r'^tunneldatainfo/(?P<path>.+?\.xml)$', surveys.tunnelfileinfo, name="tunnelfileinfo"), # parses tunnel for info
url(r'^tunneldataraw/(?P<path>.+?\.xml)/upload$', surveys.tunnelfileupload, name="tunnelfileupload"),
# Prospecting Guide document
url(r'^prospecting_guide/$', prospecting),
url(r'^prospecting/(?P<name>[^.]+).png$', prospecting_image, name="prospecting_image"),
# This next set are all intercepted by Apache, if it is running.
url(r'^photos/(?P<subpath>.*)$', mediapage, {'doc_root': settings.PHOTOS_ROOT}, name="mediapage"), # photo galleries
url(r'^site_media/(?P<subpath>.*)$', mediapage, {'doc_root': settings.MEDIA_ROOT}, name="mediapage"), # MEDIA_ROOT: CSS and JS
url(r'^static/(?P<subpath>.*)$', mediapage, {'doc_root': settings.MEDIA_ROOT}, name="mediapage"), # STATIC is in MEDIA now!
url(r'^javascript/(?P<subpath>.*)$', mediapage, {'doc_root': settings.JSLIB_ROOT}, name="mediapage"), # JSLIB_URL
url(r'^expowebcache/3d/(?P<subpath>.*)$', mediapage, {'doc_root': settings.THREEDCACHEDIR}, name="mediapage"),
# url(r'^map/', .........), # Intercepted by Apache. Yields OpenStreetMap. Redirects to expoweb/map
url(r'^map/map.html', map, name="map"), # Redirects to OpenStreetMap JavaScript
url(r'^map/(?P<path>.*)$', mapfile, name="mapfile"), # css, js, gpx
# Final catchall which also serves expoweb handbook pages and images
url(r'^(.*)_edit$', editexpopage, name="editexpopage"),