Update threaded script, try to reduce multipolygons in geojson
This commit is contained in:
12
threaded.py
12
threaded.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user