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
@ -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
@ -398,7 +396,7 @@ 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
@ -410,7 +408,7 @@ for cave in cavetab:
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,7 +418,7 @@ 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):
@ -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")
@ -570,7 +564,7 @@ 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")