PageSourceSearch

https://vsn.ru/src/gar.js

js vsn.ru collected 2026-10-01 07:36:37 UTC 9,520 bytes, 221 lines download raw bytes

1export const garSource = {
2  fallback: "demo/src/gar.js",
3  module: "admin-vsn-parser/app/gar.py",
4  service: "admin.vsn.ru",
5};
6
7export const garRegionOptions = [
8  { type: "city", city: "Москва", label: "г Москва", count: 843480, priority: true },
9  { type: "region", value: "Московская область", label: "обл Московская", count: 627126, priority: true },
10  { type: "city", city: "Санкт-Петербург", label: "г Санкт-Петербург", count: 456772, priority: true },
11  { type: "region", value: "Ленинградская область", label: "обл Ленинградская", count: 273813, priority: true },
12  { type: "region", value: "Республика Адыгея", label: "Респ Адыгея", count: 35415 },
13  { type: "region", value: "Республика Алтай", label: "Респ Алтай", count: 9810 },
14  { type: "region", value: "Алтайский край", label: "край Алтайский", count: 51903 },
15  { type: "region", value: "Амурская область", label: "обл Амурская", count: 12620 },
16  { type: "region", value: "Архангельская область", label: "обл Архангельская", count: 20419 },
17  { type: "region", value: "Астраханская область", label: "обл Астраханская", count: 31257 },
18  { type: "region", value: "Республика Башкортостан", label: "Респ Башкортостан", count: 109807 },
19  { type: "region", value: "Республика Бурятия", label: "Респ Бурятия", count: 11664 },
20  { type: "region", value: "Белгородская область", label: "обл Белгородская", count: 40755 },
21  { type: "region", value: "Брянская область", label: "обл Брянская", count: 26944 },
22  { type: "region", value: "Владимирская область", label: "обл Владимирская", count: 27640 },
23  { type: "region", value: "Волгоградская область", label: "обл Волгоградская", count: 38205 },
24  { type: "region", value: "Вологодская область", label: "обл Вологодская", count: 18470 },
25  { type: "region", value: "Воронежская область", label: "обл Воронежская", count: 61240 },
26  { type: "region", value: "Камчатский край", label: "край Камчатский", count: 7410 },
27  { type: "region", value: "Краснодарский край", label: "край Краснодарский", count: 182940 },
28  { type: "region", value: "Новосибирская область", label: "обл Новосибирская", count: 76850 },
29  { type: "region", value: "Республика Татарстан", label: "Респ Татарстан", count: 94120 },
30  { type: "region", value: "Ростовская область", label: "обл Ростовская", count: 88940 },
31  { type: "city", city: "Севастополь", label: "г Севастополь", count: 18630 },
32];
33
34export function garRegionGroups() {
35  const priority = garRegionOptions.filter((option) => option.priority);
36  const regular = garRegionOptions.filter((option) => !option.priority);
37  const groups = new Map();
38
39  regular.forEach((option) => {
40    const letter = option.label.replace(/^(г|обл|край|Респ)\s+/i, "").charAt(0).toUpperCase();
41    if (!groups.has(letter)) groups.set(letter, []);
42    groups.get(letter).push(option);
43  });
44
45  return [
46    { id: "priority", title: "", items: priority },
47    ...[...groups.entries()]
48      .sort(([left], [right]) => left.localeCompare(right, "ru"))
49      .map(([title, items]) => ({
50        id: title,
51        title,
52        items: items.sort((left, right) => left.label.localeCompare(right.label, "ru")),
53      })),
54  ];
55}
56
57export const garMetroSystems = {
58  Москва: {
59    city: "Москва",
60    source: "GAR transport adapter",
61    lines: [
62      {
63        id: "sokolnicheskaya",
64        name: "Сокольническая",
65        color: "#d71920",
66        stations: [
67          { id: "park-kultury", name: "Парк культуры", x: 34, y: 45, count: 146 },
68          { id: "okhotny-ryad", name: "Охотный Ряд", x: 42, y: 34, count: 88 },
69          { id: "kropotkinskaya", name: "Кропоткинская", x: 38, y: 40, count: 112 },
70          { id: "prokshino", name: "Прокшино", x: 64, y: 74, count: 156 },
71        ],
72      },
73      {
74        id: "zamoskvoretskaya",
75        name: "Замоскворецкая",
76        color: "#2a9b46",
77        stations: [
78          { id: "belorusskaya", name: "Белорусская", x: 48, y: 25, count: 92 },
79          { id: "tverskaya", name: "Тверская", x: 46, y: 36, count: 134 },
80          { id: "avtozavodskaya", name: "Автозаводская", x: 56, y: 61, count: 73 },
81        ],
82      },
83      {
84        id: "arbatsko-pokrovskaya",
85        name: "Арбатско-Покровская",
86        color: "#0072bc",
87        stations: [
88          { id: "arbatskaya", name: "Арбатская", x: 34, y: 37, count: 108 },
89          { id: "ploshchad-revolyutsii", name: "Площадь Революции", x: 43, y: 38, count: 64 },
90          { id: "kievskaya", name: "Киевская", x: 26, y: 48, count: 121 },
91        ],
92      },
93      {
94        id: "bolshaya-koltsevaya",
95        name: "Большая кольцевая",
96        color: "#82c0c0",
97        stations: [
98          { id: "delovoy-tsentr", name: "Деловой центр", x: 28, y: 38, count: 77 },
99          { id: "ramenki", name: "Раменки", x: 22, y: 58, count: 96 },
100          { id: "tekstilshchiki", name: "Текстильщики", x: 64, y: 58, count: 58 },
101        ],
102      },
103    ],
104    interchanges: [
105      ["park-kultury"],
106      ["tverskaya", "okhotny-ryad"],
107      ["arbatskaya", "kropotkinskaya"],
108    ],
109  },
110  "Санкт-Петербург": {
111    city: "Санкт-Петербург",
112    source: "GAR transport adapter",
113    lines: [
114      {
115        id: "spb-red",
116        name: "Кировско-Выборгская",
117        color: "#d71920",
118        stations: [
119          { id: "vasileostrovskaya", name: "Василеостровская", x: 30, y: 44, count: 84 },
120          { id: "ploshchad-vosstaniya", name: "Площадь Восстания", x: 50, y: 35, count: 102 },
121        ],
122      },
123      {
124        id: "spb-blue",
125        name: "Московско-Петроградская",
126        color: "#0072bc",
127        stations: [
128          { id: "gorkovskaya", name: "Горьковская", x: 42, y: 28, count: 72 },
129          { id: "moskovskaya", name: "Московская", x: 58, y: 68, count: 116 },
130          { id: "pionerskaya", name: "Пионерская", x: 34, y: 22, count: 68 },
131        ],
132      },
133    ],
134    interchanges: [],
135  },
136  Казань: {
137    city: "Казань",
138    source: "GAR transport adapter",
139    lines: [
140      {
141        id: "kazan-central",
142        name: "Центральная",
143        color: "#d71920",
144        stations: [
145          { id: "ploshchad-tukaya", name: "Площадь Тукая", x: 38, y: 40, count: 88 },
146          { id: "kozya-sloboda", name: "Козья слобода", x: 48, y: 30, count: 64 },
147          { id: "gorki", name: "Горки", x: 62, y: 62, count: 51 },
148          { id: "ametyevo", name: "Аметьево", x: 54, y: 52, count: 47 },
149        ],
150      },
151    ],
152    interchanges: [],
153  },
154  Новосибирск: {
155    city: "Новосибирск",
156    source: "GAR transport adapter",
157    lines: [
158      {
159        id: "leninskaya",
160        name: "Ленинская",
161        color: "#d71920",
162        stations: [
163          { id: "ploshchad-lenina", name: "Площадь Ленина", x: 44, y: 38, count: 76 },
164          { id: "zaeltsovskaya", name: "Заельцовская", x: 38, y: 24, count: 58 },
165          { id: "studenchenskaya", name: "Студенческая", x: 52, y: 58, count: 44 },
166        ],
167      },
168      {
169        id: "dzerzhinskaya",
170        name: "Дзержинская",
171        color: "#2a9b46",
172        stations: [
173          { id: "oktyabrskaya", name: "Октябрьская", x: 55, y: 44, count: 63 },
174          { id: "berezovaya-roshcha", name: "Березовая роща", x: 68, y: 34, count: 39 },
175        ],
176      },
177    ],
178    interchanges: [],
179  },
180};
181
182export function garMetroSystemFor(cityName) {
183  const system = garMetroSystems[cityName];
184  if (system) return system;
185
186  return {
187    city: cityName,
188    source: "GAR transport adapter",
189    lines: [],
190    interchanges: [],
191  };
192}
193
194export function garMetroStationsFor(cityName) {
195  return garMetroSystemFor(cityName).lines.flatMap((line) => (
196    line.stations.map((station) => ({
197      ...station,
198      color: line.color,
199      lineId: line.id,
200      lineName: line.name,
201    }))
202  ));
203}
204
205export function cityBelongsToGarRegion(city, region) {
206  if (!city) return false;
207  const cityRegion = normalizeGarText(city.region);
208  const requestedRegion = normalizeGarText(region);
209  return cityRegion.includes(requestedRegion) || requestedRegion.includes(cityRegion);
210}
211
212export function normalizeGarText(value) {
213  return String(value || "")
214    .toLowerCase()
215    .replace(/^г\s+/u, "")
216    .replace(/^обл\s+/u, "")
217    .replace(/^край\s+/u, "")
218    .replace(/^респ\s+/u, "республика ")
219    .replace(/\s+и\s+/gu, " ")
220    .trim();
221}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.