merge ol's prospecting guide changes

This commit is contained in:
expo 2015-06-24 03:59:57 +01:00
commit be70d66913

View File

@ -56,7 +56,7 @@ def exists_in_path(cmd):
extensions = os.environ.get("PATHEXT", "").split(os.pathsep)
for directory in os.environ.get("PATH", "").split(os.pathsep):
base = os.path.join(directory, cmd)
base = os.path.join(directory, cmd)
options = [base] + [(base + ext) for ext in extensions]
for filename in options:
if os.path.exists(filename):
@ -65,7 +65,7 @@ def exists_in_path(cmd):
def chomp(s):
if not s: return s
if(s[-1]=="\n"): return s[:-1]
if s[-1]=="\n": return s[:-1]
else: return s
def find_effective_number(c):
@ -77,25 +77,25 @@ def find_effective_number(c):
def longnumber(c, number):
"""Both numbers"""
if (c["Unofficial number"] and c["Unofficial number"] != number):
if c["Unofficial number"] and c["Unofficial number"] != number:
return number + " (" + c["Unofficial number"] + ")"
else:
return number
def find_location(cave):
for fixtype in ["tag point in dataset", "other point in dataset", "exact entrance in dataset (drip line/highest enclosed contour)", "GPS post SA", "GPS pre SA"]:
if(cave[fixtype]):
if cave[fixtype]:
return positions[cave[fixtype]]
return 0
def is_explored(cave):
s = cave["Kat Status Code"]
if(not s): return "<td></td>"
if not s: return "<td></td>"
s = s.replace("(?)","")
if s[-1] == " ": s=s[:-1]
if (not s):
print "Rogue space in " + find_effective_number(cave)
if not s:
print "Rogue space in " + find_effective_number(cave)
return "<td></td>"
code = s[-1]
if code == '+': status = "good"
@ -124,16 +124,16 @@ def findability_color(cave):
def is_underground_surveyed(cave):
s = chomp(cave["Underground drawn survey"])
if(cave["Multiple entrances"] not in ["", "yes"]): return "<td></td>"
if cave["Multiple entrances"] not in ["", "yes"]: return "<td></td>"
if not s:
return "<td class=\"awful\">None</td>"
if s and (s.find("<img") > -1 or s.find("<a") > -1):
if s.find("<img") > -1 or s.find("<a") > -1:
return "<td class=\"good\">Yes</td>"
else:
return "<td class=\"bad\">Missing</td>"
def have_survey_data(cave):
if(cave["Multiple entrances"] not in ["", "yes"]): return "<td></td>"
if cave["Multiple entrances"] not in ["", "yes"]: return "<td></td>"
s = chomp(cave["Underground centre line"])
if s: return "<td class=\"good\">Yes</td>"
s = chomp(cave["Survex file to get length and depth"])
@ -149,11 +149,11 @@ def have_survey_data(cave):
def has_photo(cave):
s = chomp(cave["Photo of location"])
if ((cave["Multiple entrances"] not in ["", "yes"]) and chomp(cave["Autogen file"]) == ""):
if (cave["Multiple entrances"] not in ["", "yes"]) and chomp(cave["Autogen file"]) == "":
return "<td></td>"
if not s:
return "<td class=\"awful\">None</td>"
if s and (s.find("<img") > -1 or s.find("<a") > -1):
if s.find("<img") > -1 or s.find("<a") > -1:
return "<td class=\"good\">Yes</td>"
else:
return "<td class=\"bad\">Missing</td>"
@ -165,7 +165,7 @@ def find_label(cave, number):
else: t += cave["Unofficial Name"]
try:
n = number
if(n[-1] in string.lowercase): n = n[:-1]
if n[-1] in string.lowercase: n = n[:-1]
except:
n = "NONE"
if lengths.has_key(n):
@ -186,24 +186,18 @@ def get_img_name(maparea):
# big map first (zoom factor ignored)
maps = {
# id left top right bottom zoom
# id left top right bottom zoom description
# G&K G&K G&K G&K factor
"all": [34950.9, 86300.0, 38325.0, 80895.6, 1.0,
"All"],
"40": [36275.6, 82392.5, 36780.3, 81800.0, 3.0,
"Eish&ouml;hle"],
"76": [35440.0, 83220.0, 36090.0, 82670.0, 3.0,
"Eislufth&ouml;hle"],
"204": [36354.1, 84154.5, 37047.4, 83399.7, 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"],
# DO NOT just change the coordinates of "all" - they MUST match the borders of the scanned map.
"all": [34394.9, 84508.6, 37399.4, 80895.6, 1.0, "All"],
"40": [36275.6, 82392.5, 36780.3, 81800.0, 3.0, "Eish&ouml;hle"],
"76": [35440.0, 83220.0, 36090.0, 82670.0, 3.0, "Eislufth&ouml;hle"],
"204": [36354.1, 84154.5, 37047.4, 83399.7, 3.0, "Steinbr&uuml;ckenh&ouml;hle"],
"tc": [35230.0, 82690.0, 36110.0, 82100.0, 3.0, "Near Top Camp"],
"gk": [36000.0, 86300.0, 38320.0, 84400.0, 4.0, "Grie&szlig;kogel Area"],
}
# Keys in the order in which we want the maps output
mapcodes = ["all", "grieß","40", "76", "204", "tc"]
mapcodes = ["all", "gk", "40", "76", "204", "tc"]
# Field codes
L = 0
T = 1
@ -267,7 +261,7 @@ def mungecoord(x, y, mapcode):
# image is 1417 by 2201
# FACTOR1 = 1000.0 / (36670.0-34542.0)
# FACTOR2 = (1201.0-562.0) / (83317 - 81967)
# FACTOR = (FACTOR1 + FACTOR2)/2
# 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.
@ -297,7 +291,7 @@ def plot(loctuple, number, area, label):
def writeout_imagemap(data, mapname):
# Munge the list of coordinates into a proper image map.
# There is a wrinkle here: the HTML spec gives priority
# There is a wrinkle here: the HTML spec gives priority
# to the _first_ defined elt, so we swap the order!
n = len(data)
htmlfile.write("<map id=\"%s\" name=\"%s\">" % (mapname, mapname))
@ -341,9 +335,13 @@ for fnm in ("../all.3d", "../alltracks.3d"):
draw = draws[mapcode]
lastx, lasty = 0, 0
for l in file3d:
# Quickly skip data we aren't interested in
if l.startswith("ERROR_INFO"): continue
if l.startswith("XSECT"): continue
match = re.match(r'''
^ #start
(MOVE|LINE|NODE|XSECT|XSECT_END|STOP) #one of six data types
(MOVE|LINE|NODE) #data type
\s+(-?[0-9.]+) #X-co-ord
\s+(-?[0-9.]+) #Y-co-ord
\s+(-?[0-9.]+) #altitude
@ -359,11 +357,11 @@ for fnm in ("../all.3d", "../alltracks.3d"):
)? #end of optional flags group
$ #end of the line
''', l, re.VERBOSE)
if not match:
if not match:
print "Unknown: " + l
continue
act,E,N,alt,name,flags = match.groups()
# print "act:%s, E:%s, N:%s, name:%s flags:%s" % (act,E,N,name,flags)
# Only need to process NODEs once
@ -393,24 +391,24 @@ for fnm in ("../all.3d", "../alltracks.3d"):
surfacecolour = "#008000"
repath = re.compile(r'^')
print "Done"
cavestoplot = []
for cave in cavetab:
if cave["Link file"]: continue
number = find_effective_number(cave)
if(cave["Multiple entrances"] not in ["", "yes"]):
if cave["Multiple entrances"] not in ["", "yes"]:
number = "&mdash;" + cachednumber + cave["Entrances"]
shortnumber = cachednumber
if not cave["Area"]: cave["Area"] = cachedarea
if not cave["Name"]: cave["Name"] = cachedname
else:
else:
cachednumber = number
shortnumber = number
cachedname = cave["Name"] or cave["Unofficial Name"]
cachedarea = cave["Area"]
area = cave["Area"]
# We have some areas like '2b or 4 (unclear)' - just chop the space
# We have some areas like '2b or 4 (unclear)' - just chop the space
# and everything after it for these.
area = re.sub(r' .*', "", area)
if area == '1626' or area == 'nonexistent': continue
@ -420,11 +418,11 @@ for cave in cavetab:
except:
print "Unable to find location for %s" % (number)
else:
label = find_label(cave, shortnumber)
label = find_label(cave, shortnumber)
if(cave["Multiple entrances"] == "yes"):
locn = "<td colspan=\"3\">&nbsp;</td>"
elif(loctuple):
locn = "<td class=\"locn good\">%d</td><td class=\"locn good\">%d</td><td class=\"locn good\">%d</td>" % loctuple
locn = "<td class=\"locn good\">%d</td><td class=\"locn good\">%d</td><td class=\"locn good\">%d</td>" % loctuple
cavestoplot.append((loctuple, number, area, label))
else:
locn = "<td colspan=\"3\" class=%s>" % findability_color(cave) + (cave["Findability"] or '?') + "</td>"
@ -439,10 +437,10 @@ else:
htmlfile = file("../../handbook/prospecting_guide.html", "w")
htmlfile.write("<html><head><meta http-equiv=\"Content-type\" content=\"text/html;charset=UTF-8\"><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("<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 }
@ -453,11 +451,7 @@ htmlfile.write("""
.notours .bad { background-color: #ffffff; }
.notours .awful { background-color: #ffffff; }
</style></head>""")
htmlfile.write("<body><h1>Prospecting Guide</h1>");
htmlfile.write("<script lang=\"Javascript\"><!--\n");
for maparea in mapcodes:
htmlfile.write("bg%s = false;\n" % maparea);
htmlfile.write("//-->\n</script>\n");
htmlfile.write("<body><h1>Prospecting Guide</h1>")
htmlfile.write("<p><small>Generated " + time.strftime("%Y-%m-%d %H:%M:%S %Z") + " by " + sys.argv[0] + "</small></p>\n")
htmlfile.write("<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>\n<li>Kataster status codes indicate the size of a cave, its character and its exploration status, as described <a href=\"../katast.htm\">here</a>.</li><li>For more info on each cave, see the links to detailed description pages.</li></ul>\n")
@ -499,7 +493,7 @@ for p in fakedpositions:
print "Couldn't understand" + repr(chomp(p))
continue
# Find the area with this cave in
# Find the area with this cave in
area = ''
for tryarea in areas:
for (number, cave, locn) in cavelists[tryarea]:
@ -510,7 +504,7 @@ for p in fakedpositions:
# but I don't know how to in Python
if area != '':
break
(x,y,d) = map(float, (x,y,d))
for maparea in maps.keys():
lo = mungecoord(x-d, y+d, maparea)
@ -528,7 +522,7 @@ for p in fakedpositions:
plot(positions["laser.0_7"], "BNase", "6", "Br&auml;uning Nase laser point")
plot(positions["226-96"], "BZkn", "6", "Br&auml;uning Zinken trig point")
plot(positions["vd1"],"VD1","6", "VD1 survey point")
plot(positions["laser.kt114_96"],"HSK","6", "Hinterer Schwarzmooskogel trig point")
plot(positions["laser.kt114_96"],"HSK","6", "Hinterer Schwarzmooskogel trig point")
plot(positions["2000"],"Nipple","6", "Nipple (Wei&szlig;e Warze)")
plot(positions["3000"],"VSK","6", "Vorderer Schwarzmooskogel summit")
plot(positions["topcamp"], "TC", "6", "Top Camp")
@ -561,7 +555,7 @@ for area in areas:
if cave["Autogen file"]:
htmlfile.write("<td><a href=\"../%s\">%s</a></td><td><a id=\"id%s\">%s</a></td>" % (cave["Autogen file"], longnumber(cave, number), number.replace("&mdash;", ""), cave["Name"] or cave["Unofficial Name"]))
else:
htmlfile.write("<td>%s</td><td><a id=\"id%s\">%s</a></td>" % (longnumber(cave, number), number.replace("&mdash;", ""), cave["Name"] or cave["Unofficial Name"]))
htmlfile.write("<td>%s</td><td><a id=\"id%s\">%s</a></td>" % (longnumber(cave, number), number.replace("&mdash;", ""), cave["Name"] or cave["Unofficial Name"]))
htmlfile.write(is_explored(cave))
htmlfile.write(have_survey_data(cave))
@ -570,10 +564,10 @@ for area in areas:
htmlfile.write(has_photo(cave))
htmlfile.write(locn)
if(cave["Findability"] != "Surveyed" and cave["Multiple entrances"] != "yes"):
if cave["Findability"] != "Surveyed" and cave["Multiple entrances"] != "yes":
htmlfile.write("<td class=\"locn\">%s %s</td>" % (cave["Location"], cave["Bearings"]))
htmlfile.write("</tr>\n")
htmlfile.write("</table>\n")
for maparea in imgmaps.keys():