Thirty of these features have been designated waypoints. These are the ones whose numeric comments are suffixed with an asterisk. The class's constructor then goes on to compile these waypoints into three air routes along which the 'aircraft' may fly:
To do this, it places the object references of each route's waypoints, in the order in which they are encountered during flight, into a route array which reside in the Route class. Having completed its task, this class object is discarded thereby releasing the memory it occupied during the construction of the waypoint and route databases.
/**
* Sets up the Waypoint Database for my Moving Map package
* @author Robert J Morton
* @version 18 December 1997 */
class wpini implements navconst {
private String Names[] = { //waypoint database
// WAYPOINTS
"51:53N 000:13E Stansted", //0*
"52:13N 000:08W Cambridge", //1*
"52:57N 001:10W Nottingham", //2*
"53:48N 001:34W Leeds", //3*
"54:59N 001:37W Newcastle", //4*
"55:57N 003:12W Edinburgh", //5*
"51:07N 001:19E Dover", //6*
"50:57N 001:56E Calais", //7*
"49:54N 002:16E Amiens", //8*
"47:48N 003:32E Auxerre", //9*
"47:20N 005:00E Dijon", //10*
"46:19N 004:50E Macon", //11*
"45:46N 004:50E Lyons", //12*
"44:57N 004:54E Valence", //13*
"43:57N 004:50E Avignon", //14*
"43:18N 005:23E Marseilles", //15*
"52:30N 001:55W Birmingham", //16*
"53:30N 002:15W Manchester", //17*
"55:52N 004:14W Glasgow", //18*
"58:12N 006:23W Stornoway", //19*
"64:10N 021:57W Reykjavik", //20*
"65:00N 062:30W Cape Mercy", //21*
"64:14N 076:32W Cape Dorset", //22*
"62:10N 093:30W Tavani", //23*
"53:30N 113:30W Edmonton", //24*
"49:30N 119:30W Penticton", //25*
"48:45N 122:27W Bellingham", //26*
"47:41N 122:15W Seattle", //27*
// GEOGRAPHIC FEATURES
// 1. England - south:
"51:30N 000:05W London", //28
"50:50N 000:09W Brighton", //29
"52:34N 001:17E Norwich", //30
"52:56N 001:18E Cromer", //31
"51:54N 000:55E Colchester", //32
"51:45N 001:15W Oxford", //33
"51:55N 002:05W Cheltenham", //34
// 2. England - north:
"53:25N 003:00W Liverpool", //35
"54:09N 004:29W Douglas", //36
"53:46N 002:42W Preston", //37
"54:08N 003:15W Barrow", //38
"54:54N 002:55W Carlisle", //39*
"53:23N 001:28W Sheffield", //40
"53:09N 000:20E Skegness", //41
"53:45N 000:20W Hull", //42
"54:37N 001:14W Redcar", //43
"54:17N 000:24W Scarborough", //44
// 3. Wales
"52:25N 004:06W Aberystwyth", //45
"52:44N 003:53W Dolgellau", //46
"53:18N 004:38W Holyhead", //47
// 4. Scotland
"57:29N 004:12W Inverness", //48
"56:25N 005:30W Oban", //49*
"56:48N 005:08W Ft William", //50
"57:54N 005:10W Ullapool", //51
"57:31N 005:39W Shieldaig", //52
"56:29N 003:00W Dundee", //53
"57:09N 002:06W Aberdeen", //54
// 6. France
"50:38N 003:03E Lille", //55
"49:15N 004:00E Reims", //56
"49:27N 001:04E Rouen", //57
"49:50N 003:16E St Quentin", //58
"48:50N 002:20E Paris", //59*
"48:49N 004:03E Troyes", //60
"46:12N 006:09E Geneva", //61
"45:12N 005:42E Grenoble", //62
"45:27N 004:22E St Etienne", //63
"43:32N 007:00E Cannes", //64
"43:37N 003:52E Montpellier", //65
"43:10N 005:55E Toulon", //66
"40:00N 000:10E Le Mans", //67
// 6. Canada/USA
"47:15N 122:30W Tacoma", //68
"48:00N 122:10W Everett", //69
"49:15N 123:10W Vancouver", //70
"48:30N 123:25W Victoria", //71
"48:07N 123:30W Port Angeles", //72
"47:00N 123:50W Aberdeen", //73
"46:16N 123:50W Astoria", //74
"47:30N 120:17W Wenatchee", //75
"49:40N 124:50W Port Alberni", //76
"49:10N 124:00W Nanaimo" //77
};
WpIni() { //CONSTRUCT THE WAYPOINT DATABASE
WayPnt w; //waypoint reference to use in initialisation
WayPnt.purge(); //set 'number of waypoints installed' to zero
for(int i = 0 ; i < Names.length ; i++) { //for each waypoint in the database
String s = Names[i]; //get the waypoint's details
double Lat = Convert( //compute latitude radians
s.substring(0, 2), //from latitude degrees
s.substring(3, 5) //and latitude minutes
);
if(s.substring(5, 6).equals("S")) //if waypoint south of equator
Lat = -Lat; //its radian latitude is negative
double Lng = Convert( //compute longitude radians
s.substring(7, 10), //from longitude degrees
s.substring(11, 13) //and longitude minutes
);
if(s.substring(13, 14).equals("W")) //if waypoint west of Greenwich
Lng = -Lng; //westerly longitudes are negative
w = new WayPnt(Lat, Lng, s.substring(15));//create a new waypoint object
}
Route.purge(); //reset to 'no routes installed'
Route r = new Route(6); //London-to-Edinburgh route
r.AddWayPnt( 0); //Stansted
r.AddWayPnt( 1); //Cambridge
r.AddWayPnt( 2); //Nottingham
r.AddWayPnt( 3); //Leeds
r.AddWayPnt( 4); //Newcastle
r.AddWayPnt( 5); //Edinburgh
r = new Route(12); //Stansted-to-Marseilles route
r.AddWayPnt( 0); //Stansted
r.AddWayPnt( 6); //Dover
r.AddWayPnt( 7); //Calais
r.AddWayPnt( 8); //Amiens
r.AddWayPnt(59); //Paris
r.AddWayPnt( 9); //Auxerre
r.AddWayPnt(10); //Dijon
r.AddWayPnt(11); //Macon
r.AddWayPnt(12); //Lyons
r.AddWayPnt(13); //Valence
r.AddWayPnt(14); //Avignon
r.AddWayPnt(15); //Marseilles
r = new Route(15); //Stansted-to-Seattle route
r.AddWayPnt( 0); //Stansted
r.AddWayPnt(16); //Birmingham
r.AddWayPnt(17); //Manchester
r.AddWayPnt(39); //Carlisle
r.AddWayPnt(18); //Glasgow
r.AddWayPnt(49); //Oban
r.AddWayPnt(19); //Stornoway
r.AddWayPnt(20); //Reykjavik
r.AddWayPnt(21); //Cape Mercy
r.AddWayPnt(22); //Cape Dorset
r.AddWayPnt(23); //Tavani
r.AddWayPnt(24); //Edmonton
r.AddWayPnt(25); //Penticton
r.AddWayPnt(26); //Bellingham
r.AddWayPnt(27); //Seattle
}
private double Convert(String s, String t) { //Convert a 'degrees & minutes' string
double d = Double.valueOf(s).doubleValue(); // into a double value in radians.
double m = Double.valueOf(t).doubleValue();
double r = (d + m / 60) / DPR;
return r;
}
}
/* Robert J Morton, the author of this program,
is a poor but Right Honourable Member of the
Ancient and Noble Order of the Long-term Unemployed.
Offers of work please to: robmorton@clara.net */