AI Driver Testing Center Locator Script
Generate a complete, deployable Python script that locates and maps Canadian DMV testing centers with real-time data integration.
You are an expert Python developer specializing in geospatial applications and government data integration. Your task is to create a complete, production-ready Python script for locating Canadian driver testing centers (DMV equivalents). ## SCRIPT REQUIREMENTS ### Core Functionality 1. **Data Sources**: Integrate with official provincial/territorial APIs where available: - Ontario: ServiceOntario locations API - British Columbia: ICBC office locator - Alberta: Alberta Registry services - Quebec: SAAQ service outlets - Federal/Other: Use OpenStreetMap + web scraping with proper attribution 2. **Geocoding & Distance Calculation** - Accept user input: [USER_ADDRESS] or [POSTAL_CODE] or [LATITUDE,LONGITUDE] - Use geopy/Nominatim for address geocoding - Calculate driving distance (not just straight-line) using OSRM or similar - Return results sorted by [SORT_PREFERENCE: distance|wait_time|availability|rating] 3. **Testing Center Data Fields** - Name, address, phone, hours of operation - Services offered: [SERVICE_TYPES] (G1/G2/G, motorcycle, commercial, air brake, etc.) - Real-time availability: appointment slots, walk-in wait times (scrape or API) - Accessibility features, languages supported 4. **Output Formats** - Console: Rich-formatted table with color coding - JSON: Machine-readable for API consumption - CSV: Export for spreadsheet analysis - HTML/Map: Folium-generated interactive map with markers and popups ### Code Quality Standards - Type hints throughout (Python 3.9+) - Comprehensive error handling with custom exceptions - Async/await for all I/O operations (aiohttp, aiogeopy) - Rate limiting and respectful scraping (robots.txt compliance) - Caching layer (diskcache or redis) for geocoding and static data - Configuration via environment variables or YAML - Logging with structured output (structlog) - Unit tests with pytest and mocked external APIs ### Security & Compliance - No hardcoded API keys; use key rotation - Input sanitization for SQL injection prevention (if using SQLite) - PIPEDA-compliant data handling - Clear attribution for all data sources ## DELIVERABLES Provide: 1. Complete, runnable `dmv_locator.py` with all dependencies in `requirements.txt` 2. `config.yaml` template with all configurable options documented 3. `README.md` with installation, usage examples, and API key setup 4. Sample output for a query: [SAMPLE_QUERY: "M5V 3A8, G2 test, within 25km, sort by wait time"] ## CONSTRAINTS - Target Python 3.10+ - No paid API dependencies required for basic functionality - Total script should be <2000 lines (modularize if needed) - Execution time for cached query: <2 seconds
You are an expert Python developer specializing in geospatial applications and government data integration. Your task is to create a complete, production-ready Python script for locating Canadian driver testing centers (DMV equivalents). ## SCRIPT REQUIREMENTS ### Core Functionality 1. **Data Sources**: Integrate with official provincial/territorial APIs where available: - Ontario: ServiceOntario locations API - British Columbia: ICBC office locator - Alberta: Alberta Registry services - Quebec: SAAQ service outlets - Federal/Other: Use OpenStreetMap + web scraping with proper attribution 2. **Geocoding & Distance Calculation** - Accept user input: [USER_ADDRESS] or [POSTAL_CODE] or [LATITUDE,LONGITUDE] - Use geopy/Nominatim for address geocoding - Calculate driving distance (not just straight-line) using OSRM or similar - Return results sorted by [SORT_PREFERENCE: distance|wait_time|availability|rating] 3. **Testing Center Data Fields** - Name, address, phone, hours of operation - Services offered: [SERVICE_TYPES] (G1/G2/G, motorcycle, commercial, air brake, etc.) - Real-time availability: appointment slots, walk-in wait times (scrape or API) - Accessibility features, languages supported 4. **Output Formats** - Console: Rich-formatted table with color coding - JSON: Machine-readable for API consumption - CSV: Export for spreadsheet analysis - HTML/Map: Folium-generated interactive map with markers and popups ### Code Quality Standards - Type hints throughout (Python 3.9+) - Comprehensive error handling with custom exceptions - Async/await for all I/O operations (aiohttp, aiogeopy) - Rate limiting and respectful scraping (robots.txt compliance) - Caching layer (diskcache or redis) for geocoding and static data - Configuration via environment variables or YAML - Logging with structured output (structlog) - Unit tests with pytest and mocked external APIs ### Security & Compliance - No hardcoded API keys; use key rotation - Input sanitization for SQL injection prevention (if using SQLite) - PIPEDA-compliant data handling - Clear attribution for all data sources ## DELIVERABLES Provide: 1. Complete, runnable `dmv_locator.py` with all dependencies in `requirements.txt` 2. `config.yaml` template with all configurable options documented 3. `README.md` with installation, usage examples, and API key setup 4. Sample output for a query: [SAMPLE_QUERY: "M5V 3A8, G2 test, within 25km, sort by wait time"] ## CONSTRAINTS - Target Python 3.10+ - No paid API dependencies required for basic functionality - Total script should be <2000 lines (modularize if needed) - Execution time for cached query: <2 seconds
More Like This
Back to LibraryCanadian Autonomous Vehicle Safety Standards & Compliance Guide Generator
This prompt helps automotive engineers, compliance officers, and policy makers create detailed safety standard documentation that aligns with Transport Canada regulations, provincial Highway Traffic Acts, and SAE automation levels. It ensures coverage of unique Canadian requirements including bilingual interfaces, metric specifications, and extreme cold-weather operational standards.
AI Commercial Vehicle Inspection Schedule Generator - Canada
This prompt creates comprehensive commercial vehicle inspection schedules that comply with Canada's National Safety Code and specific provincial regulations. It generates actionable calendars, checklists, and compliance tracking matrices for fleets of any size, ensuring adherence to mandatory periodic inspections, daily pre-trip requirements, and documentation standards.
AI Driver Training Program Designer for Canadian DMVs
This prompt helps DMV officials, driving school administrators, and curriculum developers create structured driver training programs that align with Canadian Motor Vehicle Acts, graduated licensing systems, and evidence-based safety education. It generates detailed lesson plans, assessment frameworks, and compliance documentation.