diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/models/caves.py | 6 | ||||
-rw-r--r-- | core/models/survex.py | 1 | ||||
-rw-r--r-- | core/views/statistics.py | 49 |
3 files changed, 42 insertions, 14 deletions
diff --git a/core/models/caves.py b/core/models/caves.py index 4827095..3079ed1 100644 --- a/core/models/caves.py +++ b/core/models/caves.py @@ -158,9 +158,11 @@ class Cave(TroggleModel): for e in CaveAndEntrance.objects.filter(cave=self): if e.entrance.best_station() and e.entrance.best_station() != "": #print(self, e, e.entrance.best_station()) - if e.entrance.best_station_object().x: - # print(f"{self} {e.entrance.best_station_object()} {e.entrance.best_station_object().x}") + try: + x = e.entrance.best_station_object().x no_data = False + except: + pass return no_data def singleentrance(self): diff --git a/core/models/survex.py b/core/models/survex.py index 68bae05..6e2a06f 100644 --- a/core/models/survex.py +++ b/core/models/survex.py @@ -58,6 +58,7 @@ class SurvexStation(models.Model): x = models.FloatField(blank=True, null=True) y = models.FloatField(blank=True, null=True) z = models.FloatField(blank=True, null=True) + entrance = models.ForeignKey("Entrance", blank=True, null=True, on_delete=models.SET_NULL) class Meta: ordering = ("id",) diff --git a/core/views/statistics.py b/core/views/statistics.py index 2927bd3..c1a0ca8 100644 --- a/core/views/statistics.py +++ b/core/views/statistics.py @@ -1,4 +1,5 @@ from collections import OrderedDict +from math import sqrt from pathlib import Path from django.shortcuts import render @@ -276,15 +277,10 @@ def dataissues(request): def eastings(request): """report each Northing/Easting pair wherever recorded""" - ents = [] - entrances = Entrance.objects.all() - for e in entrances: - if e.easting or e.northing: - ents.append(e) - if e.lat_wgs84 or e.long_wgs84: - ents.append(e) - - for e in ents: + ents = set() + gpsents = set() + + def add_stations(e): try: ts = e.tag_station if ts: @@ -306,10 +302,39 @@ def eastings(request): e.tag_es = None e.tag_os = None # print(f"exception for {e}") - - stations = SurvexStation.objects.all() + + entrances = Entrance.objects.all() + for e in entrances: + if e.easting or e.northing: + ents.add(e) + add_stations(e) + e.northing = float(e.northing) + e.easting = float(e.easting) + + if e.northing < 5200000: + e.bmn = True + # e.northing = e.northing + 5200000 + e.northing = e.northing + 5198919.918 + + #e.easting = e.easting - 36000 + 486000 + e.easting = e.easting + 374854.63 # linear hack + + try: + e.diffx = e.easting - e.best_station_object().x + e.diffy = e.northing - e.best_station_object().y + e.error = sqrt(e.diffx**2 + e.diffy**2) + except: + pass + + for e in entrances: + if e.lat_wgs84 or e.long_wgs84: + gpsents.add(e) + add_stations(e) + + + stations = SurvexStation.objects.all() # NB these are NOT all the stations in troggle_import_root.pos - return render(request, "eastings.html", {"ents": ents, "stations": stations}) + return render(request, "eastings.html", {"ents": ents, "gpsents": gpsents, "stations": stations}) def aliases(request, year): |