2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 14:51:51 +00:00

bin Makesurvexstation, survextitle, survexEquate

This commit is contained in:
Philip Sargent 2020-06-24 01:57:20 +01:00
parent d6c4ffca5a
commit 6bf762b72f
5 changed files with 52 additions and 51 deletions

View File

@ -52,8 +52,8 @@ class SurvexFile(models.Model):
self.save()
class SurvexEquate(models.Model):
cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.CASCADE)
#class SurvexEquate(models.Model):
# cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.CASCADE)
class SurvexStationLookUpManager(models.Manager):
def lookup(self, name):
@ -64,7 +64,7 @@ class SurvexStationLookUpManager(models.Manager):
class SurvexStation(models.Model):
name = models.CharField(max_length=100)
block = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE)
equate = models.ForeignKey('SurvexEquate', blank=True, null=True,on_delete=models.CASCADE)
# equate = models.ForeignKey('SurvexEquate', blank=True, null=True,on_delete=models.CASCADE)
objects = SurvexStationLookUpManager()
x = models.FloatField(blank=True, null=True)
y = models.FloatField(blank=True, null=True)
@ -140,22 +140,21 @@ class SurvexBlock(models.Model):
res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year, 'roles':str(personrole.role)})
return res
def MakeSurvexStation(self, name):
ssl = self.survexstation_set.filter(name=name)
if ssl:
assert len(ssl) == 1
return ssl[0]
#print name
ss = SurvexStation(name=name, block=self)
#ss.save()
return ss
# def MakeSurvexStation(self, name):
# ssl = self.survexstation_set.filter(name=name)
# if ssl:
# assert len(ssl) == 1
# return ssl[0]
# ss = SurvexStation(name=name, block=self)
# #ss.save()
# return ss
def DayIndex(self):
return list(self.expeditionday.survexblock_set.all()).index(self)
class SurvexTitle(models.Model):
survexblock = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE)
title = models.CharField(max_length=200)
title = models.CharField(max_length=200) # needed by svxcavesingle.html template
cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.CASCADE)
#
@ -217,14 +216,14 @@ class TunnelFile(models.Model):
tunnelpath = models.CharField(max_length=200)
tunnelname = models.CharField(max_length=200)
bfontcolours = models.BooleanField(default=False)
manyscansfolders = models.ManyToManyField("ScansFolder")
scans = models.ManyToManyField("SingleScan")
survexblocks = models.ManyToManyField("SurvexBlock")
manyscansfolders = models.ManyToManyField("ScansFolder") # implicitly links to SVX files
scans = models.ManyToManyField("SingleScan") # implicitly links to SVX files
# survexblocks = models.ManyToManyField("SurvexBlock")
tunnelcontains = models.ManyToManyField("TunnelFile") # case when its a frame type
filesize = models.IntegerField(default=0)
npaths = models.IntegerField(default=0)
survextitles = models.ManyToManyField("SurvexTitle")
# survextitles = models.ManyToManyField("SurvexTitle")
survexfiles = models.ManyToManyField("SurvexFile") # direct link to SVX files
class Meta:
ordering = ('tunnelpath',)

View File

