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

Added parsing of all.svx, along side parsing individual caves.

Added the making and parsing of all.pos to determine the location of stations.
Mare work is required so the caves are parsed and stored only once.
Survex parsing appears to include bugs, that print out errors.
This commit is contained in:
Martin Green
2011-07-11 00:01:12 +01:00
parent 425d38727d
commit 06efab7d73
2 changed files with 84 additions and 7 deletions

View File

@@ -52,10 +52,20 @@ class SurvexFile(models.Model):
class SurvexEquate(models.Model):
cave = models.ForeignKey('Cave', blank=True, null=True)
class SurvexStationLookUpManager(models.Manager):
def lookup(self, name):
blocknames, sep, stationname = name.rpartition(".")
return self.get(block = SurvexBlock.objects.lookup(blocknames),
name = stationname)
class SurvexStation(models.Model):
name = models.CharField(max_length=20)
block = models.ForeignKey('SurvexBlock')
equate = models.ForeignKey('SurvexEquate', blank=True, null=True)
objects = SurvexStationLookUpManager()
x = models.FloatField(blank=True, null=True)
y = models.FloatField(blank=True, null=True)
z = models.FloatField(blank=True, null=True)
class SurvexLeg(models.Model):
block = models.ForeignKey('SurvexBlock')
@@ -70,7 +80,16 @@ class SurvexLeg(models.Model):
#
# Single SurvexBlock
#
class SurvexBlockLookUpManager(models.Manager):
def lookup(self, name):
blocknames = name.split(".")
block = SurvexBlock.objects.get(parent=None, survexfile__path="all")
for blockname in blocknames:
block = SurvexBlock.objects.get(parent=block, name=blockname)
return block
class SurvexBlock(models.Model):
objects = SurvexBlockLookUpManager()
name = models.CharField(max_length=100)
parent = models.ForeignKey('SurvexBlock', blank=True, null=True)
text = models.TextField()