forked from expo/troggle
stopped storing survex legs
This commit is contained in:
parent
90a5524036
commit
d134a58931
33
core/views_logbooks.py
Normal file → Executable file
33
core/views_logbooks.py
Normal file → Executable file
@ -218,20 +218,41 @@ def pathsreport(request):
|
|||||||
|
|
||||||
|
|
||||||
def experimental(request):
|
def experimental(request):
|
||||||
|
blockroots = models.SurvexBlock.objects.filter(name="root")
|
||||||
|
if len(blockroots)>1:
|
||||||
|
print(" ! more than one root survexblock {}".format(len(blockroots)))
|
||||||
|
for sbr in blockroots:
|
||||||
|
print("{} {} {} {}".format(sbr.id, sbr.name, sbr.text, sbr.date))
|
||||||
|
sbr = blockroots[0]
|
||||||
|
totalsurvexlength = sbr.totalleglength
|
||||||
|
try:
|
||||||
|
nimportlegs = int(sbr.text)
|
||||||
|
except:
|
||||||
|
print("{} {} {} {}".format(sbr.id, sbr.name, sbr.text, sbr.date))
|
||||||
|
nimportlegs = -1
|
||||||
|
|
||||||
legsbyexpo = [ ]
|
legsbyexpo = [ ]
|
||||||
|
addupsurvexlength = 0
|
||||||
for expedition in Expedition.objects.all():
|
for expedition in Expedition.objects.all():
|
||||||
survexblocks = expedition.survexblock_set.all()
|
survexblocks = expedition.survexblock_set.all()
|
||||||
survexlegs = [ ]
|
#survexlegs = [ ]
|
||||||
|
legsyear=0
|
||||||
survexleglength = 0.0
|
survexleglength = 0.0
|
||||||
for survexblock in survexblocks:
|
for survexblock in survexblocks:
|
||||||
survexlegs.extend(survexblock.survexleg_set.all())
|
#survexlegs.extend(survexblock.survexleg_set.all())
|
||||||
survexleglength += survexblock.totalleglength
|
survexleglength += survexblock.totalleglength
|
||||||
legsbyexpo.append((expedition, {"nsurvexlegs":len(survexlegs), "survexleglength":survexleglength}))
|
try:
|
||||||
|
legsyear += int(survexblock.text)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
addupsurvexlength += survexleglength
|
||||||
|
legsbyexpo.append((expedition, {"nsurvexlegs":legsyear, "survexleglength":survexleglength}))
|
||||||
legsbyexpo.reverse()
|
legsbyexpo.reverse()
|
||||||
|
|
||||||
survexlegs = models.SurvexLeg.objects.all()
|
#removing survexleg objects completely
|
||||||
totalsurvexlength = sum([survexleg.tape for survexleg in survexlegs])
|
#survexlegs = models.SurvexLeg.objects.all()
|
||||||
return render(request, 'experimental.html', { "nsurvexlegs":len(survexlegs), "totalsurvexlength":totalsurvexlength, "legsbyexpo":legsbyexpo })
|
#totalsurvexlength = sum([survexleg.tape for survexleg in survexlegs])
|
||||||
|
return render(request, 'experimental.html', { "nsurvexlegs":nimportlegs, "totalsurvexlength":totalsurvexlength, "addupsurvexlength":addupsurvexlength, "legsbyexpo":legsbyexpo })
|
||||||
|
|
||||||
@login_required_if_public
|
@login_required_if_public
|
||||||
def newLogbookEntry(request, expeditionyear, pdate = None, pslug = None):
|
def newLogbookEntry(request, expeditionyear, pdate = None, pslug = None):
|
||||||
|
33
parsers/survex.py
Normal file → Executable file
33
parsers/survex.py
Normal file → Executable file
@ -18,8 +18,12 @@ A 'survexscansfolder' is what we today call a "survey scans folder" or a "wallet
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
line_leg_regex = re.compile(r"[\d\-+.]+$")
|
line_leg_regex = re.compile(r"[\d\-+.]+$")
|
||||||
|
survexlegsalllength = 0.0
|
||||||
|
survexlegsnumber = 0
|
||||||
|
|
||||||
def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
|
def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
|
||||||
|
global survexlegsalllength
|
||||||
|
global survexlegsnumber
|
||||||
# The try catches here need replacing as they are relatively expensive
|
# The try catches here need replacing as they are relatively expensive
|
||||||
ls = sline.lower().split()
|
ls = sline.lower().split()
|
||||||
ssfrom = survexblock.MakeSurvexStation(ls[stardata["from"]])
|
ssfrom = survexblock.MakeSurvexStation(ls[stardata["from"]])
|
||||||
@ -31,13 +35,14 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
|
|||||||
if stardata["type"] == "normal":
|
if stardata["type"] == "normal":
|
||||||
try:
|
try:
|
||||||
survexleg.tape = float(ls[stardata["tape"]])
|
survexleg.tape = float(ls[stardata["tape"]])
|
||||||
|
survexlegsnumber += 1
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("! Tape misread in", survexblock.survexfile.path)
|
print("! Tape misread in", survexblock.survexfile.path)
|
||||||
print(" Stardata:", stardata)
|
print(" Stardata:", stardata)
|
||||||
print(" Line:", ls)
|
print(" Line:", ls)
|
||||||
message = ' ! Value Error: Tape misread in line %s in %s' % (ls, survexblock.survexfile.path)
|
message = ' ! Value Error: Tape misread in line %s in %s' % (ls, survexblock.survexfile.path)
|
||||||
models.DataIssue.objects.create(parser='survex', message=message)
|
models.DataIssue.objects.create(parser='survex', message=message)
|
||||||
survexleg.tape = 1000
|
survexleg.tape = 0
|
||||||
try:
|
try:
|
||||||
lclino = ls[stardata["clino"]]
|
lclino = ls[stardata["clino"]]
|
||||||
except:
|
except:
|
||||||
@ -83,15 +88,20 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
|
|||||||
survexleg.cave = cave
|
survexleg.cave = cave
|
||||||
|
|
||||||
# only save proper legs
|
# only save proper legs
|
||||||
survexleg.save()
|
# No need to save as we are measuring lengths only on parsing now.
|
||||||
|
# delete the object so that django autosaving doesn't save it.
|
||||||
|
survexleg = None
|
||||||
|
#survexleg.save()
|
||||||
|
|
||||||
itape = stardata.get("tape")
|
itape = stardata.get("tape")
|
||||||
if itape:
|
if itape:
|
||||||
try:
|
try:
|
||||||
survexblock.totalleglength += float(ls[itape])
|
survexblock.totalleglength += float(ls[itape])
|
||||||
|
survexlegsalllength += float(ls[itape])
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print("! Length not added")
|
print("! Length not added")
|
||||||
survexblock.save()
|
# No need to save as we are measuring lengths only on parsing now.
|
||||||
|
#survexblock.save()
|
||||||
|
|
||||||
|
|
||||||
def LoadSurvexEquate(survexblock, sline):
|
def LoadSurvexEquate(survexblock, sline):
|
||||||
@ -141,6 +151,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines):
|
|||||||
teammembers = [ ]
|
teammembers = [ ]
|
||||||
global insp
|
global insp
|
||||||
global callcount
|
global callcount
|
||||||
|
global survexlegsnumber
|
||||||
|
|
||||||
# uncomment to print out all files during parsing
|
# uncomment to print out all files during parsing
|
||||||
print(insp+" - Reading file: " + survexblock.survexfile.path + " <> " + survexfile.path)
|
print(insp+" - Reading file: " + survexblock.survexfile.path + " <> " + survexfile.path)
|
||||||
@ -334,6 +345,7 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines):
|
|||||||
else:
|
else:
|
||||||
print(insp+' - No match (b) for %s' % newsvxpath)
|
print(insp+' - No match (b) for %s' % newsvxpath)
|
||||||
|
|
||||||
|
previousnlegs = survexlegsnumber
|
||||||
name = line.lower()
|
name = line.lower()
|
||||||
print(insp+' - Begin found for: ' + name)
|
print(insp+' - Begin found for: ' + name)
|
||||||
# print(insp+'Block cave: ' + str(survexfile.cave))
|
# print(insp+'Block cave: ' + str(survexfile.cave))
|
||||||
@ -353,7 +365,11 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines):
|
|||||||
if iblankbegins:
|
if iblankbegins:
|
||||||
iblankbegins -= 1
|
iblankbegins -= 1
|
||||||
else:
|
else:
|
||||||
survexblock.text = "".join(textlines)
|
#survexblock.text = "".join(textlines)
|
||||||
|
# .text not used, using it for number of legs per block
|
||||||
|
legsinblock = survexlegsnumber - previousnlegs
|
||||||
|
print("LEGS: {} (previous: {}, now:{})".format(legsinblock,previousnlegs,survexlegsnumber))
|
||||||
|
survexblock.text = str(legsinblock)
|
||||||
survexblock.save()
|
survexblock.save()
|
||||||
# print(insp+' - End found: ')
|
# print(insp+' - End found: ')
|
||||||
endstamp = datetime.now()
|
endstamp = datetime.now()
|
||||||
@ -434,6 +450,8 @@ def RecursiveLoad(survexblock, survexfile, fin, textlines):
|
|||||||
# print(insp+' - Time to process: ' + str(timetaken))
|
# print(insp+' - Time to process: ' + str(timetaken))
|
||||||
|
|
||||||
def LoadAllSurvexBlocks():
|
def LoadAllSurvexBlocks():
|
||||||
|
global survexlegsalllength
|
||||||
|
global survexlegsnumber
|
||||||
|
|
||||||
print(' - Flushing All Survex Blocks...')
|
print(' - Flushing All Survex Blocks...')
|
||||||
|
|
||||||
@ -461,6 +479,7 @@ def LoadAllSurvexBlocks():
|
|||||||
survexfile.SetDirectory()
|
survexfile.SetDirectory()
|
||||||
|
|
||||||
#Load all
|
#Load all
|
||||||
|
# this is the first so id=1
|
||||||
survexblockroot = models.SurvexBlock(name="root", survexpath="", begin_char=0, cave=None, survexfile=survexfile, totalleglength=0.0)
|
survexblockroot = models.SurvexBlock(name="root", survexpath="", begin_char=0, cave=None, survexfile=survexfile, totalleglength=0.0)
|
||||||
survexblockroot.save()
|
survexblockroot.save()
|
||||||
fin = survexfile.OpenFile()
|
fin = survexfile.OpenFile()
|
||||||
@ -468,7 +487,9 @@ def LoadAllSurvexBlocks():
|
|||||||
# The real work starts here
|
# The real work starts here
|
||||||
RecursiveLoad(survexblockroot, survexfile, fin, textlines)
|
RecursiveLoad(survexblockroot, survexfile, fin, textlines)
|
||||||
fin.close()
|
fin.close()
|
||||||
survexblockroot.text = "".join(textlines)
|
survexblockroot.totalleglength = survexlegsalllength
|
||||||
|
survexblockroot.text = str(survexlegsnumber)
|
||||||
|
#survexblockroot.text = "".join(textlines) these are all blank
|
||||||
survexblockroot.save()
|
survexblockroot.save()
|
||||||
|
|
||||||
# Close the file
|
# Close the file
|
||||||
@ -478,6 +499,8 @@ def LoadAllSurvexBlocks():
|
|||||||
|
|
||||||
# Restore sys.stdout to our old saved file handler
|
# Restore sys.stdout to our old saved file handler
|
||||||
sys.stdout = stdout_orig
|
sys.stdout = stdout_orig
|
||||||
|
print(" - total number of survex legs: {}m".format(survexlegsnumber))
|
||||||
|
print(" - total leg lengths loaded: {}m".format(survexlegsalllength))
|
||||||
print(' - Loaded All Survex Blocks.')
|
print(' - Loaded All Survex Blocks.')
|
||||||
|
|
||||||
|
|
||||||
|
4
templates/experimental.html
Normal file → Executable file
4
templates/experimental.html
Normal file → Executable file
@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
<h1>Expo Experimental</h1>
|
<h1>Expo Experimental</h1>
|
||||||
|
|
||||||
<p>Number of survey legs: {{nsurvexlegs}}, total length: {{totalsurvexlength}}</p>
|
<p>Number of survey legs: {{nsurvexlegs}}<br />
|
||||||
|
Total length: {{totalsurvexlength}} m on importing survex files.<br />
|
||||||
|
Total length: {{addupsurvexlength}} m adding up all the years below.</p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr><th>Year</th><th>Surveys</th><th>Survey Legs</th><th>Total length</th></tr>
|
<tr><th>Year</th><th>Surveys</th><th>Survey Legs</th><th>Total length</th></tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user