claude fixes to too-few matches

This commit is contained in:
zyphlar
2026-02-25 10:25:48 -08:00
parent 69818eecba
commit 6bb0902faa
+35 -5
View File
@@ -387,12 +387,28 @@ out geom;"""
osm_point = osm_row.geometry
distance = local_point.distance(osm_point)
# Additional verification: check if house numbers match (handle type differences)
# Verify house number, street, and unit (if present) match
local_house_num = str(local_row.get('addr:housenumber', ''))
osm_house_num = str(osm_row.get('addr:housenumber', ''))
# Only consider as potential match if house numbers match
if local_house_num == osm_house_num and distance < min_distance:
# Check street name match (required)
local_street = str(local_row.get('addr:street', '')).strip().lower()
osm_street = str(osm_row.get('addr:street', '')).strip().lower()
street_match = (local_street == osm_street and local_street != '' and local_street != 'nan')
# Check unit match (only if both have units specified)
local_unit = local_row.get('addr:unit')
osm_unit = osm_row.get('addr:unit')
# Unit matches if: (1) both are None/null, OR (2) both have values and they're equal
unit_match = True
if local_unit is not None and pd.notna(local_unit) and osm_unit is not None and pd.notna(osm_unit):
# Both have units - they must match
unit_match = (str(local_unit).strip().lower() == str(osm_unit).strip().lower())
# Only consider as potential match if house numbers, street, and unit all match
if (local_house_num == osm_house_num and
street_match and unit_match and
distance < min_distance):
min_distance = distance
best_match = osm_idx
@@ -436,12 +452,26 @@ out geom;"""
osm_point = osm_row.geometry
distance_meters = local_point.distance(osm_point) * 111000.0
# Check if house numbers match (handle type differences)
# Verify house number, street, and unit (if present) match
local_house_num = str(local_row.get('addr:housenumber', ''))
osm_house_num = str(osm_row.get('addr:housenumber', ''))
# Check street name match (required)
local_street = str(local_row.get('addr:street', '')).strip().lower()
osm_street = str(osm_row.get('addr:street', '')).strip().lower()
street_match = (local_street == osm_street and local_street != '' and local_street != 'nan')
# Check unit match (only if both have units specified)
local_unit = local_row.get('addr:unit')
osm_unit = osm_row.get('addr:unit')
unit_match = True
if local_unit is not None and pd.notna(local_unit) and osm_unit is not None and pd.notna(osm_unit):
# Both have units - they must match
unit_match = (str(local_unit).strip().lower() == str(osm_unit).strip().lower())
if (distance_meters <= self.tolerance_meters and
local_house_num == osm_house_num):
local_house_num == osm_house_num and
street_match and unit_match):
matched_osm_indices.add(osm_idx)
break # Only match to first OSM address found