UnionZoneCalc is a simple Python CLI tool that calculates union work zones based on the distance from a City Hall or other landmark. The initial poof of concept version usese the Toronto City Hall and the distances from Local 30 Roofing map.
It uses the Google Geocoding API to convert addresses into coordinates and applies predefined distance rules to determine the correct zone.
- Convert address β coordinates using Google API
- Calculate distance from Toronto City Hall
- Automatically assign zone:
- Zone 1: 0β20 km
- Zone 3: 20β50 km
- Zone 4: 50β80 km
- Zone 5: 80β95 km
- Special case handling:
- Toronto Islands (manual Zone 2 check)
- Locations south of Lake Ontario β Room & Board
- CLI input or interactive prompt
git clone https://github.com/yourusername/unionzone.git
cd unionzonepip install requests
Create a file named config.cfg:
[google] api_key=YOUR_API_KEY_HERE
python zone_calculator.py "185 Conestoga Dr, Brampton"python zone_calculator.py
If the distance is between 2.2 km and 3.4 km, verify manually if the address is on the Toronto Islands.
If the location is south of the lake, it should be considered:
Room & Board
unionzone/
β
βββ zone_calculator.py
βββ config.cfg # NOT committed (contains API key)
βββ .gitignore
βββ README.md
Your API key is stored locally in config.cfg and is excluded from version control using .gitignore.
C:\Repo\UnionZoneCalc> python.exe .\zone_calculator.py
Enter address: 185 Conestoga Drive, Brampton
--- RESULT ---
Address: 185 Conestoga Dr, Brampton, ON L6Z 2Z7, Canada
Coordinates: 43.7233218, -79.7906296
Distance from City Hall: 33.60 km
Zone: Zone 3
- Web interface (Flask/FastAPI)
- Map visualization (? Maybe)
- Batch processing (CSV input)
- More precise geographic rules (GIS polygons TBD)
- Generate PDF Instructions on how to use the app
You can package the app into a standalone .exe so users donβt need Python installed.
pip install pyinstaller
If you have multiple Python versions, use:
python -m pip install pyinstaller
python -m PyInstaller --onefile zone_calculator.py
Optional (with custom icon):
python -m PyInstaller --onefile --icon=app.ico zone_calculator.py
Optional (custom name):
python -m PyInstaller --onefile --name UnionZoneCalc zone_calculator.py
After building, the executable will be located in:
dist/zone_calculator.exe
Or (if using custom name):
dist/UnionZoneCalc.exe
- The file
config.cfgmust be in the same folder as the.exe - First run may be slightly slower (normal for PyInstaller)
- Windows Defender may show a warning for unsigned executables (common for internal tools)
Run with address parameter:
UnionZoneCalc.exe "185 Conestoga Dr, Brampton"
Or run without parameters for interactive mode:
UnionZoneCalc.exe
Luciano Peixoto