From the archive · 2017
An Post GeoDirectory
A single-page app showcasing An Post's GeoDirectory, with an Ordnance Survey map, autocomplete address search and building counts for any area you draw.
To help An Post showcase its GeoDirectory database, I built a single-page app with an Ordnance Survey map, autocomplete postal address search and a tool for counting addresses in an area. It was designed to sit alongside the GeoFindit app built by another developer.
Search API server
Elasticsearch handled the autocomplete, giving fast full-text search across the whole GeoDirectory dataset. A small Node.js API sat between Elasticsearch and the front end to add rate limiting and stop anyone scraping the data.
Query limiter
An Post wanted to limit users to 20 searches a day. That was tricky with autocomplete, where a slow typist could use up the allowance on a single address. The query limiter groups related searches so they count once.
It compares each query with the previous one from the same IP address using Damerau-Levenshtein distance. If the new query continues the last one, it goes through free. If it’s a new search, the query, IP address and timestamp are stored in Redis and that IP’s count goes up by one. An IP over quota is refused, unless its timestamp is more than 24 hours old, in which case the quota resets.
Catchment analysis
Users could draw their own area on the map and get counts of residential and commercial buildings inside it. A forked version of the JMap Feature Server took the area as GeoJSON and ran the count as a SQL query against the GeoDirectory database in PostgreSQL. GeoJSON has no circle type, so circles were sent as a point with a radius property, which the backend translated into the right query.