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:
@@ -195,6 +195,22 @@ class SurvexBlockLookUpManager(models.Manager):
|
|||||||
block = SurvexBlock.objects.get(parent=block, name__iexact=blockname)
|
block = SurvexBlock.objects.get(parent=block, name__iexact=blockname)
|
||||||
return block
|
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):
|
class SurvexBlock(models.Model):
|
||||||
"""One begin..end block within a survex file. The basic element of a survey trip.
|
"""One begin..end block within a survex file. The basic element of a survey trip.
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class MapLocations(object):
|
|||||||
# but not in troggle reports unless we include them here
|
# but not in troggle reports unless we include them here
|
||||||
|
|
||||||
nullent = Entrance.objects.all()[0]
|
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,
|
# nor are they on the pendingcaves.txt list - yet - as they really need a proper name,
|
||||||
# /walletedit/2013:02
|
# /walletedit/2013:02
|
||||||
# so probably 2013-BL-02,03 etc.
|
# so probably 2013-BL-02,03 etc.
|
||||||
@@ -393,5 +393,7 @@ def LoadPositions():
|
|||||||
print(f" - {found} distinct SurvexStation entrance stations identified in {lineno:,} lines in {positions_filename}.")
|
print(f" - {found} distinct SurvexStation entrance stations identified in {lineno:,} lines in {positions_filename}.")
|
||||||
if dups > 0:
|
if dups > 0:
|
||||||
print(f" - {dups} Duplicated SurvexStation entrances found")
|
print(f" - {dups} Duplicated SurvexStation entrances found")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
store_data_issues()
|
store_data_issues()
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ from pathlib import Path
|
|||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
|
from troggle.core.models.caves import Cave, Entrance, GetCaveLookup
|
||||||
from troggle.core.models.logbooks import QM
|
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.troggle import DataIssue, Expedition
|
||||||
from troggle.core.models.wallets import Wallet
|
from troggle.core.models.wallets import Wallet
|
||||||
from troggle.core.utils import chaosmonkey, get_process_memory
|
from troggle.core.utils import chaosmonkey, get_process_memory
|
||||||
@@ -2544,30 +2544,24 @@ def FindAndLoadSurvex():
|
|||||||
print(f" - Number of SurvexFiles: {tf:,}")
|
print(f" - Number of SurvexFiles: {tf:,}")
|
||||||
print(f" - Number of Survex *fix: {fixnumber:,}")
|
print(f" - Number of Survex *fix: {fixnumber:,}")
|
||||||
print(f" - Number of Survex legs: {legsnumber:,}")
|
print(f" - Number of Survex legs: {legsnumber:,}")
|
||||||
|
|
||||||
for f in svx_load.fixes:
|
fixlist = []
|
||||||
|
for f in svx_load.fixes:
|
||||||
survexblock, name, altitude, comment = svx_load.fixes[f]
|
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
|
s = survexblock
|
||||||
spath = s.parent.survexfile
|
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
|
ff = survexblock.survexfile
|
||||||
|
# print(f"FIX {name} : {ff} {survexblock} ; {comment}")
|
||||||
if comment:
|
if comment:
|
||||||
# print(f"FIX {survexblock} {altitude} {comment}")
|
|
||||||
if re.match(r"(?i)[^s]*srtm[\s\S]*", comment.lower()):
|
if re.match(r"(?i)[^s]*srtm[\s\S]*", comment.lower()):
|
||||||
print(f"SRTM {ff}.svx::{survexblock} - {spath}.svx - alt={altitude} '{comment}'")
|
print(f"SRTM {ff}.svx::{survexblock} - {spath}.svx - alt={altitude} '{comment}'")
|
||||||
if re.match(r"(?i)[^s]*radost[\s\S]*", comment.lower()):
|
if re.match(r"(?i)[^s]*radost[\s\S]*", comment.lower()):
|
||||||
print(f"RDST {ff}.svx::{survexblock} - {spath}.svx - alt={altitude} '{comment}'")
|
print(f"RDST {ff}.svx::{survexblock} - {spath}.svx - alt={altitude} '{comment}'")
|
||||||
|
SurvexFix.objects.bulk_create(fixlist)
|
||||||
svx_load = None
|
svx_load = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return legsnumber
|
return legsnumber
|
||||||
|
|
||||||
def display_contents(blocks):
|
def display_contents(blocks):
|
||||||
|
|||||||
Reference in New Issue
Block a user