diff --git a/README.md b/README.md index c79cf65..43d0297 100644 --- a/README.md +++ b/README.md @@ -199,8 +199,6 @@ with every train live on it. they meet and part without crossing. Stations whose platforms are on different tracks get a bar joining them, as on AT's map. Straight lines stand in until the timetable has loaded. -- **Te Huia** runs from The Strand out along the eastern line and on to - Hamilton. - **Every train, live**, snapped onto its own line and pointing the way it's going, with an orange or red dot when it's running 2 or 5+ minutes late. - **Diagram, Satellite or Map.** Diagram is a quiet map (land, water, parks and diff --git a/app/src/main/java/nz/aryan/akllive/gtfs/Rail.kt b/app/src/main/java/nz/aryan/akllive/gtfs/Rail.kt index 0e34b20..d1b12c9 100644 --- a/app/src/main/java/nz/aryan/akllive/gtfs/Rail.kt +++ b/app/src/main/java/nz/aryan/akllive/gtfs/Rail.kt @@ -124,8 +124,10 @@ object Rail { fun asks(stations: List, segs: List, lineIds: List): List { fun piece(line: String, a: Int, b: Int) = TrackAsk(line, stations[a].lon, stations[a].lat, stations[b].lon, stations[b].lat) val idx = { n: String -> stations.indexOfFirst { it.name == n } } + // Te Huia's run south only when its stations are on the map + val south = HUIA_SOUTH.map(idx) return segs.map { piece(lineIds[it.line], it.from, it.to) } + - HUIA_SOUTH.zipWithNext().map { (a, b) -> piece("HUIA", idx(a), idx(b)) } + if (south.any { it < 0 }) emptyList() else south.zipWithNext().map { (a, b) -> piece("HUIA", a, b) } } /** Each line as one route along its track ([cut]: the real track per ask, null for straight lines between stations). */ @@ -235,7 +237,7 @@ object Rail { * track. [shown]: the AT lines showing (Te Huia always is). */ fun layout(stations: List, geo: RailGeo, shown: Set): RailDrawing { - val lines = geo.routes.filter { it.line == HUIA || it.line in shown } + val lines = geo.routes.filter { (it.line == HUIA || it.line in shown) && it.pts.size > 1 } // every little segment of track, in a grid, so finding the rails near a point is quick val cell = 0.0015 val grid = HashMap>() diff --git a/app/src/main/java/nz/aryan/akllive/ui/TrainScreen.kt b/app/src/main/java/nz/aryan/akllive/ui/TrainScreen.kt index a51d048..4792168 100644 --- a/app/src/main/java/nz/aryan/akllive/ui/TrainScreen.kt +++ b/app/src/main/java/nz/aryan/akllive/ui/TrainScreen.kt @@ -82,10 +82,10 @@ import nz.aryan.akllive.data.TrainState import nz.aryan.akllive.data.TripDetail import nz.aryan.akllive.data.occupancyText -/** The network's stations and segments, plus Te Huia's own stops, for the rail layout. */ +/** The network's stations and segments, for the rail layout: AT's lines only (no Te Huia on to Hamilton). */ object TrainNet { val stations: List = - MapData.STATIONS.map { RailStation(it.name, it.lat, it.lon, it.lines, it.priority) } + Rail.HUIA_STOPS + MapData.STATIONS.map { RailStation(it.name, it.lat, it.lon, it.lines, it.priority) } val segs: List = MapData.SEGS.map { RailSeg(it.line, it.from, it.to) } /** straight lines between stations, until the timetable's in */ val straight: RailGeo by lazy { Rail.build(stations, segs, null) } @@ -117,7 +117,7 @@ private fun bearing(a: Pt, b: Pt) = ((Math.toDegrees(atan2((b.x - a.x) * KX, b.y /** * Trains: Auckland's rail network drawn along the real tracks in AT's line - * colours (lines side by side where they share rails, Te Huia on to Hamilton), + * colours (lines side by side where they share rails), * with every train live on its own line where its GPS puts it. Over a quiet * diagram map, satellite photos or a street map; tap a train or a station. */ @@ -378,7 +378,7 @@ private fun Overview(state: TrainState, now: Long) { Spacer(Modifier.height(10.dp)) Text("Tap a train for where it's going, its speed and its next stops. Tap a station for live " + "departures from every platform. The lines follow the real tracks, side by side where they share rails, " + - "with every train where its GPS puts it, pointing the way it's heading. Te Huia runs on to Hamilton.", + "with every train where its GPS puts it, pointing the way it's heading.", style = MaterialTheme.typography.bodySmall, color = MaterialTheme.colorScheme.onSurfaceVariant) }