From 76688695b80ebf18e4a8a541a1d2595204bee02b Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 18 Nov 2023 12:38:07 +0000 Subject: [PATCH] srtm altitude parsing --- core/models/caves.py | 2 +- parsers/survex.py | 33 ++++++++++++++++----------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/core/models/caves.py b/core/models/caves.py index fe22ea8..72a532b 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -82,7 +82,7 @@ class Cave(TroggleModel): references = models.TextField(blank=True, null=True) survex_file = models.CharField(max_length=100, blank=True, null=True) # should be a foreign key? survey = models.TextField(blank=True, null=True) - underground_centre_line = models.TextField(blank=True, null=True) + # underground_centre_line = models.TextField(blank=True, null=True) underground_description = models.TextField(blank=True, null=True) unofficial_number = models.CharField(max_length=60, blank=True, null=True) url = models.CharField(max_length=300, blank=True, null=True, unique = True) diff --git a/parsers/survex.py b/parsers/survex.py index ba90a84..9c5950c 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -617,7 +617,7 @@ class LoadingSurvex: SO we have to recognise the '*fix' too """ # *fix|36|reference|36359.40|82216.08|2000.00\n - rx_fixline = re.compile(r"(?i)^\s*[*]fix\s+([\w\d_\.\-]+)\s+(?:reference)?\s*([\d\.]*)\s+([\d\.]*)\s+([\d\.]*).*$") + rx_fixline = re.compile(r"(?i)^\s*[*]fix\s+([\w\d_\.\-]+)\s+(?:reference)?\s*([\d\.]*)\s+([\d\.]*)\s+([\d\.]*)\s*;(.*)$") line = line.replace("\n","") #fixline = self.rx_fixline.match(line) @@ -644,7 +644,7 @@ class LoadingSurvex: #_, _, alt, *rest = (fixdata + [None]*5)[:5] name, _, _, alt, comment = (list(fixdata) + [None]*5)[:5] fixid = str(survexblock.id)+ ":"+ name - self.fixes[fixid] = (survexblock, name) + self.fixes[fixid] = (survexblock, name, alt, comment) message = f"{name}, {fixdata=}, last:{fixline.groups()[-1]}" print(self.insp + message) except Exception as e: @@ -2417,24 +2417,23 @@ def FindAndLoadSurvex(): for f in svx_load.fixes: # why are we seeing no *fixes from fixedpts/gps18.svx etc. ? They are parsed ! - survexblock, altitude, comment = svx_load.fixes[f] + survexblock, name, altitude, comment = svx_load.fixes[f] s = survexblock - spath = "" - sprevious = None - while s.parent != sprevious: - spath += str(s.parent) + ":" + spath - sprevious = s - if not s.parent: - break - s = s.parent - + spath = s.parent.survexfile + # sprevious = None + # while s.parent != sprevious: + # spath += str(s.parent) + ":" + spath + # sprevious = s + # if not s.parent: + # break + # s = s.parent + ff = survexblock.survexfile if comment: - print(f"COMMENT {survexblock} {altitude} {comment}") + # print(f"FIX {survexblock} {altitude} {comment}") if re.match("(?i)[^s]*srtm[\s\S]*", comment.lower()): - print(f"{f} - {spath}::{survexblock} - {comment}") - else: - if str(f).startswith("1623"): - print(f"{f} - {spath}::{survexblock} - {altitude=}") + print(f"SRTM {ff}.svx::{survexblock} - {spath}.svx - '{comment}'") + if re.match("(?i)[^s]*radost[\s\S]*", comment.lower()): + print(f"RDST {ff}.svx::{survexblock} - {spath}.svx - '{comment}'") svx_load = None