Skip to content
This repository has been archived by the owner on Jun 19, 2018. It is now read-only.

How Does It Work?

mudar edited this page Nov 7, 2012 · 3 revisions

Technical explanation of using The City's Open Data to build Park Catcher / Capteur de stationnement.

##The Open Data

“Open data is data that can be freely used, reused and redistributed by anyone – subject only, at most, to the requirement to attribute and sharealike.” OpenDefinition.org

###Montréal's Parking Open Data

In September 2012, the City of Montréal published on its Open Data Portal the on-street parking and street panels data-set. This information is available in KMZ and JSON formats.

The KMZ files, grouped by borough, are very useful for quick visualization of all street panels using tools such as Google Earth. The information includes parking, toponymy, touristic, parks, pedestrian, bus information and generally all kinds of panels.

The JSON files, grouped by panel type, are more useful for developers to build maps presenting the geo-locations of these panels. Park Catcher uses the on-street and paid parking data-sets.

####Examples

KMZ file viewed using Google Earth:
Google Earth screen capture

JSON data excerpt:

{
    "name": "STATIONNEMENT",
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -73.5121123406351,
                    45.607406741031
                ]
            },
            "properties": {
                "DESCRIPTION_REP": "En conception",
                "DESCRIPTION_RTP": "1- Tige et base",
                "DESCRIPTION_CAT": "STATIONNEMENT",
                "FLECHE_PAN": 0,
                "DATE_CONCEPTION_POT": "20120802000000",
                "POTEAU_ID_POT": 69775,
                "DESCRIPTION_RPA": "\\\\P 08h30-11h30 MARDI 1 AVRIL AU 1 DEC.",
                "Longitude": -73.5121123406351,
                "POTEAU_VERSION_POT": 5,
                "PANNEAU_ID_RPA": 14318,
                "CODE_RPA": "SU-AC-A",
                "X": 303855.219,
                "Y": 5051945,
                "Latitude": 45.607406741031,
                "PANNEAU_ID_PAN": 902244
            }
        }
    ]
}

##Processing The Data

The on-street parking JSON file provides more than 115,000 entries.

  • Each entry represents a unique street panel.
  • Each panel is associated with the street post carrying it and with the code of the parking rule printed on it.
  • Each post has its latitude and longitude geo-coordinates allowing to place it on the map.
  • Each panel code contains a unique parking rule, written in French.

###Data Structure Using the original data which is based on panels, Park Catcher builds the following hierarchical information structure:

  • Posts
    {id_post, latitude, longitude, version}
  • Panels
    {id_panel, id_post, id_panel_code, arrow}
  • Panels Codes
    {id_panel_code, code, text_description, category}
  • Panels Codes Rules
    {id_panel_code, hour_start, hour_end, day_start, day_end, season_start, season_end, vehicle_type}

In the original data-set, a post that carries two panels would be included in two entries. Same wise, text description of two identical panels on two different posts would be included twice. The new structure cleans this redundancy by defining relations between unique elements.

##Let the fun begin! The major job is to make a searchable data out of the panels text description, by translating the panels text description into usable time data (days, hours, calendar).

This can be done with a parser or manually.

###Parser Building a parser would usually be the recommended solution: loop through entries and convert text information into usable time data.
Example:

// Input
{ "SU-AC-A" : "\\P 08h30-11h30 MARDI 1 AVRIL AU 1 DEC." }
// English translation!
{ "SU-AC-A" : "\\P 08:30-11:30 TUESDAY APRIL 1 TO DEC 1." }
// Output
{
    "id_panel_code": "SU-AC-A", 
    "hour_start":"8.5" , 
    "hour_end" : "11.5", 
    "day_start" : "tuesday", 
    "day_end" : "tuesday", 
    "season_start" : "2012-04-01", 
    "season_end" : "2012-12-01", 
    "vehicle_type":"all"
}

However, text descriptions carry many variations. Different boroughs may have the same information as:

  • "\P 08:30-11:30 TUESDAY TO THURSDAY APRIL 1 TO DEC 1."
  • "08:30-11:30 TUESDAY TO THURSDAY APRIL 1 TO DEC 1."
  • "\P 08:30-11:30 TUESDAY THURSDAY APRIL 1 TO DEC 1."
  • "\P 08:30-11:30 TUESDAY TILL THURSDAY APRIL 1 TO DEC 1."
  • "\P 08:30-11:30 TUES TO THU APRIL 1 TO DEC 1."
  • "\P 08:30-11:30 TUES WED THU APRIL 1 TO DEC 1."
  • "\P 08:30 TO 11:30 TUESDAY TO THURSDAY APRIL 1 TO DEC 1."
  • "\P 08:30-11:30 TUESDAY TO THURSDAY APRIL 1 TO DECEMBER 1."
  • "\P 08:30-11:30 TUESDAY TO THURSDAY APRIL TO NOV."
  • "\P MAX 3 HOURS 08:30-11:30 TUESDAY TO THURSDAY APRIL 1 TO DEC 1."

