2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

x/y distances between explicit data and survey points

This commit is contained in:
Philip Sargent 2023-10-11 01:03:28 +03:00
parent 973f9bedd5
commit d6a3006444
6 changed files with 105 additions and 60 deletions

View File

@ -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):

View File

@ -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",)

View File

@ -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)
ents = set()
gpsents = set()
for e in ents:
def add_stations(e):
try:
ts = e.tag_station
if ts:
@ -307,9 +303,38 @@ def eastings(request):
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)
return render(request, "eastings.html", {"ents": ents, "stations": stations})
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, "gpsents": gpsents, "stations": stations})
def aliases(request, year):

View File

@ -34,7 +34,7 @@ class MapLocations(object):
We don't need these map locations any more ?!
They would only be used in addition to entrances going onto a map display"""
p = [
fp = [
("laser.0_7", "BNase", "Reference", "Br&auml;uning Nase laser point"),
("226-96", "BZkn", "Reference", "Br&auml;uning Zinken trig point"),
("vd1", "VD1", "Reference", "VD1 survey point"),
@ -49,12 +49,14 @@ class MapLocations(object):
("225-96", "BAlm", "Reference", "Br&auml;uning Alm trig point"),
] # 12 fixed points
p = []
def points(self):
prior = len(self.p)
for ent in Entrance.objects.all():
for st, ent_type in {ent.exact_station: "exact", ent.other_station: "other", ent.tag_station: "tag"}.items():
if st != "":
self.p.append((st, str(ent), ent.needs_surface_work(), str(ent)))
self.p.append((st, str(ent), ent.needs_surface_work(), ent))
store_data_issues()
found = len(self.p) - prior
message = f" - {found} Entrance tags found - not yet validated against survex .pos file."
@ -70,9 +72,10 @@ def validate_entrance_stations(ent=None):
"""
bads = 0
good = 0
url="/caves" # fallback
def tag_lower_case(station):
nonlocal url
so = SurvexStation.objects.filter(name=station.lower())
if so.count() == 1:
message = f"X - Entrance {ent} station '{station}' should be '{station.lower()}'"
@ -104,23 +107,6 @@ def validate_entrance_stations(ent=None):
continue
try:
so = SurvexStation.objects.filter(name=st)
if so.count() == 1:
good +=1
# print(f"OK - Entrance {ent} '{ent_type}' station '{st}'")
continue
if so.count() != 0:
message =f"{so.count()} found for Entrance {ent} '{ent_type}' station '{st}' {so}"
else:
message = f" ! - Entrance {ent} has invalid '{ent_type}' station '{st}'"
if st == ent.best_station():
message = message + " - AND THIS IS THE 'BEST' ONE"
else:
message = message + " - not the 'best'"
stash_data_issue(parser="positions", message=message, url=url)
print(message)
bads +=1
tag_lower_case(st)
continue
except:
message = f" ! - Entrance {ent} has invalid '{ent_type}' station '{st}'. EXCEPTION."
stash_data_issue(parser="positions", message=message, url=url)
@ -128,6 +114,25 @@ def validate_entrance_stations(ent=None):
bads +=1
continue
if so.count() == 1:
good +=1
# print(f"OK - Entrance {ent} '{ent_type}' station '{st}'")
continue
if so.count() != 0:
message =f"{so.count()} found for Entrance {ent} '{ent_type}' station '{st}' {so}"
else:
message = f" ! - Entrance {ent} has invalid '{ent_type}' station '{st}'"
if st == ent.best_station():
message = message + " - AND THIS IS THE 'BEST' ONE"
else:
message = message + " - not the 'best'"
stash_data_issue(parser="positions", message=message, url=url)
print(message)
bads +=1
tag_lower_case(st)
continue
if ent:
return validate_ent(ent)
@ -255,8 +260,10 @@ def LoadPositions():
mappoints = {}
for pt in MapLocations().points():
svxid, number, point_type, label = pt
mappoints[svxid] = True
svxid, number, point_type, ent = pt
#((st, str(ent), ent.needs_surface_work(), ent))
mappoints[svxid] = ent
if svxid =="1":
print(f"BOGUS {pt}") # this is now checked for when importing the entrance tags in parsers/caves.py
@ -294,6 +301,7 @@ def LoadPositions():
ss.x = float(x)
ss.y = float(y)
ss.z = float(z)
ss.entrance = mappoints[sid]
ss.save()
found += 1
except:

View File

@ -175,7 +175,7 @@
<dt>Explorers</dt><dd>{{ ent.entrance.explorers|safe }}</dd>
{% endif %}
{% if ent.entrance.northing %}
<dt>Location</dt><dd>UTM33 Northing: {{ ent.entrance.northing|safe }}, Easting: {{ ent.entrance.easting|safe }}, {{ ent.entrance.alt|safe }}m</dd>
<dt>Location</dt><dd> Northing: {{ ent.entrance.northing|safe }}, Easting: {{ ent.entrance.easting|safe }} (UTM or BMN, depending...), {{ ent.entrance.alt|safe }}m</dd>
{% endif %}
{% if ent.entrance.lat_wgs84 %}
<dt>Location</dt><dd><a href="https://www.openstreetmap.org/?mlat={{ ent.entrance.lat_wgs84|floatformat:7}}&mlon={{ent.entrance.long_wgs84|floatformat:7}}">WGS84 Lat.: {{ ent.entrance.lat_wgs84|floatformat:7 }} N, Long.:{{ ent.entrance.long_wgs84|floatformat:7 }} E</a></dd>

