ParkKing: Turning Toronto's Parking Bylaws Into a Live Curb Map
The Problem
The City of Toronto publishes parking restrictions as open data, but each one is recorded as descriptive legal prose rather than coordinates:
"A point 59 metres north of Elm Avenue and Spadina Road"
To know whether you can park on a specific curb at 2:30 PM on a Tuesday, you have to parse that text, resolve the street names and intersections against the City's road network, place the rule on the right side of the right block, and reconcile bylaws that overlap. Then it all has to answer in a moment, on a phone, with a weak signal.
What I Built
- Data pipeline. An installable Python package using GeoPandas and Shapely. It parses freeform bylaw text into structured schedules, walks the Toronto Centreline street graph to resolve intersections, projects spans onto physical road-edge polygons, and exports a versioned, hash-pinned SQLite release with a spatial index. The current release carries about 82,000 curb features.
- iPhone app. A native SwiftUI and MapKit app with no third-party dependencies. It opens the bundled database read-only, answers viewport and tap queries through an R-tree index, and evaluates the verdict for the time and length of stay you choose, entirely on the device. It's live on the App Store and free.
- Android app. A Kotlin and Jetpack Compose port of the same verdict engine, in development, with the pure-logic core tested on the JVM.
- Product site. getparkking.com, a static site on Cloudflare Pages with a small Worker for snow-route status.
The Interesting Engineering
1. Legal Prose → Typed Rules
Free-text descriptions vary widely across decades of municipal amendments. An ordered pattern-matching engine classifies them into typed rules. Anything it can't place goes to a failure ledger with the stage and reason, rather than being dropped, so each round of fixes starts from the biggest class of failures.
2. Local Graph-Walking and Curb Projection
The pipeline runs on local copies of the City's street and intersection data instead of calling a geocoding API. It finds the intersecting street nodes, measures metric offsets along the centreline, and projects the span onto the physical curb, falling back to calibrated parallel offsets where the road-edge data is missing.
3. Overlapping Bylaws
A block can carry a rush-hour no-parking rule and a metered-parking rule at once. The pipeline splits overlapping rules into non-overlapping pieces that each remember every rule behind them, so the app can apply precedence without hiding a conflicting restriction.
4. Ticket Data as a Second Source of Truth
Seven years of City parking-ticket data tells me where enforcement and the map disagree. It labels likely paid curbs, sizes TTC stop zones, flags curbs where officers enforce a rule the map doesn't have, and powers an "how often is this block ticketed" estimate. The iPhone app replays real tickets through its own verdict engine to count the cases where it would have wrongly said parking was allowed.
5. One Rule Engine, Several Languages
Schedules involve Ontario statutory holidays, seasonal rules and overnight windows. The logic has to behave the same in Python, Swift and Kotlin, so it's checked against shared fixtures, with golden-file regression tests and CI around the pipeline.
A note on accuracy: ParkKing is a guide, not legal advice. Signs on the street win, and the app says so. The ticket-based checks are how I measure where the map is still wrong.
Key Takeaways
Treating a side project like production software paid off: a failure ledger, golden tests, versioned data releases and a second data source to audit the first. The hardest part wasn't drawing lines on a map. It was making a deterministic, checkable system out of ambiguous legal text.