@ -14,12 +14,11 @@ from django.http import HttpResponse, Http404
import troggle.settings as settings
import parsers.survex
from troggle.core.models import Expedition, Person, PersonExpedition
from troggle.core.models_survex import SurvexBlock, SurvexPersonRole, SurvexFile, SurvexDirectory, SurvexTitle
from troggle.core.models_survex import SurvexBlock, SurvexPersonRole, SurvexFile, SurvexDirectory #, SurvexTitle
from troggle.core.models_caves import Cave, PersonTrip, LogbookEntry
from troggle.parsers.people import GetPersonExpeditionNameLookup
survextemplatefile = """; *** DO NOT SAVE THIS FILE WITHOUT RENAMING IT !! ***
;[Stuff in square brackets is example text to be replaced with real data,
; removing the square brackets]
@ -184,7 +183,6 @@ def svx(request, survex_file):
if "diff" in rform.data:
form.data['code'] = rcode
#process(survex_file)
if 'code' not in form.data:
form.data['code'] = form.GetDiscCode()
@ -231,19 +229,19 @@ def threed(request, survex_file):
log = open(settings.SURVEX_DATA + survex_file + ".log", "rt",encoding='utf8')
return HttpResponse(log, content_type="text")
def log(request, survex_file):
process(survex_file)
log = open(settings.SURVEX_DATA + survex_file + ".log", "rt",encoding='utf8')
return HttpResponse(log, content_type="text")
def err(request, survex_file):
process(survex_file)
err = open(settings.SURVEX_DATA + survex_file + ".err", "rt",encoding='utf8')
return HttpResponse(err, content_type="text")
def identifycavedircontents(gcavedir):
# find the primary survex file in each cave directory
name = os.path.split(gcavedir)[1]
@ -339,6 +337,8 @@ def survexcaveslist(request):
# parsing all the survex files of a single cave and showing that it's consistent and can find all the files and people
# doesn't use recursion. just writes it twice
# currently produces title and blank page.. link test is "dates and explorers"
def survexcavesingle(request, survex_cave):
breload = False
cave = Cave.objects.get(kataster_number=survex_cave)

View File

@ -5,6 +5,13 @@ import urllib.parse
# link 'localsettings.py' to localsettingsWSL.py for use on a Windows 10 machine running WSL1
print(" * importing troggle/localsettings.py")
#-----------------------------------------------------------------
# THINK before you push this to a repo
# - have you checked that this file is in .gitignore ?
# - have you run pre-push.sh to copy files and remove passwords?
# - we don't want to have to change the expo system password !
#-----------------------------------------------------------------
SERVERPORT = '3777'
LIBDIR = '/mnt/d/CUCC-Expo/t37/lib/python3.7/'

View File

@ -111,12 +111,12 @@ def LoadSurvexLineLeg(survexblock, stardata, sline, comment, cave):
# No need to save as we are measuring lengths only on parsing now.
def LoadSurvexEquate(survexblock, sline):
#print sline #
stations = sline.split()
assert len(stations) > 1
for station in stations:
survexblock.MakeSurvexStation(station)
# def LoadSurvexEquate(survexblock, sline):
# #print sline #
# stations = sline.split()
# assert len(stations) > 1
# for station in stations:
# survexblock.MakeSurvexStation(station)
def LoadSurvexLinePassage(survexblock, stardata, sline, comment):
@ -317,7 +317,7 @@ def RecursiveLoad(survexblock, survexfile, fin):
elif re.match("begin$(?i)", cmd):
# On a *begin statement we start a new survexblock.
# There should not be any *include inside a begin-end block, so this is a simple
# load not a recursive load. But there may be many blocks in one file.
# load not a recursive fileload. But there may be many blocks nested to any depth in one file.
if line:
newsvxpath = os.path.join(os.path.split(survexfile.path)[0], re.sub(r"\.svx$", "", line))
# Try to find the cave in the DB if not use the string as before
@ -334,8 +334,10 @@ def RecursiveLoad(survexblock, survexfile, fin):
previousnlegs = survexlegsnumber
name = line.lower()
print(insp+' - Begin found for:{}, creating new SurvexBlock '.format(name))
survexblockdown = models_survex.SurvexBlock(name=name, parent=survexblock, survexpath=survexblock.survexpath+"."+name,
cave=survexfile.cave, survexfile=survexfile, legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0)
survexblockdown = models_survex.SurvexBlock(name=name, parent=survexblock,
survexpath=survexblock.survexpath+"."+name,
cave=survexfile.cave, survexfile=survexfile,
legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0)
survexblockdown.save()
survexblock.save()
survexblock = survexblockdown
@ -386,8 +388,9 @@ def RecursiveLoad(survexblock, survexfile, fin):
personrole.save()
elif cmd == "title":
survextitle = models_survex.SurvexTitle(survexblock=survexblock, title=line.strip('"'), cave=survexfile.cave)
survextitle.save()
# unused in troggle.
#survextitle = models_survex.SurvexTitle(survexblock=survexblock, title=line.strip('"'), cave=survexfile.cave)
#survextitle.save()
pass
elif cmd == "require":
@ -407,7 +410,8 @@ def RecursiveLoad(survexblock, survexfile, fin):
assert ls[0] == "passage", line
elif cmd == "equate":
LoadSurvexEquate(survexblock, line)
#LoadSurvexEquate(survexblock, line)
pass
elif cmd == "set" and re.match("names(?i)", line):
pass
@ -416,7 +420,9 @@ def RecursiveLoad(survexblock, survexfile, fin):
# but this data is only used for sense-checking not to actually calculate anything important
pass
elif cmd == "fix":
survexblock.MakeSurvexStation(line.split()[0])
# troggle does not use survex stations
#survexblock.MakeSurvexStation(line.split()[0])
pass
elif cmd in ["alias", "calibrate", "cs","entrance", "export", "case",
"declination", "infer","instrument", "sd", "units"]:
# we ignore all these, which is fine.
@ -469,8 +475,8 @@ def LoadAllSurvexBlocks():
models_survex.SurvexBlock.objects.all().delete()
models_survex.SurvexFile.objects.all().delete()
models_survex.SurvexDirectory.objects.all().delete()
models_survex.SurvexEquate.objects.all().delete()
models_survex.SurvexTitle.objects.all().delete()
# models_survex.SurvexEquate.objects.all().delete()
# models_survex.SurvexTitle.objects.all().delete()
models_survex.SurvexPersonRole.objects.all().delete()
models_survex.SurvexStation.objects.all().delete()
@ -516,7 +522,6 @@ def LoadPos():
# cavern defaults to using same cwd as supplied input file
call([settings.CAVERN, "--output=%s.3d" % (topdata), "%s.svx" % (topdata)])
call([settings.THREEDTOPOS, '%s.3d' % (topdata)], cwd = settings.SURVEX_DATA)
#print(" - This next bit takes a while. Matching ~32,000 survey positions. Be patient...")
mappoints = {}
for pt in MapLocations().points():
@ -525,7 +530,6 @@ def LoadPos():
posfile = open("%s.pos" % (topdata))
posfile.readline() #Drop header
try:
survexblockroot = models_survex.SurvexBlock.objects.get(name=ROOTBLOCK)
except:
@ -540,17 +544,8 @@ def LoadPos():
r = poslineregex.match(line)
if r:
x, y, z, id = r.groups()
# if id in notfoundbefore:
# skip[id] = 1
# else:
for sid in mappoints:
if id.endswith(sid):
# notfoundnow.append(id)
# Now that we don't import any stations, we create it rather than look it up
# ss = models_survex.SurvexStation.objects.lookup(id)
# need to set block_id which means doing a search on all the survex blocks..
# remove dot at end and add one at beginning
blockpath = "." + id[:-len(sid)].strip(".")
try:
sbqs = models_survex.SurvexBlock.objects.filter(survexpath=blockpath)
@ -582,6 +577,5 @@ def LoadPos():
print(message)
models.DataIssue.objects.create(parser='survex', message=message)
raise
print(" - {} SurvexStation entrances found.".format(found))

View File

@ -27,6 +27,7 @@ sed -i '/SECRET_KEY/ s/^.*$/SECRET_KEY = "not-the-real-secret-key-a#vaeozn0---^f
echo " " reset: SECRET_KEY = \"not-the-real-secret-key-a#vaeozn0---^fj!355qki*vj2\"
#
# Do these before final testing, *not* just before pushing:
# in ./pre-run.sh
# python reset-django.py
# python manage.py makemigrations
# python manage.py test