diff --git a/noinfo/prospecting_guide_scripts/make-prospectingguide-new.py b/noinfo/prospecting_guide_scripts/make-prospectingguide-new.py index 7a81e8bab..18350f503 100644 --- a/noinfo/prospecting_guide_scripts/make-prospectingguide-new.py +++ b/noinfo/prospecting_guide_scripts/make-prospectingguide-new.py @@ -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 "" + if not s: return "" 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 "" 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 "" + if cave["Multiple entrances"] not in ["", "yes"]: return "" if not s: return "None" - if s and (s.find(" -1 or s.find(" -1): + if s.find(" -1 or s.find(" -1: return "Yes" else: return "Missing" def have_survey_data(cave): - if(cave["Multiple entrances"] not in ["", "yes"]): return "" + if cave["Multiple entrances"] not in ["", "yes"]: return "" s = chomp(cave["Underground centre line"]) if s: return "Yes" 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 "" if not s: return "None" - if s and (s.find(" -1 or s.find(" -1): + if s.find(" -1 or s.find(" -1: return "Yes" else: return "Missing" @@ -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öhle"], -"76": [35440.0, 83220.0, 36090.0, 82670.0, 3.0, - "Eislufthöhle"], -"204": [36354.1, 84154.5, 37047.4, 83399.7, 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"], +# 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öhle"], +"76": [35440.0, 83220.0, 36090.0, 82670.0, 3.0, "Eislufthöhle"], +"204": [36354.1, 84154.5, 37047.4, 83399.7, 3.0, "Steinbrückenhö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ß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("" % (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 = "—" + 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 = " " elif(loctuple): - locn = "%d%d%d" % loctuple + locn = "%d%d%d" % loctuple cavestoplot.append((loctuple, number, area, label)) else: locn = "" % findability_color(cave) + (cave["Findability"] or '?') + "" @@ -439,10 +437,10 @@ else: htmlfile = file("../../handbook/prospecting_guide.html", "w") htmlfile.write("Prospecting Guide\n") -#htmlfile.write("\n"); +htmlfile.write("\n") htmlfile.write(""" """) -htmlfile.write("

Prospecting Guide

"); -htmlfile.write("\n"); +htmlfile.write("

Prospecting Guide

") htmlfile.write("

Generated " + time.strftime("%Y-%m-%d %H:%M:%S %Z") + " by " + sys.argv[0] + "

\n") htmlfile.write("

Notes:

  • 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.
  • \n
  • Kataster status codes indicate the size of a cave, its character and its exploration status, as described here.
  • For more info on each cave, see the links to detailed description pages.
\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äuning Nase laser point") plot(positions["226-96"], "BZkn", "6", "Brä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ß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("%s%s" % (cave["Autogen file"], longnumber(cave, number), number.replace("—", ""), cave["Name"] or cave["Unofficial Name"])) else: - htmlfile.write("%s%s" % (longnumber(cave, number), number.replace("—", ""), cave["Name"] or cave["Unofficial Name"])) + htmlfile.write("%s%s" % (longnumber(cave, number), number.replace("—", ""), 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("%s %s" % (cave["Location"], cave["Bearings"])) htmlfile.write("\n") - + htmlfile.write("\n") for maparea in imgmaps.keys():