diff options
Diffstat (limited to 'parsers')
-rw-r--r-- | parsers/survex.py | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/parsers/survex.py b/parsers/survex.py index b5542cf..5f23c5c 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -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)) |