From b88b1423328d26081457e9d0bb5f55cf86232f24 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 12 Mar 2023 00:35:37 +0000 Subject: [PATCH] fixing bad splay detection --- core/views/survex.py | 5 +++++ parsers/survex.py | 28 +++++++++++++++++----------- templates/onthisdate.html | 2 +- templates/personexpedition.html | 18 +++--------------- templates/statistics.html | 5 +++-- templates/svxfile.html | 1 + 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/core/views/survex.py b/core/views/survex.py index e91d228..edc3b1f 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -350,6 +350,10 @@ def svx(request, survex_file): svxblocks = [] try: svxblocksall = svxfile.survexblock_set.all() + svxlength = 0.0 + for b in svxblocksall: + svxlength += b.legslength + print(svxlength,b) except AttributeError: # some survexfiles just *include files and have no blocks themselves svxblocksall = [] else: @@ -366,6 +370,7 @@ def svx(request, survex_file): "warning": warning, "has_3d": (Path(survexdatasetpath) / Path(survex_file + ".3d")).is_file(), "title": survex_file, + "svxlength": svxlength, "svxblocks": svxblocks, "svxincludes": svxincludes, "difflist": difflist, diff --git a/parsers/survex.py b/parsers/survex.py index d91eabe..6cff3e5 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -497,9 +497,10 @@ class LoadingSurvex: def LoadSurvexAlias(self, survexblock, line): # *alias station - .. - splayalias = re.match("(?i)station\s*\-\s*\.\.\s*$", line) + splayalias = re.match("(?i)\s*station\s*\-\s*\.\.\s*$", line) if splayalias: self.flagsstar["splayalias"] = True + print(line) else: message = f"! Bad *ALIAS: '{line}' ({survexblock}) {survexblock.survexfile.path}" print(self.insp + message) @@ -696,7 +697,13 @@ class LoadingSurvex: survexleg = SurvexLeg() # skip all splay legs - try: + try: + if "splayalias" in self.flagsstar: + if ls[datastar["from"]] == "-" or ls[datastar["to"]] == "-": + if debugprint: + print("Aliased splay in ", survexblock.survexfile.path) + return + if ls[datastar["from"]] == ".." or ls[datastar["from"]] == ".": if debugprint: print("Splay in ", survexblock.survexfile.path) @@ -705,15 +712,14 @@ class LoadingSurvex: if debugprint: print("Splay in ", survexblock.survexfile.path) return - if self.flagsstar["splayalias"]: - if ls[datastar["from"]] == "-": - if debugprint: - print("Aliased splay in ", survexblock.survexfile.path) - return - if ls[datastar["to"]] == "-": - if debugprint: - print("Aliased splay in ", survexblock.survexfile.path) - return + + if ls[datastar["to"]] == "-": + message = f" ! Suspected splay, not declared, in line {ls} in {survexblock.survexfile.path}" + print(self.insp + message) + stash_data_issue( + parser="survexleg", message=message, url=None, sb=(survexblock.survexfile.path) + ) + return except: message = f" ! datastar parsing from/to incorrect in line {ls} in {survexblock.survexfile.path}" print(self.insp + message) diff --git a/templates/onthisdate.html b/templates/onthisdate.html index e2f44d1..eea001b 100644 --- a/templates/onthisdate.html +++ b/templates/onthisdate.html @@ -3,7 +3,7 @@ {% if svxothers %}Survex files on this date:
{% for item in svxothers %} -     {{item.path|safe}}
+     {{item.path|safe}}
{% empty %} None found for this date.
{% endfor %} diff --git a/templates/personexpedition.html b/templates/personexpedition.html index ea26088..365c812 100644 --- a/templates/personexpedition.html +++ b/templates/personexpedition.html @@ -1,10 +1,5 @@ {% extends "base.html" %} {% block title %}Person {{personexpedition.person}} for {{personexpedition.expedition}}{% endblock %} - {% block content %}

@@ -13,7 +8,7 @@ If anyone really cares, they can always look in the original survex file

{{message}}

-

{{personexpedition.surveyedleglength|stringformat:".1f"}} m surveyed this year.

+

{{personexpedition.surveyedleglength|floatformat:1}} m surveyed this year.

Other years:  {% for otherpersonexpedition in personexpedition.person.personexpedition_set.all %} @@ -31,8 +26,6 @@ If anyone really cares, they can always look in the original survex file

Table of all trips and surveys aligned by date

- {% for persondate in personchronology %} @@ -47,14 +40,9 @@ If anyone really cares, they can always look in the original survex file {% if persondate.2 %} - {%comment%} - {%endcomment%} + {% else %} diff --git a/templates/statistics.html b/templates/statistics.html index 67a895d..9439fdc 100644 --- a/templates/statistics.html +++ b/templates/statistics.html @@ -12,17 +12,18 @@ Total length: {{addupsurvexlength|stringformat:".1f"}} km adding up the total fo

These are uncorrected tape lengths which include pitches and duplicates but exclude splays or surface-surveys.

-This is work in progress (Feb.2023). +This is work in progress (March 2023): the last column is floatng point numbers, the 3rd column appears to be strings..

This includes ARGE and other surveys currently. It will be changed to only include lengths surveyed by valid Expo-attendees.

DateTripsSurveys
{{persondate.2.name}} - {% for survexpersonrole in persondate.2.survexpersonrole_set.all %} - {{survexpersonrole.nrole}} - {% endfor %} - - {{persondate.2.legslength|stringformat:".1f"}} m + {{persondate.2.legslength|floatformat:1}} m
- + {% for legs in legsbyexpo %} + {% endfor %}
YearSurvex
Survey
Blocks
Survex
Survey Legs
Total length
(m)
YearSurvex
Survey
Blocks
Survex
Survey Legs
Total length
(m)
Total length
(m)
{{legs.0}} {{legs.0.survexblock_set.all|length}} {{legs.1.nsurvexlegs|rjust:"10"}} {{legs.1.survexleglength}}{{legs.1.survexleglength|floatformat:0}}
diff --git a/templates/svxfile.html b/templates/svxfile.html index 22abaf6..ca35cde 100644 --- a/templates/svxfile.html +++ b/templates/svxfile.html @@ -80,6 +80,7 @@ LOGMESSAGES --> {% endif %}
+survey length: {{svxlength|floatformat:2}} metres {% for sb in svxblocks %} {% empty %}