[svn r7412] Put the prospecting guide map on the public site, but without the scanned

map backdrop.
This commit is contained in:
olly
2006-06-22 18:06:42 +02:00
parent 3e9b26bc30
commit 4f1de43684
12 changed files with 2018 additions and 47 deletions

View File

@@ -38,7 +38,7 @@ areacolours = {
'2d' : '#ff9900',
'3' : '#880000',
'4' : '#0000ff',
'6' : '#000000', # doubles for surface fixed pts
'6' : '#000000', # doubles for surface fixed pts, and anything else
'7' : '#808080'
}
@@ -164,21 +164,20 @@ def get_img_name(maparea):
return filename
# Parameters for big map and zoomed subarea maps:
# height and width for subareas are calculated automatically from the
# coordinates and the zoom factor
# big map first (zoom factor ignored)
maps = {
# id left top right bottom width height zoom
# G&K G&K G&K G&K pixels pixels (times)
"all": [34394.9, 84508.6, 37399.4, 80895.6, 1417, 1704, 1.0,
# id left top right bottom zoom
# G&K G&K G&K G&K factor
"all": [34394.9, 84508.6, 37399.4, 80895.6, 1.0,
"All"],
"40": [36275.6, 82392.5, 36780.3, 81800.0, 0, 0, 3.0,
"40": [36275.6, 82392.5, 36780.3, 81800.0, 3.0,
"Eishöhle"],
"76": [35440.0, 83320.0, 36090.0, 82770.0, 0, 0, 3.0,
"76": [35440.0, 83320.0, 36090.0, 82770.0, 3.0,
"Eislufthöhle"],
"204": [36354.1, 84154.5, 37047.4, 83399.7, 0, 0, 3.0,
"204": [36354.1, 84154.5, 37047.4, 83399.7, 3.0,
"Steinbrückenhöhle"],
"tc": [35230.0, 82790.0, 36110.0, 82200.0, 0, 0, 3.0,
"tc": [35230.0, 82790.0, 36110.0, 82200.0, 3.0,
"Near Top Camp"],
}
# Keys in the order in which we want the maps output
@@ -188,10 +187,10 @@ L = 0
T = 1
R = 2
B = 3
W = 4
H = 5
Z = 6
D = 7
ZOOM = 4
DESC = 5
allwhite = False
import Image, ImageDraw, ImageFont, string, os, sys
for FONT in [
@@ -203,41 +202,43 @@ for FONT in [
SIZE = 8
myFont = ImageFont.truetype(FONT, SIZE)
M = maps["all"]
mainImage = Image.open("pguidemap.jpg")
#mainImage = Image.new("RGB", (M[W], M[H]), '#ffffff')
if len(sys.argv) > 1 and sys.argv[1] == '--white':
mainImage = Image.new("RGB", mainImage.size, '#ffffff')
imgs = {}
draws = {}
imgmaps = {}
factors = {}
for maparea in maps.keys():
m = maps[maparea]
if maparea == "all":
img = mainImage
else:
l = int((m[L] - M[L]) / (M[R] - M[L]) * M[W])
t = int((m[T] - M[T]) / (M[B] - M[T]) * M[H])
r = int((m[R] - M[L]) / (M[R] - M[L]) * M[W])
b = int((m[B] - M[T]) / (M[B] - M[T]) * M[H])
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[Z] * (m[R] - m[L]) / (M[R] - M[L]) * M[W]))
h = int(round(m[Z] * (m[B] - m[T]) / (M[B] - M[T]) * M[H]))
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))
print "%s: H %d W %d" % (maparea, h, w)
img = img.resize((w, h), Image.BICUBIC)
maps[maparea][H] = h
maps[maparea][W] = w
imgs[maparea] = img
draw = ImageDraw.Draw(img)
draw.setfont(myFont)
draws[maparea] = draw
imgmaps[maparea] = []
# Draw scale bar
m100 = int(100 / (m[R] - m[L]) * m[W])
m100 = int(100 / (m[R] - m[L]) * img.size[0])
draw.line([10, SIZE*3, 10, SIZE*2], fill='#000000')
draw.line([10, SIZE*2, 10+m100, SIZE*2], fill='#000000')
draw.line([10+m100, SIZE * 3, 10+m100, SIZE*2], fill='#000000')
label = "100m"
draw.text([10 + (m100 - draw.textsize(label)[0]) / 2, SIZE/2], label, fill='#000000')
factors[maparea] = img.size[0] / (m[R] - m[L]), img.size[1] / (m[T] - m[B])
def mungecoord(x, y, mapcode):
# Top of Zinken is 73 1201 = dataset 34542 81967
@@ -254,19 +255,24 @@ def mungecoord(x, y, mapcode):
# return (1073 + xoffset, 562 - yoffset)
m = maps[mapcode]
return (x - m[L]) / (m[R] - m[L]) * m[W], (m[T] - y) / (m[T] - m[B]) * m[H]
return ((x - m[L]) * factors[mapcode][0], (m[T] - y) * factors[mapcode][1])
def plot(loctuple, number, area, label):
shortnumber = number.replace("—","")
if area in areacolours:
fillcol = areacolours[area]
else:
fillcol = 6
for maparea in maps.keys():
(x,y) = map(int, mungecoord(loctuple[0], loctuple[1], maparea))
draw = draws[maparea]
imgmaps[maparea].append( [x-4, y-SIZE/2, x+4+draw.textsize(shortnumber)[0], y+SIZE/2, shortnumber, label] )
draw.rectangle([(x+4, y-SIZE/2), (x+4+draw.textsize(shortnumber)[0], y+SIZE/2)], fill="#ffffff")
draw.text((x+6,y-SIZE/2), shortnumber, fill="#000000")
draw.ellipse([(x-4,y-4),(x+4,y+4)], fill=areacolours[area], outline="#000000")
draw.ellipse([(x-4,y-4),(x+4,y+4)], fill=fillcol, outline="#000000")
def writeout_imagemap(data, mapname):
# Munge the list of coordinates into a proper image map.
@@ -374,6 +380,10 @@ for cave in cavetab:
htmlfile = file("../prospecting_guide.html", "w")
htmlfile.write("<html><head><title>Prospecting Guide</title>\n")
htmlfile.write("<script lang=\"Javascript\"><!--\n");
for maparea in mapcodes:
htmlfile.write("bg%s = false;\n" % maparea);
htmlfile.write("//-->\n</script>\n");
htmlfile.write("""
<style type="text/css">
.locn { font-size: x-small }
@@ -388,8 +398,10 @@ htmlfile.write("<p><b>Notes:</b></p><ul><li>A marking status of \"Retag\" means
for maparea in mapcodes:
filename = get_img_name(maparea)
if maparea != "all":
htmlfile.write("<h3 id=\"idsubmap%s\">%s area detail</h3>\n" % (maparea, maps[maparea][D]))
htmlfile.write("<p><img src=\"%s\" usemap=\"#map%s\" ismap=\"ismap\" /></p>\n" % (filename, maparea))
htmlfile.write("<h3 id=\"idsubmap%s\">%s area detail</h3>\n" % (maparea, maps[maparea][DESC]))
htmlfile.write("<button onclick=\"if (bg%s) img%s.src = '%s'; else img%s.src = '../noinfo/%s'; bg%s = !bg%s;\">Toggle Background</button>\n" % (maparea, maparea, filename, maparea, filename, maparea, maparea))
htmlfile.write("<p><img src=\"%s\" usemap=\"#map%s\" ismap=\"ismap\" name=\"img%s\"" % (filename, maparea, maparea))
htmlfile.write(" width=\"%d\" height=\"%d\" /></p>\n" % imgs[maparea].size)
cachednumber = ""
cachedarea = ""
@@ -407,8 +419,6 @@ for maparea in maps.keys():
draws['all'].rectangle([l, t, l+textlen, t+SIZE+2], fill='#ffffff')
draws['all'].text((l+2, t+1), text, fill="#000000")
imgmaps['all'].append( [l, t, l+textlen, t+SIZE+2, "submap" + maparea, maparea + " subarea map"] )
# draws['all'].rectangle([l, t, l+8, t+8], fill='#777777')
# imgmaps['all'].append( [l, t, l+8, t+8, "submap" + maparea, maparea + " subarea map"] )
draws['all'].rectangle([l, t, r, b], outline='#777777')
draws['all'].rectangle([l, t, l+textlen, t+SIZE+2], outline='#777777')
@@ -459,10 +469,7 @@ plot(positions["laser.0_1"], "LSR1", "6", "Laser Point 0/1")
plot(positions["laser.0_5"], "LSR5", "6", "Laser Point 0/5")
for (loctuple, number, area, label) in cavestoplot:
try:
plot(loctuple, number, area, label)
except:
plot(loctuple, number, "6", label)
plot(loctuple, number, area, label)
for area in areas:
if area:

View File

@@ -1,6 +1,10 @@
# Script to create a slightly more useful attempt
# at a prospecting guide.
import sys
print "Don't run this script - use make-prospectingguide-new.py instead"
sys.exit(0)
areas = ['', '1a','1b','1c','1d', '2a', '2b', '2c', '2d', '3', '4', '5', '6','7', '8a', '8b', '8c', '8d', '9', '10', '11']
areanames = {