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

trying to fin dup entrance bug

This commit is contained in:
Philip Sargent 2023-10-18 00:19:17 +03:00
parent de298748e3
commit 1cbbdad1b3

View File

@ -52,29 +52,27 @@ class MapLocations(object):
p = [] p = []
def points(self): def points(self):
prior = len(self.p)
for ent in Entrance.objects.all(): for ent in Entrance.objects.all():
for st, ent_type in {ent.other_station: "other", ent.tag_station: "tag"}.items(): for st, ent_type in {ent.other_station: "other", ent.tag_station: "tag"}.items():
if st != "": if st != "":
self.p.append((st, str(ent), ent.needs_surface_work(), ent)) self.p.append((st, str(ent), ent.needs_surface_work(), ent))
store_data_issues() store_data_issues()
found = len(self.p) - prior message = f" - {len(self.p)} Survey stations found on Entrance objects - not yet validated against survex .pos file."
message = f" - {found} Entrance tags found - not yet validated against survex .pos file."
print(message) print(message)
return self.p return self.p
def __str__(self): def __str__(self):
return f"{len(self.p)} map locations" return f"{len(self.p)} ent locations"
def validate_entrance_stations(ent=None): def validate_entrance_stations(ent=None):
"""Now that we have the located positions, we can check if the Entrances had correct tags """Now that we have the located positions, we can check if the Entrances had correct stations
""" """
bads = 0 bads = 0
good = 0 good = 0
url="/caves" # fallback url="/caves" # fallback
def tag_lower_case(station): def station_lower_case(station):
nonlocal url nonlocal url
so = SurvexStation.objects.filter(name=station.lower()) so = SurvexStation.objects.filter(name=station.lower())
if so.count() == 1: if so.count() == 1:
@ -129,7 +127,7 @@ def validate_entrance_stations(ent=None):
stash_data_issue(parser="positions", message=message, url=url) stash_data_issue(parser="positions", message=message, url=url)
print(message) print(message)
bads +=1 bads +=1
tag_lower_case(st) station_lower_case(st)
continue continue
@ -259,13 +257,19 @@ def LoadPositions():
runcavern3d() runcavern3d()
mappoints = {} mappoints = {}
for pt in MapLocations().points(): found_points = {}
pts = MapLocations().points()
i=0
for pt in pts:
svxid, number, point_type, ent = pt svxid, number, point_type, ent = pt
i += 1
#((st, str(ent), ent.needs_surface_work(), ent)) #((st, str(ent), ent.needs_surface_work(), ent))
if svxid in mappoints:
print(f" = seen this svxid {svxid} for {ent} already on {mappoints[svxid]} item {i}")
else:
mappoints[svxid] = ent mappoints[svxid] = ent
if svxid =="1": if svxid =="1":
print(f"BOGUS {pt}") # this is now checked for when importing the entrance tags in parsers/caves.py print(f"BOGUS {pt}") # this is now checked for when importing the entrance stations in parsers/caves.py
if not Path(pospath).is_file(): if not Path(pospath).is_file():
message = f" ! Failed to find {pospath} so aborting generation of entrance locations. " message = f" ! Failed to find {pospath} so aborting generation of entrance locations. "
@ -296,6 +300,11 @@ def LoadPositions():
for sid in mappoints: for sid in mappoints:
if sbid.endswith(sid) or sbid.endswith(sid.lower()): if sbid.endswith(sid) or sbid.endswith(sid.lower()):
blockpath = "." + sbid[: -len(sid)].strip(".") # only the most recent one that is mappoints blockpath = "." + sbid[: -len(sid)].strip(".") # only the most recent one that is mappoints
if sid in found_points:
found_points[sid] += 1
else:
found_points[sid] = 1
try: try:
ss = SurvexStation(name=sbid) ss = SurvexStation(name=sbid)
ss.x = float(x) ss.x = float(x)
@ -312,7 +321,15 @@ def LoadPositions():
raise raise
validate_entrance_stations() # do not need to use db here really validate_entrance_stations() # do not need to use db here really
positions_filename = Path(pospath).name positions_filename = Path(pospath).name
print(f" - {found-12} SurvexStation entrance tags indentified 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")
# for p in mappoints:
# if p not in found_points:
# print(f"Valid point {p} NOT found in {positions_filename}")
# print(f" - {len(mappoints)} mappoints, {len(found_points)} found_points")
# for sid in found_points:
# if found_points[sid] > 1:
# print(f" - {sid} - {found_points[sid]}")
store_data_issues() store_data_issues()