Permalink
Browse files

Added inward and outward codes

  • Loading branch information...
cblanc committed Feb 17, 2014
1 parent 6f6bfbe commit a214200c3536273a0448c6c0829e8b78a208856d
Showing with 10 additions and 2 deletions.
  1. +6 −2 app/models/postcode.js
  2. +4 −0 tests/helper/index.js
View
@@ -28,7 +28,9 @@ var postcodeSchema = {
"parish" : "VARCHAR(255)",
"lsoa" : "VARCHAR(255)",
"msoa" : "VARCHAR(255)",
- "nuts" : "VARCHAR(255)"
+ "nuts" : "VARCHAR(255)",
+ "incode" : "VARCHAR(5)",
+ "outcode" : "VARCHAR(5)"
};
var indexes = {
@@ -225,7 +227,7 @@ Postcode.prototype.seedPostcodes = function (filePath, callback) {
" latitude, country, nhs_ha," +
" admin_county, admin_district, admin_ward, parish, quality," +
" parliamentary_constituency , european_electoral_region, region, " +
- " primary_care_trust, lsoa, msoa, nuts"
+ " primary_care_trust, lsoa, msoa, nuts, incode, outcode"
dataPath = path.join(__dirname, "../../data/"),
countries = JSON.parse(fs.readFileSync(dataPath + "countries.json")),
nhsHa = JSON.parse(fs.readFileSync(dataPath + "nhsHa.json")),
@@ -283,6 +285,8 @@ Postcode.prototype.seedPostcodes = function (filePath, callback) {
finalRow.push(lsoa[row[42]]); // 2011 LSOA
finalRow.push(msoa[row[43]]); // 2011 MSOA
finalRow.push(nuts[row[22]]); // NUTS
+ finalRow.push(row[2].split(" ")[1]); // Incode
+ finalRow.push(row[2].split(" ")[0]); // Outcode
return finalRow;
}
View
@@ -115,6 +115,8 @@ function isPostcodeObject(o) {
assert.property(o, "msoa");
assert.property(o, "nuts");
assert.property(o, "primary_care_trust");
+ assert.property(o, "incode");
+ assert.property(o, "outcode");
}
function isRawPostcodeObject(o) {
@@ -139,6 +141,8 @@ function isRawPostcodeObject(o) {
assert.property(o, "msoa");
assert.property(o, "nuts");
assert.property(o, "primary_care_trust");
+ assert.property(o, "incode");
+ assert.property(o, "outcode");
}
module.exports = {

0 comments on commit a214200

Please sign in to comment.