From 1cbbdad1b3fd43619d0c4b7fed8abdf4d6057340 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 18 Oct 2023 00:19:17 +0300 Subject: [PATCH] trying to fin dup entrance bug --- parsers/locations.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/parsers/locations.py b/parsers/locations.py index 03b1c8a..4745bc6 100644 --- a/parsers/locations.py +++ b/parsers/locations.py @@ -52,29 +52,27 @@ class MapLocations(object): p = [] def points(self): - prior = len(self.p) for ent in Entrance.objects.all(): for st, ent_type in {ent.other_station: "other", ent.tag_station: "tag"}.items(): if st != "": 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." + message = f" - {len(self.p)} Survey stations found on Entrance objects - not yet validated against survex .pos file." print(message) return self.p def __str__(self): - return f"{len(self.p)} map locations" + return f"{len(self.p)} ent locations" 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 good = 0 url="/caves" # fallback - def tag_lower_case(station): + def station_lower_case(station): nonlocal url so = SurvexStation.objects.filter(name=station.lower()) if so.count() == 1: @@ -129,7 +127,7 @@ def validate_entrance_stations(ent=None): stash_data_issue(parser="positions", message=message, url=url) print(message) bads +=1 - tag_lower_case(st) + station_lower_case(st) continue @@ -259,13 +257,19 @@ def LoadPositions(): runcavern3d() mappoints = {} - for pt in MapLocations().points(): + found_points = {} + pts = MapLocations().points() + i=0 + for pt in pts: svxid, number, point_type, ent = pt + i += 1 #((st, str(ent), ent.needs_surface_work(), ent)) - - mappoints[svxid] = ent + if svxid in mappoints: + print(f" = seen this svxid {svxid} for {ent} already on {mappoints[svxid]} item {i}") + else: + mappoints[svxid] = ent 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(): message = f" ! Failed to find {pospath} so aborting generation of entrance locations. " @@ -296,6 +300,11 @@ def LoadPositions(): for sid in mappoints: if sbid.endswith(sid) or sbid.endswith(sid.lower()): 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: ss = SurvexStation(name=sbid) ss.x = float(x) @@ -312,7 +321,15 @@ def LoadPositions(): raise validate_entrance_stations() # do not need to use db here really 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: 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()