Skip to content

Commit

Permalink
Merge pull request #234 from davwheat/short-platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat authored Jun 6, 2024
2 parents c8e9a7e + 6bf3333 commit 61f40c9
Show file tree
Hide file tree
Showing 4 changed files with 2,209 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ static/temp/
.sentryclirc

.wrangler/

~$*.xlsx
39 changes: 32 additions & 7 deletions src/components/AmeyLiveTrainAnnouncements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import dayjs from 'dayjs'
import dayjsUtc from 'dayjs/plugin/utc'
import dayjsTz from 'dayjs/plugin/timezone'
import Breakpoints from '@data/breakpoints'
import { isMindTheGapStation } from '@data/liveTrains/mindTheGap'
import { isShortPlatform } from '@data/liveTrains/shortPlatforms'

dayjs.extend(dayjsUtc)
dayjs.extend(dayjsTz)
Expand Down Expand Up @@ -95,6 +97,7 @@ function getCallingPoints(
name: '',
randomId: '',
requestStop: p.activities?.includes('R'),
shortPlatform: p.crs ? isShortPlatform(p.crs, p.platform ?? null, train) || undefined : undefined,
}

p.associations
Expand Down Expand Up @@ -175,6 +178,7 @@ function getCallingPoints(
name: '',
randomId: '',
requestStop: p.activities?.includes('R'),
shortPlatform: p.crs ? isShortPlatform(p.crs, p.platform ?? null, train) || undefined : undefined,
}
})
.filter(Boolean) as CallingAtPoint[]
Expand Down Expand Up @@ -262,11 +266,6 @@ export interface LiveTrainAnnouncementsProps<SystemKeys extends string> {

type DisplayType = 'infotec-landscape-dmi' | 'blackbox-landscape-lcd'

const MindTheGapStations: Record<string, string[]> = {
WVF: ['1', '2'],
LWS: ['1', '2', '3', '4', '5'],
}

const DisplayNames: Record<DisplayType, string> = {
'infotec-landscape-dmi': 'Infotec landscape DMI',
'blackbox-landscape-lcd': 'Blackbox landscape LCD',
Expand Down Expand Up @@ -546,7 +545,7 @@ export function LiveTrainAnnouncements<SystemKeys extends string>({
const callingAt = getCallingPoints(train, systems[systemKey].STATIONS, loc => getStation(loc, systemKey))
const [vias] = getViaPoints(train, systems[systemKey].STATIONS, stationNameToCrsMap, loc => getStation(loc, systemKey))

const mindTheGap = !!MindTheGapStations[selectedCrs]?.includes(train.platform)
const mindTheGap = isMindTheGapStation(selectedCrs, train.platform)

console.log(`Mind the gap: ${mindTheGap}`)

Expand Down Expand Up @@ -1482,10 +1481,36 @@ export function LiveTrainAnnouncements<SystemKeys extends string>({
<li>are terminating at the selected station</li>
</ul>
<p>
We also can't handle short platforms and some other features as this information isn't contained within the open data provided by
We also can't handle most short platforms and various other features as this information isn't contained within the open data provided by
National Rail.
</p>

<div
style={{
padding: 12,
paddingLeft: 16,
borderLeft: '4px solid var(--primary-blue)',
background: `color-mix(in srgb, var(--primary-blue), transparent 92%)`,
marginBottom: 24,
}}
>
<p>
We're currently trialling <strong>automated short platform announcements</strong> for stations served by GTR (Southern, Thameslink,
Gatwick Express, and Great Northern) and Southeastern.
</p>
<p>
Please let us know if you know any short platforms that aren't correctly announced by the website for these TOCs. We'll seek
information and feedback about other TOCs in the near future
</p>
<p style={{ marginBottom: 0 }}>
Have feedback? Please post it on{' '}
<a target="_blank" href="https://github.com/davwheat/rail-announcements/issues/226">
this GitHub tracking issue
</a>
!
</p>
</div>

{!hasEnabledFeature ? (
<>
<button
Expand Down
15 changes: 15 additions & 0 deletions src/data/liveTrains/mindTheGap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export function isMindTheGapStation(crs: string, platformNumber: string | null): boolean {
if (platformNumber === null) return false

return MindTheGapStations[crs]?.includes(platformNumber) ?? false
}

/**
* Mind the gap stations data
*
* Mapped by CRS -> Platform
*/
const MindTheGapStations: Record<string, string[]> = {
WVF: ['1', '2'],
LWS: ['1', '2', '3', '4', '5'],
}
Loading

0 comments on commit 61f40c9

Please sign in to comment.