Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/nz/aryan/akllive/gtfs/Rail.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ object Rail {
fun asks(stations: List<RailStation>, segs: List<RailSeg>, lineIds: List<String>): List<TrackAsk> {
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). */
Expand Down Expand Up @@ -235,7 +237,7 @@ object Rail {
* track. [shown]: the AT lines showing (Te Huia always is).
*/
fun layout(stations: List<RailStation>, geo: RailGeo, shown: Set<Int>): 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<Long, MutableList<Long>>()
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/nz/aryan/akllive/ui/TrainScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<RailStation> =
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<RailSeg> = 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) }
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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)
}

Expand Down
Loading