-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDepartureData.h
More file actions
68 lines (57 loc) · 2.36 KB
/
DepartureData.h
File metadata and controls
68 lines (57 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef DEPARTUREDATA_H
#define DEPARTUREDATA_H
#include <time.h>
// ============================================================================
// Departure Data Structures
// ============================================================================
#define DEPS_PER_STOP 12 // Departures requested per stop from API
#define MAX_DEPARTURES 24 // Result cache size (larger for secondEta matching across multi-stop hubs)
struct Departure
{
char line[8]; // Line number (e.g., "31", "A", "S9")
char destination[64]; // Destination/headsign
int eta; // Minutes until departure (recalculated from departureTime)
time_t departureTime; // Unix timestamp of departure (from API)
char platform[8]; // Platform/track (e.g., "D", "3", optional)
char sourceStopId[16]; // Stop ID that produced this departure (for symbol matching)
bool hasAC; // Air conditioning
bool isDelayed; // Has delay
int delayMinutes; // Delay in minutes
int secondEta; // ETA of next departure for same line+destination (-1 if none)
time_t secondDepartureTime; // Timestamp of second departure (0 if none)
};
// ============================================================================
// Departure Processing Functions
// ============================================================================
/**
* Comparison function for qsort - sorts departures by ETA ascending, then destination alphabetical
* @param a First departure
* @param b Second departure
* @return Negative if a < b, positive if a > b, zero if equal
*/
int compareDepartures(const void* a, const void* b);
/**
* Shorten long destination names to fit on display
* Modifies the string in-place
* @param destination UTF-8 string to shorten (will be modified in-place)
*/
void shortenDestination(char* destination);
/**
* Calculate ETA in minutes from departure timestamp
* @param departureTime Unix timestamp of departure
* @return Minutes until departure (0 if already departed)
*/
int calculateETA(time_t departureTime);
/**
* Remove all spaces from a string (leading, trailing, and middle)
* Modifies the string in-place
* @param str String to strip spaces from
*/
void stripSpaces(char* str);
/**
* Remove all bracket characters from a string: < [ { ( ) } ] >
* Modifies the string in-place
* @param str String to strip brackets from
*/
void stripBrackets(char* str);
#endif // DEPARTUREDATA_H