Jamie,
I’ve looked at the “which side is it” code and realised I have forgotten that the top of the page (up, if you like) is “north” on most of the original diagrams, but on the District, it’s West! I’ve updated the JSON and code to reflect this.
My debug code says this now looks right
There had to be a bit of messing around with the data to “fix” things. So I ended up with two functions that did it, so there’s this one to work out which is “north” and “south” for each diagram…
private static function defineThisLineNorthAndSouth($strLineName, &$N, &$S)
{
$N = "N";
$S = "S";
if ($strLineName == "Jubilee" or $strLineName == "District") {
$N = "E";
$S = "W";
}
if ($strLineName == "Piccadilly" or $strLineName == "Central" or $strLineName == "District") {
$N = "W";
$S = "E";
}
if ($strLineName == "DLR") {
$N = "U";
$S = "D";
}
if ($strLineName == "Circle") {
$N = "O";
$S = "I";
}
}
Then correct the source codes for some stations…
private function overrideLayoutByName($strName, $strLayoutCode, $strLineName)
{
switch ($strName) {
case "Greenford":
$strLayoutCode = "[W1=2t2=3E ns]";
break;
case "Hainault":
$strLayoutCode = "[=SB==N]";
break;
case "Stratford International":
$strLayoutCode = "[=TT=]";
break;
case "Sudbury Town":
$strLayoutCode = "[OP]";
break;
case "Turnpike Lane":
$strLayoutCode = "[CP]";
break;
case "Pudding Mill Lane":
$strLayoutCode = "[IPX]";
break;
/*
* These fixes are to deal with duplicates in the original data.
*
*/
case "Woodford":
$strLayoutCode = "[V=WE=]";
break;
case "Kennington":
$strLayoutCode = "[N1==3NS4==2S]";
break;
case "Croxley":
$strLayoutCode = "[OP]";
break;
case "Seven Sisters";
$strLayoutCode = "[N==N/=S+2]";
break;
case "Paddington":
if ($strLineName == "Circle") {
$strLayoutCode = "[E16==15W/=2OI1=]";
}
break;
case "Canning Town":
if ($strLineName == "DLR") {
$strLayoutCode = "[U4=3D/e6=5wB2=1D]";
}
break;
case "Stratford":
if ($strLineName == "DLR") {
$strLayoutCode = "['4a'T=='4b'T =16UD17=]";
}
break;
case "Acton Town":
if ($strLineName == "District") {
$strLayoutCode = "[W=WE=E]";
}
break;
case "West India Quay":
$strLayoutCode = "[U==UD= D X+1]";
break;
case "Holborn":
if ($strLineName == "Piccadilly") {
$strLayoutCode = "[=3Wb5==4E]";
}
break;
case "Latimer Road":
case "Goldhawk Road":
if ($strLineName == "HammersmithAndCity") {
$strLayoutCode = "[OP]";
}
break;
case "Chalfont & Latimer":
$strLayoutCode = "[=NS=V]";
break;
case "Custom House":
$strLayoutCode = "[=4UD3=]";
break;
case "Poplar DLR":
$strLayoutCode = "[U==UD==D X]";
break;
case "Clapham Junction":
/* Overground platforms... */
$strLayoutCode = "[T==T ]";
break;
case "Camden Town":
$strLayoutCode = "[N1=-=3N/S2=-=4S] ";
break;
case "Borough":
$strLayoutCode = "[=S =N]";
break;
case "Finchley Central":
$strLayoutCode = "[V==NS=]";
break;
case "East Finchley":
$strLayoutCode = "[N=NS=S]";
break;
case "Mill Hill East":
$strLayoutCode = "[T=]";
break;
case "Euston":
if ($strLineName == "Northern") {
$strLayoutCode = "[N==ns==S +2]";
}
break;
/*
* These need the # # that show defunct platforms near the district line
*
*/
case "Bromley-by-Bow":
case "Upton Park":
if ($strLineName == "HammersmithAndCity") {
$strLayoutCode = "[=NS=]";
} else {
$strLayoutCode = "[OP]";
}
break;
case "Plaistow":
if ($strLineName == "HammersmithAndCity") {
$strLayoutCode = "=1NS2=3V";
} else {
$strLayoutCode = "[=1WE2=3V]";
}
break;
case "Uxbridge":
$strLayoutCode = "[T1=2T2=3T]";
break;
/*
* Fix odd mistatakes
*
*/
case "Arnos Grove":
$strLayoutCode = "[W1=2B3=4E]";
break;
case "Cockfosters":
$strLayoutCode = "[V1=2V3=4V]";
break;
case "Loughton":
$strLayoutCode = "[W==B==E]";
break;
case "Norwood Junction":
$strLayoutCode = "[=N==ns==SS=]";
break;
case "New Cross":
$strLayoutCode = "[b==bb=='D'V]";
break;
case "Baker Street":
if ($strLineName == "HammersmithAndCity") {
$strLayoutCode = "=6WE5=/v1==2ns3==4v";
}
break;
case "Upminster":
$strLayoutCode = "[t==we==WE==Ev=]";
break;
break;
}
return $strLayoutCode;
}
And then I needed to deal with “only readable by a human, acutally” codes…
private static function manualDecodeOfSpeailCodesFound(&$strCode, &$arrPlaforms, $strCodeOriginal)
{
if (self::hasASingleQuote($strCode)) {
switch ($strCodeOriginal) {
case "[v'4a'='4b'v '3a'=W3=5wE6=8ew=10":
$strCode = "v==v =W==wE==ew=";
$arrPlaforms = ["4a","4b","3a",3,5,6,8,10];
break;
case "[V'4a'='4b'V '3a'=w3=5we6=8ew=10":
$strCode = "V==V =w==we==ew=";
$arrPlaforms = ["4a","4b","3a",3,5,6,8,10];
break;
case "['4a'T=='4b'T =16UD17=]";
$strCode = "T==T/=UD=";
$arrPlaforms = ["4a","4b",16,17];
break;
case "[b==bb=='D'V]":
$strCode = "wew==be==V";
$arrPlaforms = ["A","B","C","D"];
break;
default:
break;
}
} else {
switch ($strCodeOriginal) {
case "[=#du#= V15=TT13=]":
$strCode = "V==VV=";
$arrPlaforms = [13,14,15];
break;
case "[...=14vW=E]":
$strCode = "W==E";
$arrPlaforms = [15,16];
break;
case "[=6we5==1V1=NS=4V]":
$strCode = "=oi=/V==NS==V";
$arrPlaforms = [6,5,1,2,3,4];
break;
case "[t4=sn=1t =5OI6=]":
$strCode = "=OI=/v==ns==v";
$arrPlaforms = [6,5,1,2,3,4];
break;
case "[N1=-=3n/S2=-=4s]":
$strCode = "N==N/S==S";
$arrPlaforms = [1,3,2,4];
break;
case "[=6we5=-=1V1=NS=4V]":
$strCode = "=we=/V==NS==V";
$arrPlaforms = [6,5,1,2,3,4];
break;
case "[=6V =4VV=WE1=]":
$strCode = "=WE=/V==Vv==v";
$arrPlaforms = [6,5,1,2,3,4];
break;
case "[=WE=WE= X]":
$strCode = "=WE==we=";
$arrPlaforms = [1,2,4,4];
break;
}
}
}
This has been quite … fun.
And then there is Greenford, the only place on the whole system that has a bay platform where both sides are the same number (2).