aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/app/config/RegionConfig.ts
blob: 8acfbbf89a43e6c083430d635c8a0e139ea65dcd (plain)
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
export type RegionId = "vigo";

export interface RegionConfig {
  id: RegionId;
  name: string;
  stopsEndpoint: string;
  estimatesEndpoint: string;
  consolidatedCirculationsEndpoint: string | null;
  timetableEndpoint: string | null;
  defaultCenter: [number, number]; // [lat, lng]
  bounds?: {
    sw: [number, number];
    ne: [number, number];
  };
  textColour?: string;
  defaultZoom: number;
  showMeters: boolean; // Whether to show distance in meters
}

export const REGIONS: Record<RegionId, RegionConfig> = {
  vigo: {
    id: "vigo",
    name: "Vigo",
    stopsEndpoint: "/stops/vigo.json",
    estimatesEndpoint: "/api/vigo/GetStopEstimates",
    consolidatedCirculationsEndpoint: "/api/vigo/GetConsolidatedCirculations",
    timetableEndpoint: "/api/vigo/GetStopTimetable",
    defaultCenter: [42.229188855975046, -8.72246955783102],
    bounds: {
      sw: [-8.951059, 42.098923],
      ne: [-8.447748, 42.3496],
    },
    textColour: "#e72b37",
    defaultZoom: 14,
    showMeters: true,
  },
};

export const DEFAULT_REGION: RegionId = "vigo";

export function getRegionConfig(regionId: RegionId): RegionConfig {
  return REGIONS[regionId];
}

export function getAvailableRegions(): RegionConfig[] {
  return Object.values(REGIONS);
}

export function isValidRegion(regionId: string): regionId is RegionId {
  return regionId === "vigo";
}