1
0
Fork 0

fix bunch of bugs

This commit is contained in:
Mateusz Konieczny 2025-02-26 18:42:53 +01:00
parent 905986985c
commit 016747f3c3

View file

@ -208,20 +208,20 @@ def process_single_dataset(checked_data_sources, atp_code, area):
for entry in entries:
links_per_osm_object[entry.osm_link] += 1
apparently_importable = defaultdict(dict)
apparently_importable = defaultdict(list)
for entry in entries:
if entry.osm_link in skipped_osm_cases():
continue
match_judgment = thorough_match_mismatch_check(entry)
if links_per_osm_object[entry.osm_link] != 1:
for extracted in checked_data_sources:
match_judgment = {'status': 'it_is_not_matching', 'mismatching_key_list': 'multiple ATP matched to ' + entry.osm_link}
extracted['data'].append(entry_to_presentation_object(extracted['key'], entry, match_judgment))
if entry.osm_link == None:
match_judgment = {'status': 'it_is_not_matching', 'mismatching_key_list': ['no match found in OSM']}
extracted['data'].append(entry_to_presentation_object(extracted['key'], entry, match_judgment))
continue
if match_judgment == None:
# complete failure of matching
# silently skip such cases
match_judgment = thorough_match_mismatch_check(entry)
if links_per_osm_object[entry.osm_link] > 1:
for extracted in checked_data_sources:
match_judgment = {'status': 'it_is_not_matching', 'mismatching_key_list': ['multiple ATP matched to ' + entry.osm_link]}
extracted['data'].append(entry_to_presentation_object(extracted['key'], entry, match_judgment))
continue
for extracted in checked_data_sources:
if match_judgment['status'] != 'matching':
@ -234,7 +234,11 @@ def process_single_dataset(checked_data_sources, atp_code, area):
import_judgment = adjust_judgment_for_address_location_mismatch_checked_by_nominatim(entry, import_judgment)
extracted['data'].append(entry_to_presentation_object(extracted['key'], entry, import_judgment))
apparently_importable[extracted['key']].append(entry)
write_output_data(atp_code, checked_data_sources, apparently_importable, header_of_presentation_objects)
def write_output_data(atp_code, checked_data_sources, apparently_importable, header_of_presentation_objects):
for extracted in checked_data_sources:
filename = extracted['output_filename_for_html']
location = config.output_folder() + filename
@ -286,14 +290,19 @@ def entry_to_presentation_object(checked_key, entry, judgment):
atp_key = checked_key
if checked_key == "opening_hours":
atp_key = config.opening_hours_key()
checked_key_value_in_osm = None
osm_match_tags_as_html_list = ""
if entry.osm_match_tags != None:
checked_key_value_in_osm = entry.osm_match_tags.get(checked_key, "")
osm_match_tags_as_html_list = show_data.tag_list_to_html(entry.osm_match_tags, atp_tag_list=False)
return {
'columns': [
{'type': 'link', 'value': {'text': 'ATP map', 'url': shared.link_to_point_in_atp(lat=entry.atp_center['lat'], lon=entry.atp_center['lon'], zoom_level=20)}},
{'type': 'link', 'value': {'text': 'OSM object', 'url': entry.osm_link}},
{'type': 'text', 'value': entry.atp_tags.get(atp_key, "")},
{'type': 'text', 'value': entry.osm_match_tags.get(checked_key, "")},
{'type': 'text', 'value': checked_key_value_in_osm},
{'type': 'text', 'value': show_data.tag_list_to_html(entry.atp_tags, atp_tag_list=True)},
{'type': 'text', 'value': show_data.tag_list_to_html(entry.osm_match_tags, atp_tag_list=False)},
{'type': 'text', 'value': osm_match_tags_as_html_list},
{'type': 'text', 'value': ", ".join(judgment.get('mismatching_key_list', ""))},
],
'display_type': row_type