summaryrefslogtreecommitdiffstats
path: root/core/views_caves.py
diff options
context:
space:
mode:
authorSam Wenham <sam@wenhams.co.uk>2019-07-16 00:07:37 +0100
committerSam Wenham <sam@wenhams.co.uk>2019-07-16 00:07:37 +0100
commit08a41941f9e2b35b16548624d5070216dd933f79 (patch)
treecfd0bd7dfc68c77cf66d92d72b6d1d74e6155880 /core/views_caves.py
parenta26109cb3006dd64e1bec38100397ad636813e98 (diff)
downloadtroggle-08a41941f9e2b35b16548624d5070216dd933f79.tar.gz
troggle-08a41941f9e2b35b16548624d5070216dd933f79.tar.bz2
troggle-08a41941f9e2b35b16548624d5070216dd933f79.zip
Part one of getting troggle to work with django 1.10
Major rework of how survex is processed
Diffstat (limited to 'core/views_caves.py')
-rw-r--r--core/views_caves.py225
1 files changed, 113 insertions, 112 deletions
diff --git a/core/views_caves.py b/core/views_caves.py
index af76b1e..7b0555f 100644
--- a/core/views_caves.py
+++ b/core/views_caves.py
@@ -37,7 +37,7 @@ def numericalcmp(x, y):
-def caveCmp(x, y):
+def caveCmp(x, y):
if x.kataster_number:
if y.kataster_number:
return numericalcmp(x.kataster_number, y.kataster_number) # Note that cave kataster numbers are not generally integers.
@@ -240,7 +240,7 @@ def entranceSlug(request, slug):
def survexblock(request, survexpath):
survexpath = re.sub("/", ".", survexpath)
- print "jjjjjj", survexpath
+ print("jjjjjj", survexpath)
survexblock = models.SurvexBlock.objects.get(survexpath=survexpath)
#ftext = survexblock.filecontents()
ftext = survexblock.text
@@ -277,30 +277,30 @@ def get_qms(request, caveslug):
return render(request,'options.html', {"items": [(e.entrance.slug(), e.entrance.slug()) for e in cave.entrances()]})
areanames = [
- #('', 'Location unclear'),
- ('1a', '1a &ndash; Plateau: around Top Camp'),
- ('1b', '1b &ndash; Western plateau near 182'),
- ('1c', '1c &ndash; Eastern plateau near 204 walk-in path'),
- ('1d', '1d &ndash; Further plateau around 76'),
- ('2a', '2a &ndash; Southern Schwarzmooskogel near 201 path and the Nipple'),
- ('2b', '2b &ndash; Eish&ouml;hle area'),
- ('2b or 4 (unclear)', '2b or 4 (unclear)'),
- ('2c', '2c &ndash; Kaninchenh&ouml;hle area'),
- ('2d', '2d &ndash; Steinbr&uuml;ckenh&ouml;hle area'),
- ('3', '3 &ndash; Br&auml;uning Alm'),
- ('4', '4 &ndash; Kratzer valley'),
- ('5', '5 &ndash; Schwarzmoos-Wildensee'),
- ('6', '6 &ndash; Far plateau'),
- ('1626 or 6 (borderline)', '1626 or 6 (borderline)'),
- ('7', '7 &ndash; Egglgrube'),
- ('8a', '8a &ndash; Loser south face'),
- ('8b', '8b &ndash; Loser below Dimmelwand'),
- ('8c', '8c &ndash; Augst See'),
- ('8d', '8d &ndash; Loser-Hochganger ridge'),
- ('9', '9 &ndash; Gschwandt Alm'),
- ('10', '10 &ndash; Altaussee'),
- ('11', '11 &ndash; Augstbach')
- ]
+ #('', 'Location unclear'),
+ ('1a', '1a &ndash; Plateau: around Top Camp'),
+ ('1b', '1b &ndash; Western plateau near 182'),
+ ('1c', '1c &ndash; Eastern plateau near 204 walk-in path'),
+ ('1d', '1d &ndash; Further plateau around 76'),
+ ('2a', '2a &ndash; Southern Schwarzmooskogel near 201 path and the Nipple'),
+ ('2b', '2b &ndash; Eish&ouml;hle area'),
+ ('2b or 4 (unclear)', '2b or 4 (unclear)'),
+ ('2c', '2c &ndash; Kaninchenh&ouml;hle area'),
+ ('2d', '2d &ndash; Steinbr&uuml;ckenh&ouml;hle area'),
+ ('3', '3 &ndash; Br&auml;uning Alm'),
+ ('4', '4 &ndash; Kratzer valley'),
+ ('5', '5 &ndash; Schwarzmoos-Wildensee'),
+ ('6', '6 &ndash; Far plateau'),
+ ('1626 or 6 (borderline)', '1626 or 6 (borderline)'),
+ ('7', '7 &ndash; Egglgrube'),
+ ('8a', '8a &ndash; Loser south face'),
+ ('8b', '8b &ndash; Loser below Dimmelwand'),
+ ('8c', '8c &ndash; Augst See'),
+ ('8d', '8d &ndash; Loser-Hochganger ridge'),
+ ('9', '9 &ndash; Gschwandt Alm'),
+ ('10', '10 &ndash; Altaussee'),
+ ('11', '11 &ndash; Augstbach')
+ ]
def prospecting(request):
@@ -318,21 +318,21 @@ def prospecting(request):
# big map first (zoom factor ignored)
maps = {
-# id left top right bottom zoom
-# G&K G&K G&K G&K factor
-"all": [33810.4, 85436.5, 38192.0, 81048.2, 0.35,
- "All"],
-"40": [36275.6, 82392.5, 36780.3, 81800.0, 3.0,
- "Eish&ouml;hle"],
-"76": [35440.0, 83220.0, 36090.0, 82670.0, 1.3,
- "Eislufth&ouml;hle"],
-"204": [36354.1, 84154.5, 37047.4, 83300, 3.0,
- "Steinbr&uuml;ckenh&ouml;hle"],
-"tc": [35230.0, 82690.0, 36110.0, 82100.0, 3.0,
- "Near Top Camp"],
+# id left top right bottom zoom
+# G&K G&K G&K G&K factor
+"all": [33810.4, 85436.5, 38192.0, 81048.2, 0.35,
+ "All"],
+"40": [36275.6, 82392.5, 36780.3, 81800.0, 3.0,
+ "Eish&ouml;hle"],
+"76": [35440.0, 83220.0, 36090.0, 82670.0, 1.3,
+ "Eislufth&ouml;hle"],
+"204": [36354.1, 84154.5, 37047.4, 83300, 3.0,
+ "Steinbr&uuml;ckenh&ouml;hle"],
+"tc": [35230.0, 82690.0, 36110.0, 82100.0, 3.0,
+ "Near Top Camp"],
"grieß":
- [36000.0, 86300.0, 38320.0, 84400.0, 4.0,
- "Grießkogel Area"],
+ [36000.0, 86300.0, 38320.0, 84400.0, 4.0,
+ "Grießkogel Area"],
}
for n in maps.keys():
@@ -353,50 +353,50 @@ ZOOM = 4
DESC = 5
areacolours = {
- '1a' : '#00ffff',
- '1b' : '#ff00ff',
- '1c' : '#ffff00',
- '1d' : '#ffffff',
- '2a' : '#ff0000',
- '2b' : '#00ff00',
- '2c' : '#008800',
- '2d' : '#ff9900',
- '3' : '#880000',
- '4' : '#0000ff',
- '6' : '#000000', # doubles for surface fixed pts, and anything else
- '7' : '#808080'
- }
+ '1a' : '#00ffff',
+ '1b' : '#ff00ff',
+ '1c' : '#ffff00',
+ '1d' : '#ffffff',
+ '2a' : '#ff0000',
+ '2b' : '#00ff00',
+ '2c' : '#008800',
+ '2d' : '#ff9900',
+ '3' : '#880000',
+ '4' : '#0000ff',
+ '6' : '#000000', # doubles for surface fixed pts, and anything else
+ '7' : '#808080'
+ }
for FONT in [
- "/usr/share/fonts/truetype/freefont/FreeSans.ttf",
- "/usr/X11R6/lib/X11/fonts/truetype/arial.ttf",
- "C:\WINNT\Fonts\ARIAL.TTF"
- ]:
- if os.path.isfile(FONT): break
+ "/usr/share/fonts/truetype/freefont/FreeSans.ttf",
+ "/usr/X11R6/lib/X11/fonts/truetype/arial.ttf",
+ "C:\WINNT\Fonts\ARIAL.TTF"
+ ]:
+ if os.path.isfile(FONT): break
TEXTSIZE = 16
CIRCLESIZE =8
LINEWIDTH = 2
myFont = ImageFont.truetype(FONT, TEXTSIZE)
def mungecoord(x, y, mapcode, img):
- # Top of Zinken is 73 1201 = dataset 34542 81967
- # Top of Hinter is 1073 562 = dataset 36670 83317
- # image is 1417 by 2201
- # FACTOR1 = 1000.0 / (36670.0-34542.0)
- # FACTOR2 = (1201.0-562.0) / (83317 - 81967)
- # FACTOR = (FACTOR1 + FACTOR2)/2
- # The factors aren't the same as the scanned map's at a slight angle. I
- # can't be bothered to fix this. Since we zero on the Hinter it makes
- # very little difference for caves in the areas round 76 or 204.
- # xoffset = (x - 36670)*FACTOR
- # yoffset = (y - 83317)*FACTOR
- # return (1073 + xoffset, 562 - yoffset)
-
- m = maps[mapcode]
- factorX, factorY = img.size[0] / (m[R] - m[L]), img.size[1] / (m[T] - m[B])
- return ((x - m[L]) * factorX, (m[T] - y) * factorY)
-
+ # Top of Zinken is 73 1201 = dataset 34542 81967
+ # Top of Hinter is 1073 562 = dataset 36670 83317
+ # image is 1417 by 2201
+ # FACTOR1 = 1000.0 / (36670.0-34542.0)
+ # FACTOR2 = (1201.0-562.0) / (83317 - 81967)
+ # FACTOR = (FACTOR1 + FACTOR2)/2
+ # The factors aren't the same as the scanned map's at a slight angle. I
+ # can't be bothered to fix this. Since we zero on the Hinter it makes
+ # very little difference for caves in the areas round 76 or 204.
+ # xoffset = (x - 36670)*FACTOR
+ # yoffset = (y - 83317)*FACTOR
+ # return (1073 + xoffset, 562 - yoffset)
+
+ m = maps[mapcode]
+ factorX, factorY = img.size[0] / (m[R] - m[L]), img.size[1] / (m[T] - m[B])
+ return ((x - m[L]) * factorX, (m[T] - y) * factorY)
+
COL_TYPES = {True: "red",
False: "#dddddd",
"Reference": "#dddddd"}
@@ -422,40 +422,40 @@ def prospecting_image(request, name):
m = maps[name]
#imgmaps = []
if name == "all":
- img = mainImage
+ img = mainImage
else:
- M = maps['all']
- W, H = mainImage.size
- l = int((m[L] - M[L]) / (M[R] - M[L]) * W)
- t = int((m[T] - M[T]) / (M[B] - M[T]) * H)
- r = int((m[R] - M[L]) / (M[R] - M[L]) * W)
- b = int((m[B] - M[T]) / (M[B] - M[T]) * H)
- img = mainImage.crop((l, t, r, b))
- w = int(round(m[ZOOM] * (m[R] - m[L]) / (M[R] - M[L]) * W))
- h = int(round(m[ZOOM] * (m[B] - m[T]) / (M[B] - M[T]) * H))
- img = img.resize((w, h), Image.BICUBIC)
+ M = maps['all']
+ W, H = mainImage.size
+ l = int((m[L] - M[L]) / (M[R] - M[L]) * W)
+ t = int((m[T] - M[T]) / (M[B] - M[T]) * H)
+ r = int((m[R] - M[L]) / (M[R] - M[L]) * W)
+ b = int((m[B] - M[T]) / (M[B] - M[T]) * H)
+ img = mainImage.crop((l, t, r, b))
+ w = int(round(m[ZOOM] * (m[R] - m[L]) / (M[R] - M[L]) * W))
+ 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)
if name == "all":
for maparea in maps.keys():
- if maparea == "all":
- continue
- localm = maps[maparea]
- l,t = mungecoord(localm[L], localm[T], "all", img)
- r,b = mungecoord(localm[R], localm[B], "all", img)
- 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")
- #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)
- draw.line([l, t, l, b], fill='#777777', width=LINEWIDTH)
- draw.line([r, t, r, b], fill='#777777', width=LINEWIDTH)
- draw.line([l, t, l+textlen, t], fill='#777777', width=LINEWIDTH)
- draw.line([l, t+TEXTSIZE+2, l+textlen, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH)
- draw.line([l, t, l, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH)
- draw.line([l+textlen, t, l+textlen, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH)
+ if maparea == "all":
+ continue
+ localm = maps[maparea]
+ l,t = mungecoord(localm[L], localm[T], "all", img)
+ r,b = mungecoord(localm[R], localm[B], "all", img)
+ 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")
+ #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)
+ draw.line([l, t, l, b], fill='#777777', width=LINEWIDTH)
+ draw.line([r, t, r, b], fill='#777777', width=LINEWIDTH)
+ draw.line([l, t, l+textlen, t], fill='#777777', width=LINEWIDTH)
+ draw.line([l, t+TEXTSIZE+2, l+textlen, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH)
+ draw.line([l, t, l, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH)
+ draw.line([l+textlen, t, l+textlen, t+TEXTSIZE+2], fill='#777777', width=LINEWIDTH)
#imgmaps[maparea] = []
# Draw scale bar
m100 = int(100 / (m[R] - m[L]) * img.size[0])
@@ -477,14 +477,15 @@ def prospecting_image(request, name):
plot("laser.0_5", "LSR5", "Reference", "Laser Point 0/5", name, draw, img)
plot("225-96", "BAlm", "Reference", "Br&auml;uning Alm trig point", name, draw, img)
for entrance in Entrance.objects.all():
- station = entrance.best_station()
- if station:
- #try:
- areaName = entrance.caveandentrance_set.all()[0].cave.getArea().short_name
- plot(station, "%s-%s" % (areaName, str(entrance)[5:]), entrance.needs_surface_work(), str(entrance), name, draw, img)
- #except:
- # pass
-
+ station = entrance.best_station()
+ if station:
+ #try:
+ areaName = entrance.caveandentrance_set.all()[0].cave.getArea().short_name
+ plot(station, "%s-%s" % (areaName, str(entrance)
+ [5:]), entrance.needs_surface_work(), str(entrance), name, draw, img)
+ #except:
+ # pass
+
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