jflight / nearby-uk-postcode-finder
Find all UK Ppostcodes within the radius of a postcode
Requires
- league/geotools: @stable
Requires (Dev)
- behat/behat: 2.4.*@stable
- phpunit/phpunit: 4.1.*
This package is not auto-updated.
Last update: 2025-02-25 05:19:13 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"; }