class Station implements Comparable { // stations.csv: "id","latitude","longitude","name","display_name","zone","total_lines","rail" String id; double lat,lon; String name; String displayName; float zone; int totalLines, rail; float screenx,screeny; float mapx,mapy; float targetx, targety; ArrayList conns = new ArrayList(); // for path finding int timeToCentre = 0; Station pathParent = null; Station(String id, double lon, double lat, String name, String displayName, float zone, int totalLines, int rail) { this.id = id; this.lon = lon; this.lat = lat; this.name = name; this.displayName = displayName; this.zone = zone; this.totalLines = totalLines; this.rail = rail; } int compareTo(Object o) { Station other = (Station)o; return this.timeToCentre - other.timeToCentre; } void animate() { if (abs(screenx-targetx)>1.0) { screenx += (targetx-screenx)/5.0; } if (abs(screeny-targety)>1.0) { screeny += (targety-screeny)/5.0; } } } void parseStations() { String strings[] = loadStrings("stations.csv"); for (int i = 1; i < strings.length; i++) { // stations.csv: "id","latitude","longitude","name","display_name","zone","total_lines","rail" String words[] = split(strings[i],","); if (words.length > 8) { // glue things back together for "Heathrow Terminals 1, 2 & 3" (and curse the comma!) if (!words[3].endsWith('"')) { words[3] += "," + words[4]; arrayCopy(words,5,words,4,words.length-5); words = shorten(words); } if (!words[4].endsWith('"')) { words[4] += "," + words[5]; arrayCopy(words,6,words,5,words.length-6); words = shorten(words); } } String id = words[0]; double lat = float(words[1]); double lon = float(words[2]); String name = words[3].substring(1,words[3].length()-1); String displayName = words[4]; float zone = float(words[5]); int totalLines = int(words[6]); int rail = int(words[7]); //console.log(id, lon, lat, name, displayName, zone, totalLines, rail); stations.put(id, new Station(id, lon, lat, name, displayName, zone, totalLines, rail)); } /* Vector statIndex = new Vector(); Iterator keyIter = stations.keySet().iterator(); while(keyIter.hasNext()) { Station s = (Station)stations.get(keyIter.next()); statIndex.add(s.name + ":" + s.id); } Collections.sort(statIndex); String[] stringsToWrite = new String[statIndex.size()]; for (int i = 0; i < stringsToWrite.length; i++) { String s = (String)statIndex.get(i); String[] words = split(s,":"); stringsToWrite[i] = ""; } saveStrings("station-links.html",stringsToWrite); */ }