View File

@ -27,15 +27,25 @@ Coordinate systems in Austria are explained in:<br>
<p>The Lat. Long. coordinates are manually entered using a phone or a hand-held GPS device at (or near) the entrance.
<p>For the Cave column, if there is an official cave name, then it is shown.
Otherwise whatever other name we can find for it is shown <em>in italics</em>.
For the Entrance column, if the entrance has a name (e.g. Gr&uuml;ner Eingang in Schwarzmooskogeleish&ouml;hle) then it is shown.
Otherwise it says "Anon:" followed by whatever other name we can find for it, usually the entrance id slug, <em>in italics</em>.
<style>
th, td {
padding-left: 5px;
padding-right: 5px;
</style>
<table>
<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>
<p>OK now for the nasty bit. Many of the older caves did not have easting & northing in UTM 33T at all, but (probably) in BMN and converting between BMN into UTM requires ellipsoids and bessel functions.. or we can just take a linear approximation, which is what I have done here:<br>
e.northingUTM = e.northingBMN + 5198919.918<br>
e.eastingUTM = e.easting + 374854.63<br>
Such converted eastings and northings are <em>in italics</em> in the table below. As you can see, some were wildly out.
<p>These magic numbers simply come from assuming that both BMN and UTM are in metres, and linear over our area, and then taking the avergage of the offsets for 5 locations, the 5 cave entrances at the bottom of this page:
<a href="http://localhost:8000/handbook/survey/coord.htm#summary">Olaf's Coordinates</a>.
<p>This horrible approximation is accruate to ~8m in the northing and ~30m in the easting.
<table>BMN
<tr><th>Cave</th><th>Entrance slug</th><th>Easting</th><th>Northing</th><th>best tag easting</th><th>best tag northing</th>
<th>&Delta; x</th>
<th>&Delta; y</th>
<th>Distance (m)</th></tr>
{% for ent in ents %}
<tr>
<td style="text-align:left">
@ -47,28 +57,24 @@ th, td {
<em>{{c|safe}}</em>
{% endif %}</a><br>
{% endfor %}</td>
<td style="text-align:left">
{% if ent.name %}
{{ent.name|safe}}
{% else %}
Anon: <em>{{ent|safe}}</em>
{% endif %}
</td>
<td style="text-align:right">{{ent.easting|floatformat:2}}</td>
<td style="text-align:right">{{ent.northing|floatformat:2}}</td>
<td style="text-align:right">{{ent.lat_wgs84|floatformat:6}}</td>
<td style="text-align:right">{{ent.long_wgs84|floatformat:6}}</td>
<td style="text-align:right">{{ent.tag_station}}</td>
<td style="text-align:right">{{ent.exact_station}}</td>
<td style="text-align:right">{{ent.other_station}}</td>
<td style="text-align:right">{{ent.slug}}</td>
<td style="text-align:right; {% if ent.bmn %}font-style: italic{% endif %}">{{ent.easting|floatformat:2}}</td>
<td style="text-align:right; {% if ent.bmn %}font-style: italic{% endif %}">{{ent.northing|floatformat:2}}</td>
<td style="text-align:right">{{ent.best_station_object.x|floatformat:2}}</td>
<td style="text-align:right">{{ent.best_station_object.y|floatformat:2}}</td>
<td style="text-align:right; {% if ent.bmn %}font-style: italic{% endif %}">{{ent.diffx|floatformat:0}}</td>
<td style="text-align:right; {% if ent.bmn %}font-style: italic{% endif %}">{{ent.diffy|floatformat:0}}</td>
<td style="text-align:right; {% if ent.bmn %}font-style: italic{% endif %}">{{ent.error|floatformat:0}}</td>
</tr>
{% endfor %}
</table>
<p>and now with the locations of the survey stations. All as UTM eatings, norhtings:
<p>and now the GPS equivalents:
<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><th>Cave</th><th>GPS Lat</th><th>GPS Long</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 gpsents %}
<tr>
<td style="text-align:left">
{% for c in ent.cavelist %}
@ -80,6 +86,8 @@ th, td {
{% endif %}</a><br>
{% endfor %}</td>
<td style="text-align:right">{{ent.lat_wgs84|floatformat:6}}</td>
<td style="text-align:right">{{ent.long_wgs84|floatformat:6}}</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>
@ -104,8 +112,9 @@ the assemblage of survex files, including fixed point files, and is probably 'co
<a href="/handbook/survey/coord2.html">GPS and coordinate systems</a><br>
<a href="/handbook/survey/coord.htm">Basic Coordinate Systems</a>.
<p>This next table is of all the survex stations in troggle: i.e. only those survey stations which have been identified with an Entrance by manually editing the Entrance data.
<table cellpadding="6" cellspacing="8">
<tr><th>Survex Station</th><th>x</th><th>y</th><th>lat.</th><th>long.</th></tr>
<tr><th>Survex Station</th><th>x</th><th>y</th><th>lat.</th><th>long.</th><th>Used on ent</th></tr>
{% for s in stations %}
<tr>
<td style="text-align:left; width:240px"> {{s.name|safe}} </td>
@ -113,7 +122,7 @@ the assemblage of survex files, including fixed point files, and is probably 'co
<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>
<td style="text-align:right;" > {{s.entrance|safe}} </td>
</tr>
{% empty %}
<td colspan="3"> NO STATION DATA - This is due to survex (cavern) failing on the entire dataset.