forked from expo/troggle
rewritten QM loading from SVX files
This commit is contained in:
@@ -235,62 +235,41 @@ class LoadSurvex():
|
|||||||
insp = self.insp
|
insp = self.insp
|
||||||
qm_no = qmline.group(1)
|
qm_no = qmline.group(1)
|
||||||
qm_grade = qmline.group(2)
|
qm_grade = qmline.group(2)
|
||||||
qm_from_block = qmline.group(3) # usual closest survey station
|
if qmline.group(3): # usual closest survey station
|
||||||
qm_from_station = qmline.group(4)
|
qm_nearest = qmline.group(3)
|
||||||
qm_resolve_section = qmline.group(6)
|
if qmline.group(4):
|
||||||
qm_resolve_station = qmline.group(7)
|
qm_nearest = qm_nearest +"."+ qmline.group(4)
|
||||||
|
|
||||||
|
if qmline.group(6) and qmline.group(6) != '-':
|
||||||
|
qm_resolve_station = qmline.group(6)
|
||||||
|
if qmline.group(7):
|
||||||
|
qm_resolve_station = qm_resolve_station +"."+ qmline.group(7)
|
||||||
|
else:
|
||||||
|
qm_resolve_station = ""
|
||||||
qm_notes = qmline.group(8)
|
qm_notes = qmline.group(8)
|
||||||
# This whole section should be moved if we can have *QM become a proper survex command
|
# Spec of QM in SVX files:
|
||||||
# Spec of QM in SVX files, currently commented out need to add to survex
|
|
||||||
# needs to match self.rx_qm
|
|
||||||
# ;Serial number grade(A/B/C/D/X) nearest-station resolution-station description
|
# ;Serial number grade(A/B/C/D/X) nearest-station resolution-station description
|
||||||
# ;QM1 a hobnob_hallway_2.42 hobnob-hallway_3.42 junction of keyhole passage
|
# ;QM1 a hobnob_hallway_2.42 hobnob-hallway_3.42 junction of keyhole passage
|
||||||
# ;QM1 a hobnob_hallway_2.42 - junction of keyhole passage
|
# ;QM1 a hobnob_hallway_2.42 - junction of keyhole passage
|
||||||
|
|
||||||
# print(insp+'Cave - %s' % survexfile.cave)
|
# NB none of the SurveyStations are in the DB now, so if we want to link to aSurvexStation
|
||||||
# print(insp+'QM no %d' % int(qm_no))
|
# we would have to create one. But that is not obligatory and no QMs loaded from CSVs have one
|
||||||
# print(insp+'QM grade %s' % qm_grade)
|
try:
|
||||||
# print(insp+'QM section %s' % qm_from_block)
|
qm = models_caves.QM.objects.create(number=qm_no,
|
||||||
# print(insp+'QM station %s' % qm_from_station)
|
# nearest_station=a_survex_station_object, # can be null
|
||||||
# print(insp+'QM res section %s' % qm_resolve_section)
|
nearest_station_description=qm_resolve_station,
|
||||||
# print(insp+'QM res station %s' % qm_resolve_station)
|
nearest_station_name=qm_nearest,
|
||||||
# print(insp+'QM notes %s' % qm_notes)
|
grade=qm_grade.upper(),
|
||||||
|
location_description=qm_notes)
|
||||||
# If the QM isn't resolved (has a resolving station) then load it.
|
qm.save
|
||||||
# NB none of the SurveyStations are in the DB now, so searching always fails
|
# message = " ! QM{} '{}' CREATED in DB in '{}'".format(qm_no, qm_nearest,survexblock.survexfile.path)
|
||||||
if not qm_resolve_section or qm_resolve_section != '-' or qm_resolve_section != 'None':
|
# print(insp+message)
|
||||||
from_block = models_survex.SurvexBlock.objects.filter(name=qm_from_block)
|
# models.DataIssue.objects.create(parser='survex', message=message)
|
||||||
# If we can find a section (survex note chunk, named)
|
except:
|
||||||
if len(from_block) > 0:
|
message = " ! QM{} FAIL to create {} in'{}'".format(qm_no, qm_nearest,survexblock.survexfile.path)
|
||||||
from_station = models_survex.SurvexStation.objects.filter(block=from_block[0], name=qm_from_station)
|
|
||||||
# If we can find a from station then we have the nearest station and can import it
|
|
||||||
# but now that we don't import all the stations this will fail
|
|
||||||
if len(from_station) > 0:
|
|
||||||
qm = models_caves.QM.objects.create(number=qm_no,
|
|
||||||
nearest_station=from_station[0],
|
|
||||||
grade=qm_grade.upper(),
|
|
||||||
location_description=qm_notes)
|
|
||||||
message = " - QM{} in '{}' loaded into DB using '{}'".format(qm_no, survexblock.survexfile.path,str(from_station[0]))
|
|
||||||
print(insp+message)
|
|
||||||
models.DataIssue.objects.create(parser='survex', message=message)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
qm = models_caves.QM.objects.create(number=qm_no,
|
|
||||||
nearest_station=qm_from_block,
|
|
||||||
grade=qm_grade.upper(),
|
|
||||||
location_description=qm_notes)
|
|
||||||
message = " ! QM{} in '{}' CREATED in DB at '{}'".format(qm_no, survexblock.survexfile.path, qm_from_block)
|
|
||||||
print(insp+message)
|
|
||||||
models.DataIssue.objects.create(parser='survex', message=message)
|
|
||||||
except:
|
|
||||||
message = " ! QM{} in '{}' failed to create in DB at '{}'".format(qm_no, survexblock.survexfile.path, qm_from_block)
|
|
||||||
print(insp+message)
|
|
||||||
models.DataIssue.objects.create(parser='survex', message=message)
|
|
||||||
else:
|
|
||||||
message = " - QM{} in '{}' resolved as '{}'".format(qm_no, survexblock.survexfile.path,qm_resolve_section)
|
|
||||||
print(insp+message)
|
print(insp+message)
|
||||||
models.DataIssue.objects.create(parser='survex', message=message)
|
models.DataIssue.objects.create(parser='survex', message=message)
|
||||||
pass
|
|
||||||
|
|
||||||
def LoadSurvexComment(self, survexblock, comment):
|
def LoadSurvexComment(self, survexblock, comment):
|
||||||
# ignore all comments except ;ref and ;QM
|
# ignore all comments except ;ref and ;QM
|
||||||
|
|||||||
Reference in New Issue
Block a user