aboutsummaryrefslogtreecommitdiff
path: root/src/gtfs_vigo_stops
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-11-30 19:17:02 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-11-30 19:17:02 +0100
commitcee521142a4e0673b155d97c3e4825b7fec1987f (patch)
treee8030687f62a63c34ad69cb81eefe8470c55cfee /src/gtfs_vigo_stops
parente7283ba10d45b42e1274cd13c3d6aabec57c85b4 (diff)
Refactor street name processing and remove unused stop downloader script
- Updated `street_name.py` to simplify street name handling by removing the `re_remove_street_type` regex and exception streets list, replacing them with a dictionary for name replacements. - Deleted the `download-stops.py` script from the Santiago stop downloader, which was no longer needed. - Removed the empty `.gitkeep` file from the overrides directory. - Added a new `VigoController` class to handle stop estimates and timetables, including error handling for missing data. - Introduced `LineFormatterService` to format circulation routes based on specific line conditions.
Diffstat (limited to 'src/gtfs_vigo_stops')
-rw-r--r--src/gtfs_vigo_stops/src/street_name.py31
1 files changed, 10 insertions, 21 deletions
diff --git a/src/gtfs_vigo_stops/src/street_name.py b/src/gtfs_vigo_stops/src/street_name.py
index 4bfbdba..f77e8a6 100644
--- a/src/gtfs_vigo_stops/src/street_name.py
+++ b/src/gtfs_vigo_stops/src/street_name.py
@@ -4,24 +4,13 @@ import re
re_remove_quotation_marks = re.compile(r'[""”]', re.IGNORECASE)
re_anything_before_stopcharacters_with_parentheses = re.compile(
r'^(.*?)(?:,|\s\s|\s-\s| \d| S\/N|\s\()', re.IGNORECASE)
-re_remove_street_type = re.compile(
- r'^(?:Rúa|Avda\.?|Avenida|Camiño|Estrada)(?:\s+d[aeo]s?)?\s*', re.IGNORECASE)
-exception_streets = [
- "Avda. do Aeroporto",
- "Avda. de Samil",
- "Avda. de Castrelos",
- "Estrada da Garrida",
- "Estrada de Valadares",
- "Estrada do Monte Alba",
- "Estrada da Gándara",
- "Estrada do Vao",
- "Avda. do Tranvía",
- "Avda. da Atlántida",
- "Avda. da Ponte",
- "Rúa da Cruz",
- "Estrada das Prantas"
-]
+
+NAME_REPLACEMENTS = {
+ "Rúa da Salguera Entrada": "Rúa da Salgueira",
+ "Rúa da Salgueira Entrada": "Rúa da Salgueira",
+ "Estrada de Miraflores": "Estrada Miraflores",
+}
def get_street_name(original_name: str) -> str:
@@ -34,14 +23,14 @@ def get_street_name(original_name: str) -> str:
else:
street_name = original_name
- if street_name in exception_streets:
- return street_name
+ for old_name, new_name in NAME_REPLACEMENTS.items():
+ if old_name.lower() in street_name.lower():
+ street_name = street_name.replace(old_name, new_name)
- street_name = re.sub(re_remove_street_type, '', street_name).strip()
return street_name
-def normalise_stop_name(original_name: str|None) -> str:
+def normalise_stop_name(original_name: str | None) -> str:
if original_name is None:
return ''
stop_name = re.sub(re_remove_quotation_marks, '', original_name).strip()