forked from expo/troggle
splays and alias splays implemented
This commit is contained in:
parent
51d0daafdd
commit
5be41c8163
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-06-26 23:53
|
||||
# Generated by Django 1.11.29 on 2020-07-04 12:11
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.conf import settings
|
||||
@ -25,7 +25,7 @@ class Migration(migrations.Migration):
|
||||
('short_name', models.CharField(max_length=100)),
|
||||
('name', models.CharField(blank=True, max_length=200, null=True)),
|
||||
('description', models.TextField(blank=True, null=True)),
|
||||
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Area')),
|
||||
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.Area')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
@ -191,8 +191,8 @@ class Migration(migrations.Migration):
|
||||
('slug', models.SlugField()),
|
||||
('filename', models.CharField(max_length=200, null=True)),
|
||||
('entry_type', models.CharField(choices=[('wiki', 'Wiki style logbook'), ('html', 'Html style logbook')], default='wiki', max_length=50, null=True)),
|
||||
('expedition', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Expedition')),
|
||||
('expeditionday', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ExpeditionDay')),
|
||||
('expedition', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.Expedition')),
|
||||
('expeditionday', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.ExpeditionDay')),
|
||||
],
|
||||
options={
|
||||
'verbose_name_plural': 'Logbook Entries',
|
||||
@ -290,7 +290,7 @@ class Migration(migrations.Migration):
|
||||
('area', models.CharField(blank=True, max_length=100, null=True)),
|
||||
('completion_description', models.TextField(blank=True, null=True)),
|
||||
('comment', models.TextField(blank=True, null=True)),
|
||||
('found_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='QMs_found', to='core.LogbookEntry')),
|
||||
('found_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='QMs_found', to='core.LogbookEntry')),
|
||||
],
|
||||
options={
|
||||
'abstract': False,
|
||||
@ -313,7 +313,7 @@ class Migration(migrations.Migration):
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('ffile', models.CharField(max_length=200)),
|
||||
('name', models.CharField(max_length=200)),
|
||||
('scansfolder', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ScansFolder')),
|
||||
('scansfolder', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.ScansFolder')),
|
||||
],
|
||||
options={
|
||||
'ordering': ('name',),
|
||||
@ -324,17 +324,16 @@ class Migration(migrations.Migration):
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=100)),
|
||||
('title', models.CharField(max_length=100)),
|
||||
('date', models.DateField(blank=True, null=True)),
|
||||
('survexpath', models.CharField(max_length=200)),
|
||||
('legsall', models.IntegerField(null=True)),
|
||||
('legssplay', models.IntegerField(null=True)),
|
||||
('legssurfc', models.IntegerField(null=True)),
|
||||
('totalleglength', models.FloatField(null=True)),
|
||||
('cave', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Cave')),
|
||||
('expedition', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Expedition')),
|
||||
('expeditionday', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ExpeditionDay')),
|
||||
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.SurvexBlock')),
|
||||
('scansfolder', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ScansFolder')),
|
||||
('legslength', models.FloatField(null=True)),
|
||||
('cave', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.Cave')),
|
||||
('expedition', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.Expedition')),
|
||||
('expeditionday', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.ExpeditionDay')),
|
||||
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.SurvexBlock')),
|
||||
('scansfolder', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.ScansFolder')),
|
||||
],
|
||||
options={
|
||||
'ordering': ('id',),
|
||||
@ -345,7 +344,7 @@ class Migration(migrations.Migration):
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('path', models.CharField(max_length=200)),
|
||||
('cave', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Cave')),
|
||||
('cave', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.Cave')),
|
||||
],
|
||||
options={
|
||||
'ordering': ('id',),
|
||||
@ -356,8 +355,8 @@ class Migration(migrations.Migration):
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('path', models.CharField(max_length=200)),
|
||||
('cave', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Cave')),
|
||||
('survexdirectory', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.SurvexDirectory')),
|
||||
('cave', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.Cave')),
|
||||
('survexdirectory', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.SurvexDirectory')),
|
||||
],
|
||||
options={
|
||||
'ordering': ('id',),
|
||||
@ -369,10 +368,10 @@ class Migration(migrations.Migration):
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('nrole', models.CharField(blank=True, choices=[('insts', 'Instruments'), ('dog', 'Other'), ('notes', 'Notes'), ('pics', 'Pictures'), ('tape', 'Tape measure'), ('useless', 'Useless'), ('helper', 'Helper'), ('disto', 'Disto'), ('consultant', 'Consultant')], max_length=200, null=True)),
|
||||
('personname', models.CharField(max_length=100)),
|
||||
('expeditionday', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ExpeditionDay')),
|
||||
('person', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Person')),
|
||||
('personexpedition', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.PersonExpedition')),
|
||||
('persontrip', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.PersonTrip')),
|
||||
('expeditionday', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.ExpeditionDay')),
|
||||
('person', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.Person')),
|
||||
('personexpedition', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.PersonExpedition')),
|
||||
('persontrip', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.PersonTrip')),
|
||||
('survexblock', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.SurvexBlock')),
|
||||
],
|
||||
),
|
||||
@ -384,7 +383,7 @@ class Migration(migrations.Migration):
|
||||
('x', models.FloatField(blank=True, null=True)),
|
||||
('y', models.FloatField(blank=True, null=True)),
|
||||
('z', models.FloatField(blank=True, null=True)),
|
||||
('block', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.SurvexBlock')),
|
||||
('block', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.SurvexBlock')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
@ -392,8 +391,8 @@ class Migration(migrations.Migration):
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=200)),
|
||||
('cave', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.Cave')),
|
||||
('survexblock', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.SurvexBlock')),
|
||||
('cave', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.Cave')),
|
||||
('survexblock', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.SurvexBlock')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
@ -417,22 +416,22 @@ class Migration(migrations.Migration):
|
||||
migrations.AddField(
|
||||
model_name='survexdirectory',
|
||||
name='primarysurvexfile',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='primarysurvexfile', to='core.SurvexFile'),
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='primarysurvexfile', to='core.SurvexFile'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='survexblock',
|
||||
name='survexfile',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.SurvexFile'),
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.SurvexFile'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='qm',
|
||||
name='nearest_station',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.SurvexStation'),
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.SurvexStation'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='qm',
|
||||
name='ticked_off_by',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='QMs_ticked_off', to='core.LogbookEntry'),
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='QMs_ticked_off', to='core.LogbookEntry'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='cavedescription',
|
||||
|
@ -219,7 +219,7 @@ class PersonExpedition(TroggleModel):
|
||||
|
||||
def surveyedleglength(self):
|
||||
survexblocks = [personrole.survexblock for personrole in self.personrole_set.all() ]
|
||||
return sum([survexblock.totalleglength for survexblock in set(survexblocks)])
|
||||
return sum([survexblock.legslength for survexblock in set(survexblocks)])
|
||||
|
||||
# would prefer to return actual person trips so we could link to first and last ones
|
||||
def day_min(self):
|
||||
|
@ -113,9 +113,7 @@ class SurvexBlock(models.Model):
|
||||
scansfolder = models.ForeignKey("ScansFolder", null=True,on_delete=models.SET_NULL)
|
||||
|
||||
legsall = models.IntegerField(null=True) # summary data for this block
|
||||
legssplay = models.IntegerField(null=True) # summary data for this block
|
||||
legssurfc = models.IntegerField(null=True) # summary data for this block
|
||||
totalleglength = models.FloatField(null=True)
|
||||
legslength = models.FloatField(null=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ('id',)
|
||||
|
@ -166,38 +166,6 @@ def personForm(request,pk):
|
||||
form=PersonForm(instance=person)
|
||||
return render(request,'personform.html', {'form':form,})
|
||||
|
||||
def experimental(request):
|
||||
blockroots = models.SurvexBlock.objects.filter(name="rootblock")
|
||||
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 = [ ]
|
||||
addupsurvexlength = 0
|
||||
for expedition in Expedition.objects.all():
|
||||
survexblocks = expedition.survexblock_set.all()
|
||||
legsyear=0
|
||||
survexleglength = 0.0
|
||||
for survexblock in survexblocks:
|
||||
survexleglength += survexblock.totalleglength
|
||||
try:
|
||||
legsyear += int(survexblock.text)
|
||||
except:
|
||||
pass
|
||||
addupsurvexlength += survexleglength
|
||||
legsbyexpo.append((expedition, {"nsurvexlegs":legsyear, "survexleglength":survexleglength}))
|
||||
legsbyexpo.reverse()
|
||||
|
||||
return render(request, 'experimental.html', { "nsurvexlegs":nimportlegs, "totalsurvexlength":totalsurvexlength, "addupsurvexlength":addupsurvexlength, "legsbyexpo":legsbyexpo })
|
||||
|
||||
@login_required_if_public
|
||||
def newLogbookEntry(request, expeditionyear, pdate = None, pslug = None):
|
||||
expedition = Expedition.objects.get(year=expeditionyear)
|
||||
|
@ -71,24 +71,6 @@ def stats(request):
|
||||
statsDict['caveCount'] = "{:,}".format(Cave.objects.count())
|
||||
statsDict['personCount'] = "{:,}".format(Person.objects.count())
|
||||
statsDict['logbookEntryCount'] = "{:,}".format(LogbookEntry.objects.count())
|
||||
try:
|
||||
blockroots = SurvexBlock.objects.filter(name="rootblock")
|
||||
if len(blockroots)>1:
|
||||
print(" ! more than one root survexblock {}".format(len(blockroots)))
|
||||
for sbr in blockroots:
|
||||
print("{} {} {} {}".format(sbr.id, sbr.name, sbr.legsall, sbr.date))
|
||||
sbr = blockroots[0]
|
||||
totalsurvexlength = sbr.totalleglength
|
||||
nimportlegs = sbr.legsall
|
||||
except:
|
||||
# if no files yet imported into database
|
||||
#survexfile = models_survex.SurvexFile(path=settings.SURVEX_TOPNAME, cave=None)
|
||||
#survexblockdummy = models_survex.SurvexBlock(name="dummy", survexpath="", cave=None, survexfile=survexfile,
|
||||
#legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0)
|
||||
#sbr = survexblockdummy
|
||||
totalsurvexlength = 0.0
|
||||
nimportlegs = -1
|
||||
print("{} {} {} {}".format(sbr.id, sbr.name, sbr.legsall, sbr.date))
|
||||
|
||||
legsbyexpo = [ ]
|
||||
addupsurvexlength = 0
|
||||
@ -97,7 +79,7 @@ def stats(request):
|
||||
legsyear=0
|
||||
survexleglength = 0.0
|
||||
for survexblock in survexblocks:
|
||||
survexleglength += survexblock.totalleglength
|
||||
survexleglength += survexblock.legslength
|
||||
try:
|
||||
legsyear += int(survexblock.legsall)
|
||||
except:
|
||||
@ -107,5 +89,5 @@ def stats(request):
|
||||
"survexleglength":"{:,.0f}".format(survexleglength)}))
|
||||
legsbyexpo.reverse()
|
||||
|
||||
renderDict = {**statsDict, **{ "nsurvexlegs": "{:,}".format(nimportlegs), "totalsurvexlength":totalsurvexlength/1000, "addupsurvexlength":addupsurvexlength/1000, "legsbyexpo":legsbyexpo }} # new syntax
|
||||
renderDict = {**statsDict, **{ "addupsurvexlength":addupsurvexlength/1000, "legsbyexpo":legsbyexpo }} # new syntax
|
||||
return render(request,'statistics.html', renderDict)
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-06-26 23:53
|
||||
# Generated by Django 1.11.29 on 2020-07-04 12:11
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
@ -16,40 +16,40 @@
|
||||
39 ./localsettings-expo-live.py
|
||||
39 ./localsettingsdocker.py
|
||||
39 ./localsettingsserver.py
|
||||
40 ./parsers/imports.py
|
||||
41 ./localsettingspotatohut.py
|
||||
41 ./middleware.py
|
||||
44 ./dump.py
|
||||
44 ./parsers/imports.py
|
||||
48 ./core/templatetags/survex_markup.py
|
||||
49 ./parsers/subcaves.py
|
||||
52 ./reset-django.py
|
||||
63 ./logbooksdump.py
|
||||
68 ./urls.py
|
||||
69 ./core/TESTS/tests.py
|
||||
71 ./core/TESTS/tests.py
|
||||
73 ./localsettings.py
|
||||
73 ./localsettingsWSL.py
|
||||
73 ./settings.py
|
||||
91 ./core/views_statistics.py
|
||||
78 ./core/views_statistics.py
|
||||
97 ./core/forms.py
|
||||
97 ./core/view_surveys.py
|
||||
98 ./core/admin.py
|
||||
99 ./parsers/QMs.py
|
||||
102 ./parsers/people.py
|
||||
105 ./parsers/QMs.py
|
||||
124 ./core/templatetags/wiki_markup.py
|
||||
135 ./utils.py
|
||||
141 ./core/models_survex.py
|
||||
146 ./parsers/surveys.py
|
||||
142 ./core/models_survex.py
|
||||
144 ./utils.py
|
||||
148 ./parsers/surveys.py
|
||||
164 ./flatpages/views.py
|
||||
164 ./modelviz.py
|
||||
171 ./core/models.py
|
||||
175 ./core/views_other.py
|
||||
198 ./parsers/caves.py
|
||||
216 ./core/views_logbooks.py
|
||||
255 ./core/views_survex.py
|
||||
187 ./core/views_logbooks.py
|
||||
226 ./parsers/caves.py
|
||||
263 ./core/views_survex.py
|
||||
276 ./profiles/views.py
|
||||
280 ./databaseReset.py
|
||||
387 ./core/views_caves.py
|
||||
449 ./core/models_caves.py
|
||||
515 ./parsers/logbooks.py
|
||||
556 ./parsers/survex.py
|
||||
6049
|
||||
290 ./databaseReset.py
|
||||
401 ./core/views_caves.py
|
||||
492 ./parsers/logbooks.py
|
||||
593 ./core/models_caves.py
|
||||
908 ./parsers/survex.py
|
||||
6564
|
||||
|
@ -30,14 +30,14 @@
|
||||
20 ./templates/cavebase.html
|
||||
20 ./templates/plainbase.html
|
||||
21 ./templates/logbook2005style.html
|
||||
22 ./templates/tasks.html
|
||||
23 ./templates/statistics.html
|
||||
24 ./README/index.html
|
||||
24 ./templates/dataformat/logbookentry.html
|
||||
25 ./templates/manyscansfolders.html
|
||||
25 ./templates/profiles/select_profile.html
|
||||
27 ./templates/scansfolder.html
|
||||
27 ./templates/statistics.html
|
||||
31 ./templates/caveindex.html
|
||||
31 ./templates/tasks.html
|
||||
33 ./templates/tunnelfiles.html
|
||||
35 ./templates/person.html
|
||||
35 ./templates/qm.html
|
||||
@ -61,6 +61,6 @@
|
||||
75 ./templates/newlogbookentry.html
|
||||
85 ./templates/editfile.html
|
||||
102 ./templates/prospecting.html
|
||||
115 ./templates/controlPanel.html
|
||||
117 ./templates/controlPanel.html
|
||||
439 ./templates/cave.html
|
||||
2435
|
||||
2450
|
||||
|
@ -57,7 +57,7 @@ class LoadingSurvex():
|
||||
# This interprets the survex "*data normal" command which sets out the order of the fields in the data, e.g.
|
||||
# *DATA normal from to length gradient bearing ignore ignore ignore ignore
|
||||
datastardefault = {"type":"normal", "from":0, "to":1, "tape":2, "compass":3, "clino":4}
|
||||
flagsdefault = {"duplicate":False, "surface":False, "splay":False, "skiplegs":False}
|
||||
flagsdefault = {"duplicate":False, "surface":False, "splay":False, "skiplegs":False, "splayalias":False}
|
||||
|
||||
datastar ={}
|
||||
flagsstar = {}
|
||||
@ -74,6 +74,7 @@ class LoadingSurvex():
|
||||
stacksvxfiles = []
|
||||
svxfileslist = []
|
||||
svxdirs = {}
|
||||
expos = {}
|
||||
survexdict = {} # each key is a directory, and its value is a list of files
|
||||
lineno = 0
|
||||
insp = ""
|
||||
@ -93,11 +94,11 @@ class LoadingSurvex():
|
||||
def LoadSurvexIgnore(self, survexblock, line, cmd):
|
||||
if cmd == "require":
|
||||
pass # should we check survex version available for processing?
|
||||
elif cmd in ["equate", "fix", "alias", "calibrate", "cs","entrance", "export", "case",
|
||||
elif cmd in ["equate", "fix", "calibrate", "cs", "export", "case",
|
||||
"declination", "infer","instrument", "sd", "units"]:
|
||||
pass # we ignore all these, which is fine.
|
||||
else:
|
||||
if cmd in ["include", "data", "flags", "title", "set", "ref"]:
|
||||
if cmd in ["include", "data", "flags", "title", "entrance","set", "units", "alias", "ref"]:
|
||||
message = "! Unparsed [*{}]: '{}' {}".format(cmd, line, survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
models.DataIssue.objects.create(parser='survex', message=message)
|
||||
@ -122,18 +123,40 @@ class LoadingSurvex():
|
||||
personrole.person=personexpedition.person
|
||||
personrole.save()
|
||||
|
||||
def LoadSurvexEntrance(self, survexblock, line):
|
||||
# Not using this yet
|
||||
pass
|
||||
|
||||
def LoadSurvexAlias(self, survexblock, line):
|
||||
# *alias station - ..
|
||||
splayalias = re.match("(?i)station\s*\-\s*\.\.\s*$",line)
|
||||
if splayalias:
|
||||
self.flagsstar["splayalias"] = True
|
||||
else:
|
||||
message = "! Bad *ALIAS: '{}' ({}) {}".format(line, survexblock, survexblock.survexfile.path)
|
||||
print((self.insp+message))
|
||||
models.DataIssue.objects.create(parser='survex', message=message)
|
||||
|
||||
def LoadSurvexDate(self, survexblock, line):
|
||||
# we should make this a date range for everything
|
||||
if len(line) == 10:
|
||||
year = line[:4]
|
||||
# make_aware is a django function, and may not be correct to use it like this anyway! We want Austrian time.
|
||||
survexblock.date = make_aware(datetime.strptime(re.sub(r"\.", "-", line), '%Y-%m-%d'), get_current_timezone())
|
||||
expeditions = models.Expedition.objects.filter(year=line[:4])
|
||||
if expeditions:
|
||||
# cacheing to save DB query on every block and to prepare for django-less troggle in future
|
||||
if year in self.expos:
|
||||
expo = self.expos[year]
|
||||
else:
|
||||
expeditions = models.Expedition.objects.filter(year=year)
|
||||
assert len(expeditions) == 1
|
||||
survexblock.expedition = expeditions[0]
|
||||
survexblock.expeditionday = survexblock.expedition.get_expedition_day(survexblock.date)
|
||||
survexblock.save()
|
||||
expo= expeditions[0]
|
||||
self.expos[year]= expo
|
||||
|
||||
def LoadSurvexLineLeg(self, survexblock, sline, comment):
|
||||
survexblock.expedition = expo
|
||||
survexblock.expeditionday = survexblock.expedition.get_expedition_day(survexblock.date)
|
||||
survexblock.save()
|
||||
|
||||
def LoadSurvexLeg(self, survexblock, sline, comment):
|
||||
"""This reads compass, clino and tape data but only keeps the tape lengths,
|
||||
the rest is discarded after error-checking.
|
||||
"""
|
||||
@ -141,8 +164,9 @@ class LoadingSurvex():
|
||||
invalid_compass = 720.0
|
||||
invalid_tape = 0.0
|
||||
|
||||
# if self.flagsstar["skiplegs"]:
|
||||
# return
|
||||
if self.flagsstar["skiplegs"]:
|
||||
#print("skip in ", self.flagsstar, survexblock.survexfile.path)
|
||||
return
|
||||
|
||||
#print("! LEG datastar type:{}++{}\n{} ".format(self.datastar["type"].upper(), survexblock.survexfile.path, sline))
|
||||
# SKIP PASSAGES *data passage
|
||||
@ -165,7 +189,22 @@ class LoadingSurvex():
|
||||
survexleg = SurvexLeg()
|
||||
|
||||
ls = sline.lower().split()
|
||||
|
||||
|
||||
# skip all splay legs
|
||||
if ls[datastar["from"]] == "..":
|
||||
#print("Splay in ", survexblock.survexfile.path)
|
||||
return
|
||||
if ls[datastar["to"]] == "..":
|
||||
#print("Splay in ", survexblock.survexfile.path)
|
||||
return
|
||||
if self.flagsstar["splayalias"]:
|
||||
if ls[datastar["from"]] == "-":
|
||||
#print("Aliased splay in ", survexblock.survexfile.path)
|
||||
return
|
||||
if ls[datastar["to"]] == "-":
|
||||
#print("Aliased splay in ", survexblock.survexfile.path)
|
||||
return
|
||||
|
||||
try:
|
||||
tape = ls[datastar["tape"]]
|
||||
except:
|
||||
@ -176,8 +215,7 @@ class LoadingSurvex():
|
||||
models.DataIssue.objects.create(parser='survexleg', message=message)
|
||||
survexleg.tape = invalid_tape
|
||||
return
|
||||
# this next fails for two surface survey svx files which use / for decimal point
|
||||
# e.g. '29/09' in the tape measurement, or use decimals but in brackets, e.g. (06.05)
|
||||
# e.g. '29/09' or '(06.05)' in the tape measurement
|
||||
# tape = tape.replace("(","") # edited original file (only one) instead
|
||||
# tape = tape.replace(")","") # edited original file (only one) instead
|
||||
# tape = tape.replace("/",".") # edited original file (only one) instead.
|
||||
@ -192,7 +230,7 @@ class LoadingSurvex():
|
||||
models.DataIssue.objects.create(parser='survexleg', message=message)
|
||||
survexleg.tape = invalid_tape
|
||||
try:
|
||||
survexblock.totalleglength += survexleg.tape
|
||||
survexblock.legslength += survexleg.tape
|
||||
self.slength += survexleg.tape
|
||||
except ValueError:
|
||||
message = ' ! Value Error: Tape length not added %s in %s' % (ls, survexblock.survexfile.path)
|
||||
@ -238,8 +276,6 @@ class LoadingSurvex():
|
||||
models.DataIssue.objects.create(parser='survexleg', message=message)
|
||||
survexleg.compass = invalid_compass
|
||||
|
||||
if self.flagsstar["skiplegs"]:
|
||||
return
|
||||
# delete the object to save memory
|
||||
survexleg = None
|
||||
|
||||
@ -651,6 +687,7 @@ class LoadingSurvex():
|
||||
# ------------ * FLAGS
|
||||
self.flagsstack.append(copy.deepcopy(self.flagsstar))
|
||||
# ------------ * FLAGS
|
||||
pass
|
||||
|
||||
def popblock():
|
||||
nonlocal blkid
|
||||
@ -675,7 +712,7 @@ class LoadingSurvex():
|
||||
if oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
|
||||
print(" # POP 'any' flag now:'{}' was:{} ".format(self.flagsstar["skiplegs"], oldflags["skiplegs"]))
|
||||
|
||||
def starstatement(mstar):
|
||||
def starstatement(star):
|
||||
nonlocal survexblock
|
||||
nonlocal blkid
|
||||
nonlocal pathlist
|
||||
@ -684,7 +721,7 @@ class LoadingSurvex():
|
||||
nonlocal slengthtotal
|
||||
nonlocal nlegstotal
|
||||
|
||||
cmd, args = mstar.groups()
|
||||
cmd, args = star.groups()
|
||||
cmd = cmd.lower()
|
||||
|
||||
# ------------------------BEGIN
|
||||
@ -702,7 +739,7 @@ class LoadingSurvex():
|
||||
newsurvexblock = models_survex.SurvexBlock(name=blkid, parent=survexblock,
|
||||
survexpath=pathlist,
|
||||
cave=self.currentcave, survexfile=self.currentsurvexfile,
|
||||
legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0)
|
||||
legsall=0, legslength=0.0)
|
||||
newsurvexblock.save()
|
||||
newsurvexblock.title = "("+survexblock.title+")" # copy parent inititally
|
||||
survexblock = newsurvexblock
|
||||
@ -712,7 +749,7 @@ class LoadingSurvex():
|
||||
# ---------------------------END
|
||||
elif re.match("end$(?i)", cmd):
|
||||
survexblock.legsall = self.legsnumber
|
||||
survexblock.totalleglength = self.slength
|
||||
survexblock.legslength = self.slength
|
||||
printend()
|
||||
slengthtotal += self.slength
|
||||
nlegstotal += self.legsnumber
|
||||
@ -751,6 +788,10 @@ class LoadingSurvex():
|
||||
|
||||
elif re.match("(?i)data$", cmd):
|
||||
self.LoadSurvexDataCmd(survexblock, args)
|
||||
elif re.match("(?i)alias$", cmd):
|
||||
self.LoadSurvexAlias(survexblock, args)
|
||||
elif re.match("(?i)entrance$", cmd):
|
||||
self.LoadSurvexEntrance(survexblock, args)
|
||||
elif re.match("(?i)date$", cmd):
|
||||
self.LoadSurvexDate(survexblock, args)
|
||||
elif re.match("(?i)team$", cmd):
|
||||
@ -777,12 +818,12 @@ class LoadingSurvex():
|
||||
continue # skip blank lines
|
||||
|
||||
# detect a star command
|
||||
mstar = self.rx_star.match(sline)
|
||||
if mstar:
|
||||
star = self.rx_star.match(sline)
|
||||
if star:
|
||||
# yes we are reading a *command
|
||||
starstatement(mstar)
|
||||
starstatement(star)
|
||||
else: # not a *cmd so we are reading data OR a ";" rx_comment failed
|
||||
self.LoadSurvexLineLeg(survexblock, sline, comment)
|
||||
self.LoadSurvexLeg(survexblock, sline, comment)
|
||||
|
||||
self.legsnumber = slengthtotal
|
||||
self.slength = nlegstotal
|
||||
@ -825,9 +866,9 @@ class LoadingSurvex():
|
||||
fcollate.write("{}\n".format(svxline.strip()))
|
||||
|
||||
sline, comment = self.rx_comment.match(svxline.strip()).groups()
|
||||
mstar = self.rx_star.match(sline)
|
||||
if mstar: # yes we are reading a *cmd
|
||||
cmd, args = mstar.groups()
|
||||
star = self.rx_star.match(sline)
|
||||
if star: # yes we are reading a *cmd
|
||||
cmd, args = star.groups()
|
||||
cmd = cmd.lower()
|
||||
if re.match("(?i)include$", cmd):
|
||||
includepath = os.path.normpath(os.path.join(os.path.split(path)[0], re.sub(r"\.svx$", "", args)))
|
||||
@ -1043,7 +1084,7 @@ def LoadSurvexBlocks():
|
||||
survexfileroot = MakeSurvexFileRoot()
|
||||
# this next makes a block_object assciated with a file_object.path = SURVEX_TOPNAME
|
||||
survexblockroot = models_survex.SurvexBlock(name=ROOTBLOCK, survexpath="", cave=None, survexfile=survexfileroot,
|
||||
legsall=0, legssplay=0, legssurfc=0, totalleglength=0.0)
|
||||
legsall=0, legslength=0.0)
|
||||
# this is the first so id=1
|
||||
survexblockroot.save()
|
||||
|
||||
@ -1056,7 +1097,7 @@ def LoadSurvexBlocks():
|
||||
print(" - MEMORY start:{:.3f} MB end:{:.3f} MB increase={:.3f} MB".format(memstart,memend, memend-memstart))
|
||||
|
||||
# Don't do this, it double-counts everything:
|
||||
#survexblockroot.totalleglength = slength
|
||||
#survexblockroot.legslength = slength
|
||||
#survexblockroot.legsall = legsnumber
|
||||
survexblockroot.save()
|
||||
|
||||
|
@ -10,18 +10,12 @@
|
||||
<p>{{ expoCount }} expeditions: {{ personCount }} people, {{ caveCount }} caves and {{ logbookEntryCount }} logbook entries.
|
||||
|
||||
<p>Number of survey legs: {{nsurvexlegs}}<br />
|
||||
Total length: {{totalsurvexlength|stringformat:".1f"}} km added-up on importing survex files.<br />
|
||||
Total length: {{addupsurvexlength|stringformat:".1f"}} km adding up the total for each year.</p>
|
||||
|
||||
<p>These are raw tape lengths which include pitches, splays and surface-surveys. There is also some doubt that the parsing is
|
||||
correct so maybe some long lengths are misinterpeted: compass readings as tape-lengths for example: LoadSurvexDataCmd
|
||||
in parsers/survex.py would be a good place to start.
|
||||
<p>These are uncorrected tape lengths which include pitches and duplicates but exclude splays or surface-surveys.
|
||||
<p>
|
||||
This is work in progress (July 2020).
|
||||
|
||||
<p>However the number of survey legs should be correct, and the by-year total <em>should</em> be
|
||||
the same as the by-file-import total.<br>Obviously there is still work to do.
|
||||
|
||||
<table>
|
||||
<tr><th>Year</th><th>Survex<br>Survey<br>Blocks</th><th>Survex<br>Survey Legs</th><th>Total length<br>(m)</th></tr>
|
||||
{% for legs in legsbyexpo %}
|
||||
|
@ -57,7 +57,7 @@
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
||||
<td>{{survexblock.totalleglength}}</td>
|
||||
<td>{{survexblock.legslength}}</td>
|
||||
|
||||
<td>
|
||||
{% for survextitle in survexblock.survextitle_set.all %}
|
||||
|
Loading…
Reference in New Issue
Block a user