Update threaded script, try to reduce multipolygons in geojson

This commit is contained in:
2025-06-28 23:59:35 -07:00
parent 693c40302d
commit a1521f4a47
2 changed files with 104 additions and 3 deletions

View File

@@ -32,6 +32,13 @@ qgisfunctions = importlib.import_module("qgis-functions")
# Suppress warnings for cleaner output
warnings.filterwarnings('ignore')
import re
def titlecase(s):
return re.sub(
r"[A-Za-z]+('[A-Za-z]+)?",
lambda word: word.group(0).capitalize(),
s)
class RoadComparator:
def __init__(self, tolerance_feet: float = 50.0, min_gap_length_feet: float = 100.0,
n_jobs: int = None, chunk_size: int = 1000):
@@ -308,11 +315,9 @@ class RoadComparator:
'surface': 'asphalt'
}
print("Added: "+properties['name'])
for key, value in original_properties.items():
if key == 'NAME':
properties['name'] = qgisfunctions.formatstreet(str(value)).title() if value is not None else None
properties['name'] = titlecase(qgisfunctions.formatstreet(value,None,None)) if value is not None else None
elif key == 'SpeedLimit':
properties['maxspeed'] = f"{value} mph" if value is not None else None
elif key == 'RoadClass':
@@ -333,6 +338,7 @@ class RoadComparator:
})
except Exception as e:
print(e)
continue # Skip problematic geometries
return added_roads