2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 15:21:52 +00:00

Entrance locations showing lat long screwups

This commit is contained in:
Philip Sargent 2023-09-16 22:46:17 +03:00
parent a85f859f88
commit 017f916ef9
4 changed files with 84 additions and 9 deletions

View File

@ -10,7 +10,7 @@ from django.template import loader
import settings import settings
from troggle.core.models.logbooks import QM from troggle.core.models.logbooks import QM
from troggle.core.models.survex import SurvexStation from troggle.core.models.survex import SurvexStation, utmToLatLng
from troggle.core.models.troggle import DataIssue, TroggleModel from troggle.core.models.troggle import DataIssue, TroggleModel
from troggle.core.utils import TROG, writetrogglefile from troggle.core.utils import TROG, writetrogglefile
@ -123,7 +123,7 @@ class Cave(TroggleModel):
pass pass
else: else:
self.official_name.lower() self.official_name.lower()
return Path(settings.URL_ROOT) / self.url # not good Django style.. NEEDS actual URL return Path(settings.URL_ROOT) / self.url # not good Django style? NEEDS actual URL
def url_parent(self): def url_parent(self):
if self.url: if self.url:
@ -232,7 +232,7 @@ class Entrance(TroggleModel):
alt = models.TextField(blank=True, null=True) alt = models.TextField(blank=True, null=True)
approach = models.TextField(blank=True, null=True) approach = models.TextField(blank=True, null=True)
bearings = models.TextField(blank=True, null=True) bearings = models.TextField(blank=True, null=True)
easting = models.TextField(blank=True, null=True) easting = models.TextField(blank=True, null=True) # apparently? manually entered not calculated
entrance_description = models.TextField(blank=True, null=True) entrance_description = models.TextField(blank=True, null=True)
exact_station = models.TextField(blank=True, null=True) exact_station = models.TextField(blank=True, null=True)
explorers = models.TextField(blank=True, null=True) explorers = models.TextField(blank=True, null=True)
@ -240,14 +240,14 @@ class Entrance(TroggleModel):
findability = models.CharField(max_length=1, choices=FINDABLE_CHOICES, blank=True, null=True) findability = models.CharField(max_length=1, choices=FINDABLE_CHOICES, blank=True, null=True)
findability_description = models.TextField(blank=True, null=True) findability_description = models.TextField(blank=True, null=True)
lastvisit = models.TextField(blank=True, null=True) lastvisit = models.TextField(blank=True, null=True)
lat_wgs84 = models.TextField(blank=True, null=True) lat_wgs84 = models.TextField(blank=True, null=True) # manually entered not calculated
location_description = models.TextField(blank=True, null=True) location_description = models.TextField(blank=True, null=True)
long_wgs84 = models.TextField(blank=True, null=True) long_wgs84 = models.TextField(blank=True, null=True) # manually entered not calculated
map_description = models.TextField(blank=True, null=True) map_description = models.TextField(blank=True, null=True)
marking = models.CharField(max_length=2, choices=MARKING_CHOICES) marking = models.CharField(max_length=2, choices=MARKING_CHOICES)
marking_comment = models.TextField(blank=True, null=True) marking_comment = models.TextField(blank=True, null=True)
name = models.CharField(max_length=100, blank=True, null=True) name = models.CharField(max_length=100, blank=True, null=True)
northing = models.TextField(blank=True, null=True) northing = models.TextField(blank=True, null=True) # apparently? manually entered not calculated
other_description = models.TextField(blank=True, null=True) other_description = models.TextField(blank=True, null=True)
other_station = models.TextField(blank=True, null=True) other_station = models.TextField(blank=True, null=True)
photo = models.TextField(blank=True, null=True) photo = models.TextField(blank=True, null=True)
@ -410,6 +410,12 @@ class Entrance(TroggleModel):
return "" return ""
def latlong(self): def latlong(self):
"""Gets lat long assuming that it has to get it from the associated stations, but in fact the Entrance itself
has easting/northing and lat/long fields which perhaps we should try first...
"""
if self.easting and self.northing:
return utmToLatLng(33, float(self.easting), float(self.northing), northernHemisphere=True)
station = None station = None
if self.other_station: if self.other_station:
try: try:
@ -429,6 +435,17 @@ class Entrance(TroggleModel):
if station: if station:
return station.latlong() return station.latlong()
def lat(self):
if self.latlong():
return self.latlong()[0]
else:
return None
def long(self):
if self.latlong():
return self.latlong()[1]
else:
return None
def GetCaveLookup(): def GetCaveLookup():
"""A very relaxed way of finding probably the right cave given almost any string which might serve to identify it """A very relaxed way of finding probably the right cave given almost any string which might serve to identify it

View File

@ -67,7 +67,10 @@ class SurvexStation(models.Model):
def latlong(self): def latlong(self):
return utmToLatLng(33, self.x, self.y, northernHemisphere=True) return utmToLatLng(33, self.x, self.y, northernHemisphere=True)
def lat(self):
return utmToLatLng(33, self.x, self.y, northernHemisphere=True)[0]
def long(self):
return utmToLatLng(33, self.x, self.y, northernHemisphere=True)[1]
import math import math
def utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.py ? def utmToLatLng(zone, easting, northing, northernHemisphere=True): # move this to utils.py ?

View File

