2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-18 18:07:15 +00:00

Adding SUrvexFix class

This commit is contained in:
2025-07-29 19:42:59 +02:00
parent 959c358c09
commit 7a9bcd02f7
3 changed files with 28 additions and 16 deletions

View File

@@ -195,6 +195,22 @@ class SurvexBlockLookUpManager(models.Manager):
block = SurvexBlock.objects.get(parent=block, name__iexact=blockname)
return block
class SurvexFix(models.Model):
"""a *fix line in a survexfile. New at the end of expo in July 2025
This is used to detect *fix stations which are not attached to a *entrance and thus to a cave
i.e. it is used to discover potential cave entrances
But this does not include the virtual *fix locations which are
in locations.py
"""
objects = SurvexBlockLookUpManager() # overwrites Survexfix.objects and enables lookup()
name = models.CharField(max_length=100)
class Meta:
ordering = ("name",)
def __str__(self):
return self.name + str(self.id)
class SurvexBlock(models.Model):
"""One begin..end block within a survex file. The basic element of a survey trip.

View File

@@ -60,7 +60,7 @@ class MapLocations(object):
# but not in troggle reports unless we include them here
nullent = Entrance.objects.all()[0]
# These pending entrnces have been added to the fixedpts but no Cave Description page has been created yet,
# These pending entrances have been added to the fixedpts but no Cave Description page has been created yet,
# nor are they on the pendingcaves.txt list - yet - as they really need a proper name,
# /walletedit/2013:02
# so probably 2013-BL-02,03 etc.
@@ -394,4 +394,6 @@ def LoadPositions():
if dups > 0:
print(f" - {dups} Duplicated SurvexStation entrances found")
store_data_issues()

View File

@@ -10,7 +10,7 @@ from pathlib import Path
import troggle.settings as settings
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
from troggle.core.models.logbooks import QM
from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole, SurvexStation
from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole, SurvexStation, SurvexFix
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.models.wallets import Wallet
from troggle.core.utils import chaosmonkey, get_process_memory
@@ -2545,29 +2545,23 @@ def FindAndLoadSurvex():
print(f" - Number of Survex *fix: {fixnumber:,}")
print(f" - Number of Survex legs: {legsnumber:,}")
fixlist = []
for f in svx_load.fixes:
survexblock, name, altitude, comment = svx_load.fixes[f]
fixlist.append(SurvexFix(name=name))
# this loses the survex context, e.g. 1623. or 1626. is lost
# we would need to track teh *begin/*end labels to do that
s = survexblock
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
# print(f"FIX {name} : {ff} {survexblock} ; {comment}")
if comment:
# print(f"FIX {survexblock} {altitude} {comment}")
if re.match(r"(?i)[^s]*srtm[\s\S]*", comment.lower()):
print(f"SRTM {ff}.svx::{survexblock} - {spath}.svx - alt={altitude} '{comment}'")
if re.match(r"(?i)[^s]*radost[\s\S]*", comment.lower()):
print(f"RDST {ff}.svx::{survexblock} - {spath}.svx - alt={altitude} '{comment}'")
SurvexFix.objects.bulk_create(fixlist)
svx_load = None
return legsnumber
def display_contents(blocks):