mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 07:11:52 +00:00
found why regex is not finding ; comment, to fix
This commit is contained in:
parent
e1c9de14ca
commit
5961175193
@ -300,6 +300,9 @@ class LoadingSurvex:
|
||||
rx_commteam = re.compile(r"(?i)\s*(Messteam|Zeichner)\s*[:]?(.*)")
|
||||
rx_quotedtitle = re.compile(r'(?i)^"(.*)"$')
|
||||
|
||||
rx_fixline = re.compile(r"(?i)^\s*([\w\d_\.\-]+)\s+(?:reference)?\s*([\d\.]*)\s+([\d\.]*)\s+([\d\.]*)(.*)$")
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
@ -611,15 +614,19 @@ class LoadingSurvex:
|
||||
|
||||
def LoadSurvexFix(self, survexblock, line):
|
||||
"""*fix is a station geolocation, units depend on a previous *cs setting
|
||||
NOTE 'line' is not the full line, it is 'arg' and the comments have been stripped !
|
||||
"""
|
||||
#fixline = line.strip().replace("\t"," ").split(" ") # unpack tuples idiom in python 3
|
||||
fixline = re.match("(?i)\s*([\w\d_\.\-]+)\s+(?:reference)?\s*([\d\.]*)\s+([\d\.]*)\s+([\d\.]*)\s*(;.*)?$", line)
|
||||
# fixline = re.match("(?i)\s*([\w\d_\.\-]+)\s+(?:reference)?\s*([\d\.]*)\s+([\d\.]*)\s+([\d\.]*)\s*(.*)$", line)
|
||||
fixline = self.rx_fixline.match(line)
|
||||
if not fixline:
|
||||
message = f'BAD fix regex {line.replace(" ","|")} {survexblock.survexfile.path}:{survexblock}'
|
||||
print(self.insp + message)
|
||||
stash_data_issue(parser="survex", message=message)
|
||||
else:
|
||||
name, *fixdata = fixline.groups()
|
||||
fixdata = fixline.groups()
|
||||
#print(fixline.group(1), fixline.group(5))
|
||||
print(f"'{line}'")
|
||||
name = fixdata[0]
|
||||
if name in self.fixes:
|
||||
message = f"! Duplicate *FIX: id '{line}' ({survexblock}) {survexblock.survexfile.path}"
|
||||
print(self.insp + message)
|
||||
@ -630,11 +637,14 @@ class LoadingSurvex:
|
||||
|
||||
try:
|
||||
#_, _, alt, *rest = (fixdata + [None]*4)[:4]
|
||||
_, _, alt, comment = fixdata
|
||||
fixid = str(survexblock)+name
|
||||
name, _, _, alt, comment = fixdata
|
||||
fixid = str(survexblock.id)+ ":"+ name
|
||||
self.fixes[fixid] = (survexblock, alt, comment)
|
||||
except:
|
||||
print(f'BAD fix {name}, {fixdata=}\n{line.replace(" ","|")}\n{survexblock.survexfile.path}:{survexblock}', file=sys.stderr)
|
||||
message = f"{name}, {fixdata=}, last:{fixline.groups()[-1]}"
|
||||
print(self.insp + message)
|
||||
except Exception as e:
|
||||
print(f'BAD fix comment {e}', file=sys.stderr)
|
||||
print(f'BAD fix comment {name}, {fixdata=}\n{line.replace(" ","|")}\n{survexblock.survexfile.path}:{survexblock}', file=sys.stderr)
|
||||
|
||||
|
||||
def LoadSurvexEntrance(self, survexblock, line):
|
||||
@ -2402,13 +2412,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]
|
||||
s = survexblock
|
||||
spath = ""
|
||||
sprevious = None
|
||||
while s.parent != sprevious:
|
||||
spath += str(s.parent) + ":" + spath
|
||||
sprevious = s
|
||||
if not s.parent:
|
||||
break
|
||||
s = s.parent
|
||||
|
||||
if comment:
|
||||
print(f"{a} {b} {comment}")
|
||||
print(f"COMMENT {survexblock} {altitude} {comment}")
|
||||
if re.match("(?i)[^s]*srtm[\s\S]*", comment.lower()):
|
||||
print(f"{f} - {comment}")
|
||||
print(f"{f} - {spath}::{survexblock} - {comment}")
|
||||
else:
|
||||
if str(f).startswith("162"):
|
||||
print(f"{f} - {survexblock.survexfile}:{survexblock} - {altitude=}")
|
||||
if str(f).startswith("1623"):
|
||||
print(f"{f} - {spath}::{survexblock} - {altitude=}")
|
||||
|
||||
svx_load = None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user