An Post GeoDirectory

Project Started: January 2017
Last Worked on Version: 1.1.0
Primary Technologies:
  • Node.js
  • Elastic Search
  • Redis
  • Levenshtein distance
  • PG & PG Native
  • PostGIS & PostgreSQL
  • Microsoft Azure


To help an Post show case their GeoDirectory database, I developed a single page app consisting of an Ordnance Survey Map, an autocomplete postal address search and geographic address count tool.

The web application is designed to complement the GeoFindit app released by another developer.

Search API Sever

To provide relevant results for the autocomplete search, Elastic Search was chosen as the database of choice. This No-SQL based document store allowed for simple, but powerful full text search across the entire GeoDirectory dataset. A small Node.js API was implemented between the Elastic Search server and the front end application to provide rate limiting and additional security to prevent someone from scraping the dataset.

Query Limiter Module

As part of the project specification, an Post wanted to limit users to 20 searches a day. This requirement posed an interesting technical challenge as a slow typer could easily exhaust this limit using the autocomplete API. To implement the limit fairly, I developed the query limiter module which allows multiple related searches to be grouped together.

The module uses the Damerau–Levenshtein distance algorithm, and compares the previous search query from a given IP address to the current query. If they are related (for example a continuation of a search) then the request is allowed to continue. If a new, unrelated search request is made, the new query, IP address and time stamp are stored in Redis and the search count for that IP is incremented by one. If an IP is over quota the request is denied. If an IP is over quota but the timestamp is older than 24 hours, the quota is reset and the request continues as before.

Catchment Analysis Module

To allow users to query the number of residential and commercial buildings within an area, the web application supports the drawing of a user defined catchment area. On the backend, a forked version of JMap Feature Server implements the Catchment Analysis Module.

This module takes a GeoJSON defined area and returns a JSON object with counts for the different building types. This count is done via SQL query on the GeoDirectory database in PostgreSQL. One of the challenges was to support a circle based query which is not present in the GeoJSON specification. This was handled by defining a custom point feature with a radius property which the backend would translate into the correct query.

Copyright 2019 Nigel Hanlon.