The various tools on this website are coded using perl, and store data in a MySQL database. Various scripts are used to import official data, obtain OSM data from the Overpass API, compare the two, and then generate the web pages you can view.
For many of the tools, the following types of scripts are used:
Each tool has a script that runs Overpass API queries to get the OSM data. I split the UK up into a n×m grid of rectangles and make nm individual queries in order to stay below the Overpass limits. (n and m depend on the volume of data being collected. I use 8 for more sparse cases, up to 16 for the densest.) I also have some rules to detect some of the rectangles that are wholly outside the UK border, and then don't make the API call for these.
The individual Overpass queries will sometime fail, so I need to check which have haven't been successful. This script is designed to output a warning if any fail. In such cases it's designed to be run it again to pick up the missing entries, without repeating the successful ones.
After downloading the data, it's parsed into a MySQL database table for the tool. I store the OSM object ID, lat/lon values and various tag values depending on the tool. The lat/lon values are stored as intergers (1,000,000 × the value in degrees) to speed up subsequent calculations. This gives an accuracy of 6 decimal places in the degrees, which is more the sufficient.
Where there's official government data available another script does the import of this data into a parallel MySQL table. Sometimes there's already lat/lon data available, sometimes I need to lookup geographic coordinates from the postcode. This is done using the CodePoint Open dataset (which I parse into another MySQL table). It is also sometimes necessary to convert from OSBG grid references to lat/lon values.
There's then a script that compares the two sets of data in the MySQL tables and attempts to match nearby objects. Sometimes there are unique identifiers in OSM that can be used. But even if there are some form of proximity matching is needed too.
Typically I will run through unmatched objects from one table, and look for the closed geographic match in the other within a certain radius. This is then repeated for a few increasing radii. Values used depend on the accuracy of the official data (typically, I might use 50m, 100m, 500m.) This process helps stop you making an erroneous matches where A1 is the closest object to B1, but B1 should actually be matched to the missing A2.
Finally there are scripts to generate the information shown on the web pages. Often the map data is generated live straight from the MySQL database. Other reports are re-generated each time the data is refreshed. The web maps use Leaflet.js, and typically load GeoJSON data that my scripts have generated.
I've written various Perl modules to help with common tasks in these scripts. Other people are welcome to make use of these under whatever licence you like. These modules include: