Skip to content

Commit 04da335

Browse files
committed
Updated readme for district and subDistrict
1 parent d19d663 commit 04da335

1 file changed

Lines changed: 40 additions & 23 deletions

File tree

README.md

Lines changed: 40 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
[![Build Status](https://travis-ci.org/cblanc/postcode.js.png)](https://travis-ci.org/cblanc/postcode.js)
1+
[![Build Status](https://travis-ci.org/cblanc/postcode.js.png)](https://travis-ci.org/cblanc/postcode.js)
22
[![Dependency Status](https://gemnasium.com/cblanc/postcode.js.png)](https://gemnasium.com/cblanc/postcode.js)
33

44
# Postcodes
55

66
Utility methods for UK Postcodes.
77

8-
Included is a test suite that tests against all postcodes listed in the Ordnance Survey's postcode dataset as of January 2014.
8+
Included is a test suite that tests against all postcodes listed in the Ordnance Survey's postcode dataset as of January 2014.
99

1010
## Getting Started
1111

@@ -16,25 +16,22 @@ Create an instance of Postcode to perform utility methods, like so
1616
```javascript
1717
var Postcode = require("postcode");
1818

19-
var postcode = new Postcode("po167gz");
19+
var postcode = new Postcode("ec1v9lb");
2020
```
2121

2222
Perform simple validations, parsing and normalisation
2323

2424
```javascript
25-
postcode.valid() // => True
26-
27-
postcode.normalise() // => "PO16 7GZ"
28-
29-
postcode.outcode() // => "PO16"
30-
31-
postcode.incode() // => "7GZ"
32-
33-
postcode.area() // => "PO"
34-
35-
postcode.sector() // => "PO16 7"
36-
37-
postcode.unit() // => "GZ"
25+
postcode.valid() // => true
26+
postcode.normalise() // => "EC1V 9LB"
27+
28+
postcode.outcode() // => "EC1V"
29+
postcode.incode() // => "9LB"
30+
postcode.area() // => "EC"
31+
postcode.district() // => "EC1"
32+
postcode.subDistrict() // => "EC1V"
33+
postcode.sector() // => "EC1V 9"
34+
postcode.unit() // => "LB"
3835
```
3936

4037
Misc. Class Methods include
@@ -45,27 +42,47 @@ Postcode.validOutcode(outcode)
4542

4643
## Definitions
4744

48-
### Outcode (#outcode)
45+
### Outcode
4946

5047
The outward code is the part of the postcode before the single space in the middle. It is between two and four characters long. A few outward codes are non-geographic, not divulging where mail is to be sent. Examples of outward codes include "L1", "W1A", "RH1", "RH10" or "SE1P".
5148

52-
### Inward Code (#inward)
49+
### Incode
5350

5451
The inward part is the part of the postcode after the single space in the middle. It is three characters long. The inward code assists in the delivery of post within a postal district. Examples of inward codes include "0NY", "7GZ", "7HF", or "8JQ".
5552

56-
### Postcode Area (#area)
53+
### Area
5754

5855
The postcode area is part of the outward code. The postcode area is between one and two characters long and is all letters. Examples of postcode areas include "L" for Liverpool, "RH" for Redhill and "EH" Edinburgh. A postal area may cover a wide area, for example "RH" covers north Sussex, (which has little to do with Redhill historically apart from the railway links), and "BT" (Belfast) covers the whole of Northern Ireland.
5956

60-
### Postcode Sector (#sector)
57+
### District
58+
59+
The district code is part of the outward code. It is between two and four characters long. It does not include the trailing letter found in some outcodes. Examples of district codes include "L1", "W1", "RH1", "RH10" or "SE1".
60+
61+
### Sub-District
62+
63+
The sub-district code is part of the outward code. It is often not present, only existing in particularly high density London districts. It is between three and four characters long. It does include the trailing letter omitted from the district. Examples of sub-district codes include "W1A", "EC1A", "NW1W", "E1W" or "SE1P".
64+
65+
Note: for outcodes not ending with a letter, `subDistrict` will return `null`. For example:
66+
67+
```js
68+
new Postcode("SW1A 1AA").subDistrict() // => SW1A
69+
new Postcode("E1W 1LD").subDistrict() // => E1W
70+
new Postcode("PO16 7GZ").subDistrict() // => null
71+
new Postcode("B5 5NY").subDistrict() // => null
72+
```
73+
74+
### Sector
6175

6276
The postcode sector is made up of the postcode district, the single space, and the first character of the inward code. It is between four and six characters long (including the single space). Examples of postcode sectors include "SW1W 0", "PO16 7", "GU16 7", or "L1 8", "CV1 4".
6377

64-
### Postcode Unit (#unit)
78+
### Unit
6579

6680
The postcode unit is two characters added to the end of the postcode sector. Each postcode unit generally represents a street, part of a street, a single address, a group of properties, a single property, a sub-section of the property, an individual organisation or (for instance Driver and Vehicle Licensing Agency) a subsection of the organisation. The level of discrimination is often based on the amount of mail received by the premises or business. Examples of postcode units include "SW1W 0NY", "PO16 7GZ", "GU16 7HF", or "L1 8JQ".
6781

68-
Source: [Wikipedia](http://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Formatting)
82+
Sources:
83+
84+
- https://en.wikipedia.org/wiki/Postcodes_in_the_United_Kingdom#Formatting
85+
- https://en.wikipedia.org/wiki/London_postal_district#Numbered_divisions
6986

7087
## Testing
7188

@@ -81,4 +98,4 @@ A complete list of Postcodes can be obtained from the ONS Postcode Directory, wh
8198

8299
MIT
83100

84-
Contains Ordnance Survey Data © Crown Copyright & Database Right 2014
101+
Contains Ordnance Survey Data © Crown Copyright & Database Right 2014

0 commit comments

Comments
 (0)