6 ALTER TABLE gb_postcode ADD COLUMN easting bigint;
7 ALTER TABLE gb_postcode ADD COLUMN northing bigint;
11 COPY gb_postcode (id, postcode, easting, northing) FROM stdin;
16 while ($sLine = fgets(STDIN)) {
17 $aColumns = str_getcsv($sLine);
19 // insert space before the third last position
20 // https://stackoverflow.com/a/9144834
21 $postcode = $aColumns[0];
22 $postcode = preg_replace('/\s*(...)$/', ' $1', $postcode);
24 echo join("\t", array($iCounter, $postcode, $aColumns[2], $aColumns[3]))."\n";
26 $iCounter = $iCounter + 1;
32 UPDATE gb_postcode SET geometry=ST_Transform(ST_SetSRID(CONCAT('POINT(', easting, ' ', northing, ')')::geometry, 27700), 4326);
34 ALTER TABLE gb_postcode DROP COLUMN easting;
35 ALTER TABLE gb_postcode DROP COLUMN northing;