diff options
Diffstat (limited to 'core/views_caves.py')
-rw-r--r-- | core/views_caves.py | 225 |
1 files changed, 113 insertions, 112 deletions
diff --git a/core/views_caves.py b/core/views_caves.py index af76b1e..bc5aa1a 100644 --- a/core/views_caves.py +++ b/core/views_caves.py @@ -50,7 +50,7 @@ def caveCmp(x, y): return numericalcmp(x.unofficial_number, y.unofficial_number) def caveindex(request): - caves = Cave.objects.all() + #caves = Cave.objects.all() notablecavehrefs = settings.NOTABLECAVESHREFS notablecaves = [Cave.objects.get(kataster_number=kataster_number) for kataster_number in notablecavehrefs ] caves1623 = list(Cave.objects.filter(area__short_name = "1623")) @@ -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 – 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') - ] + #('', '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): @@ -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öhle"], -"76": [35440.0, 83220.0, 36090.0, 82670.0, 1.3, - "Eislufthöhle"], -"204": [36354.1, 84154.5, 37047.4, 83300, 3.0, - "Steinbrückenhö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öhle"], +"76": [35440.0, 83220.0, 36090.0, 82670.0, 1.3, + "Eislufthöhle"], +"204": [36354.1, 84154.5, 37047.4, 83300, 3.0, + "Steinbrückenhö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ä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 |