
Why Car Park Data?
In addition to its obvious uses, one of the things that interested me about car park data was the fact that it can be used as a rough indicator of the level of current activity within the town centre.
Was the Data already available elsewhere?
West Sussex County Council had for some time displayed live car park data on their Travel Information website but the "Car Parks" page defaulted to Crawley and would only display Horsham data if a dropdown list and submit button were actioned.
Consequently the Horsham data was virtually hidden from the search engines whereas searching for "Horsham Parking" on Google would return Visit Horsham as the top result.
It made sense to try and get the data displayed on Visit Horsham where it would be much easier to be found.
So how did you go about obtaining the data?
We had previously requested access to the data some years ago and let's just say our request foundered due to 'red tape'.
But hey, we were now in the era of the "Big Society" and we thought we would put it to the test!
By a fortunate coincidence, Horsham's MP is non other than Francis Maude: the cabinet minister in charge of delivering much of the Big Society agenda.
I sent an email to Francis Maude's office explaining our previous request and requested his help, and to his credit, within a few weeks had access to a new feed set up for 3rd party access.
What format is the data in?
The data is in DATEX II format which is a standard developed for information exchange between traffic information centres and service providers.
DATEX II is formatted as XML and the significant [car park data] fields of interest in this case are:
- <latitude>
- <longitude>
- <carParkIdentity>
- <carParkOccupancy>
- <carParkStatus>
- <occupiedSpaces>
- <totalCapacity>
How did you parse the data?
The elements listed above are relatively deeply nested within the DATEX II document but it is a fairly straight forward job to parse them using ASP.NET and LINQ.
The image below shows how little code is required for the significant part of the main function I wrote to achieve this.
The basic steps are:
- Retrieve the XML file by using a WebRequest and a HttpWebResponse
- Create a XDocument by parsing the XML file
- Create a IEnumerable<XElement> collection by calling the .Element() method on the XDocument
- Once you have an IEnumerable<XElement> collection you can simply loop through it to extract the individual elements and convert them into your own types

Is that it?
Well not quite, but once you have a IEnumerable<XElement> collection of your own types you can easily run other LINQ queries to obtain specific results.
As well as the obvious properties that directly relate to the DATEX II element my 'CarPark' class also contains a static method that calculates the total occupancy of all the car parks combined. It is this method that drives the "Parking Status" box that is on every page of Visit Horsham
Conclusion
Finally getting live car park data onto Visit Horsham was a small but significant step.
Small: because technically it was not that challenging (thanks to the simplicity of LINQ!)
Significant: because it was obtained via a 'Big Society' request - hopefully setting a precedent for similar requests in the future
Link
visithorsham.co.uk/parking.aspx