@ -284,6 +284,29 @@ def eastings(request):
if e.lat_wgs84 or e.long_wgs84: if e.lat_wgs84 or e.long_wgs84:
ents.append(e) ents.append(e)
for e in ents:
try:
ts = e.tag_station
if ts:
e.tag_ts = SurvexStation.objects.get(name=ts)
print(f"{e} {e.tag_ts} {e.tag_ts.lat()} {e.tag_ts.long()}")
es = e.exact_station
if es:
e.tag_es = SurvexStation.objects.get(name=es)
print(f"{e} {e.tag_es} {e.tag_es.lat()} {e.tag_es.long()}")
os = e.other_station
if os:
e.tag_os = SurvexStation.objects.get(name=os)
print(f"{e} {e.tag_os} {e.tag_os.lat()} {e.tag_os.long()}")
except:
e.tag_ss = None
e.tag_es = None
e.tag_os = None
# print(f"exception for {e}")
stations = SurvexStation.objects.all() stations = SurvexStation.objects.all()
return render(request, "eastings.html", {"ents": ents, "stations": stations}) return render(request, "eastings.html", {"ents": ents, "stations": stations})

View File

@ -29,7 +29,7 @@ th, td {
padding-right: 5px; padding-right: 5px;
</style> </style>
<table> <table>
<tr><th>Cave</th><th>Entrance</th><th>Easting</th><th>Northing</th><th>Lat</th><th>Long</th><th>tag</th><th>tag exact</th><th>tag other</th><th>slug</th></tr> <tr><th>Cave</th><th>Entrance</th><th>best Easting</th><th>best Northing</th><th>GPS Lat</th><th>GPS Long</th><th>tag</th><th>tag exact</th><th>tag other</th><th>slug</th></tr>
{% for ent in ents %} {% for ent in ents %}
<tr> <tr>
<td style="text-align:left"> <td style="text-align:left">
@ -59,6 +59,35 @@ th, td {
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
<p>and now with the locations of the survey stations. All as UTM eatings, norhtings:
<table>
<tr><th>Cave</th><th>best Lat</th><th>best Long</th><th>tag</th><th>tag Lat</th><th>tag Long</th><th>tag exact</th><th>exact Lat</th><th>exact Long</th><th>tag other</th><th>other Lat</th><th>other Long</th></tr>
{% for ent in ents %}
<tr>
<td style="text-align:left">
{% for c in ent.cavelist %}
<a href="/{{c.url}}">
{% if c.official_name %}
{{c.official_name|safe}}
{% else %}
<em>{{c|safe}}</em>
{% endif %}</a><br>
{% endfor %}</td>
<td style="text-align:right">{{ent.lat|floatformat:6}}</td>
<td style="text-align:right">{{ent.long|floatformat:6}}</td>
<td style="text-align:right">{{ent.tag_station}}</td>
<td style="text-align:right">{{ent.tag_ts.lat|floatformat:6}}</td>
<td style="text-align:right">{{ent.tag_ts.long|floatformat:6}}</td>
<td style="text-align:right">{{ent.exact_station}}</td>
<td style="text-align:right">{{ent.tag_es.lat|floatformat:6}}</td>
<td style="text-align:right">{{ent.tag_es.long|floatformat:6}}</td>
<td style="text-align:right">{{ent.other_station}}</td>
<td style="text-align:right">{{ent.tag_os.lat|floatformat:6}}</td>
<td style="text-align:right">{{ent.tag_os.long|floatformat:6}}</td>
</tr>
{% endfor %}
</table>
<p>But the Entrances - the objects in the troggle system - are not properly connected to the dataset which is the combined set of survex data. They are only linked - and only implicitly - by the tag name. The data in the table below is calculated directly from <p>But the Entrances - the objects in the troggle system - are not properly connected to the dataset which is the combined set of survex data. They are only linked - and only implicitly - by the tag name. The data in the table below is calculated directly from
the assemblage of survex files, including fixed point files, and is probably 'correct'. the assemblage of survex files, including fixed point files, and is probably 'correct'.
@ -70,12 +99,15 @@ the assemblage of survex files, including fixed point files, and is probably 'co
<a href="/handbook/survey/coord.htm">Basic Coordinate Systems</a>. <a href="/handbook/survey/coord.htm">Basic Coordinate Systems</a>.
<table cellpadding="6" cellspacing="8"> <table cellpadding="6" cellspacing="8">
<tr><th>Survex Station</th><th>x</th><th>y</th></tr> <tr><th>Survex Station</th><th>x</th><th>y</th><th>lat.</th><th>long.</th></tr>
{% for s in stations %} {% for s in stations %}
<tr> <tr>
<td style="text-align:left; width:240px"> {{s.name|safe}} </td> <td style="text-align:left; width:240px"> {{s.name|safe}} </td>
<td style="text-align:right; width:90px"> {{s.x|floatformat:2}} </td> <td style="text-align:right; width:90px"> {{s.x|floatformat:2}} </td>
<td style="text-align:right; width:90px"> {{s.y|floatformat:2}} </td> <td style="text-align:right; width:90px"> {{s.y|floatformat:2}} </td>
<td style="text-align:right; width:90px"> {{s.lat|floatformat:6}} </td>
<td style="text-align:right; width:90px"> {{s.long|floatformat:6}} </td>
</tr> </tr>
{% empty %} {% empty %}
<td colspan="3"> NO STATION DATA - This is due to survex (cavern) failing on the entire dataset. <td colspan="3"> NO STATION DATA - This is due to survex (cavern) failing on the entire dataset.