jflight/nearby-uk-postcode-finder

There is no license information available for the latest version (0.0.2) of this package.

Find all UK Ppostcodes within the radius of a postcode

0.0.2 2014-07-26 09:29 UTC

This package is not auto-updated.

Last update: 2024-04-09 00:42:23 UTC


README

The postcode finder takes a UK postcode outcode (the bit before the space) and a radius, and returns all other uk postcodes within that radius.

It is powered by a csv file of postcodes and their longitude and latitude coordinates, and shouldn't be used in production environments where speed is important. The project makes use of the excellent Geotools library.

Installation

Add to composer.json:

    "require": {
        "jflight/nearby-uk-postcode-finder": "dev-master"
    }

Run:

composer update

Usage

Create a postcode:

$postcode = new Jflight\PostcodeFinder\UkPostcode('CF11');

Get postcodes within a radius of 10 km:

$nearbyPostcodes = $postcode->findNearestPostcodes(10)); // Array of postcodes

Extension

In theory, the postcode class could be extended and used for postcodes (or equivalent) for any county, as long as csv lookup of postcodes with their longitude and latitue is available.

This would be done as follows:

<?php

class NewPostcode extends Jflight\PostcodeFinder\Postcode {
    protected $file = "/path/to/csv.csv";
}