These variations can still be handled, but more complex panels would require too many exceptions to allow building a clean algorithm.

Conclusion: Too complicated, result not guaranteed, job must be done manually!

###Manually Park Catcher's database contains more than 1,700 panel codes. So going through each line, we add 0/1 to columns that would allow building a time-related database table. This tedious job seems to be the right way to go to convert the wide variation of complex on-street parking panels.

Example of the manual translation:

Description Time Start Time End Mon Tues Wed Thurs Fri Sat Sun Daily
\P 07h-09h LUNDI JEUDI 1 MARS AU 1 DEC. 7 9 1

1



\P 07h-09h LUNDI JEUDI 1 AVRIL AU 1 DEC. 7 9 1

1



\P 06h30-07h30 MAR. VEN. 1 MARS AU 1 DEC. 6.5 7.5
1

1


\P 06h30-07h30 MAR. VEN. 1 AVRIL AU 1 DEC. 6.5 7.5
1

1


\P 09h-12h MAR. VEN. 9 12
1

1


\P 07h-09h MAR. ET VEN. 1er MARS AU 1er DEC. 7 9
1

1


\P 07h-09h MAR. ET VEN. 1er AVRIL AU 1er DEC. 7 9
1

1


\P 09h-12h LUNDI VENDREDI 9 12 1


1


\P 1h-2h LUN et JEU 1 AVRIL au 1 DEC 1 2 1

1



\P 10h-11h LUNDI, JEUDI 10 11 1

1



\P 09h30-10h30 LUNDI, JEUDI 9.5 10.5 1

1



STAT. INT. MAR ET VEN DE 10H30 - 11H30 10.5 11.5
1

1


\P 08h30-11h30 LUN. MER. 1 AVRIL AU 1 DEC. 8.5 11.5 1
1




\P 08h-09h30 MAR. JEU. 1 AVRIL AU 1 DEC. 8 9.5
1
1



\P 08h-09h30 MAR. JEU. 1 AVRIL AU 1 DEC. 8 9.5
1
1



\P 08h30-11h30 MAR. JEU. 1 AVRIL AU 1 DEC 8.5 11.5
1
1



\P 09h-12h MARDI JEUDI 9 12
1
1



\P 07h30-08h30 MER. VEN. 1 AVRIL AU 1 DEC. 7.5 8.5

1
1


\P 07h-09h LUN. MER. 1 MARS AU 1 DEC. 7 9 1
1




Description Time Start Time End Mon Tues Wed Thurs Fri Sat Sun Daily

Note: This a simplified excerpt to allow easier display, you can download a more detailed CSV example which contains 200 entries. A complete CSV file will be available when the translation job is complete and verified to be error-free.

##A (Re)Usable Application

After restructuring the on-street parking data-set published by The City into a time-based and geo-located relational database, work begins on Park Catcher / Capteur de stationnement.

Park Catcher Search Engine

The application aims to be a guide to easy parking in Montréal. An interactive map and a search engine allow users to find spots where parking is allowed for a specific time period.

So if a user needs to park in Downtown Montréal on Wednesday between 1:30pm and 3:30pm, the application can indicate nearby spots where the user can look for parking. This could help reduce driving in circles, avoid parking tickets for users by leading them directly to the right street!

####User Interface

In order to simplify the application, and to make do with the data-set:

  • No-parking spots are not displayed on the map. We only display the parking-allowed posts.
  • Each post displays its next no-parking period.
  • The System detects Summer/Winter seasons, Schooldays and Holidays hiding non-applicable panels.
  • Vehicle types are ignored for the time being. This concerns a small percentage of users, such as small cars, motorhomes, motorbikes, authorized vehicles, police, fire-fighters, etc.
  • Paid-parking information is not available. This information is not included in The City's data-set since it belongs to Stationnement de Montréal, a subsidiary of the Board of Trade of Metropolitan Montréal.

###GeoJSON API

A fully-documented GeoJSON API is available. Check the Wiki or the example for more information.

This API was built to help other developers build applications using this data-set and to help promote Open Data. This is also my way of thanking everyone at the City of Montréal who helped publish this data making this project possible!

Clone this wiki locally