{"id":20618923,"url":"https://github.com/ereminiu/spb-subway","last_synced_at":"2025-10-29T11:46:57.287Z","repository":{"id":157995517,"uuid":"615406946","full_name":"ereminiu/spb-subway","owner":"ereminiu","description":"SPB subway simulator","archived":false,"fork":false,"pushed_at":"2023-04-28T08:46:26.000Z","size":32,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T20:02:36.785Z","etag":null,"topics":["dijkstra","dijkstra-algorithm","dijkstra-shortest-path","go","golang","levenshtein-distance","subway","subway-time","subway-train","web","web-app","web-application"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ereminiu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-17T16:10:55.000Z","updated_at":"2024-06-11T02:43:14.000Z","dependencies_parsed_at":"2024-06-21T19:10:35.127Z","dependency_job_id":"9033d89b-ba71-4b19-879c-78d3ada4fff3","html_url":"https://github.com/ereminiu/spb-subway","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ereminiu%2Fspb-subway","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ereminiu%2Fspb-subway/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ereminiu%2Fspb-subway/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ereminiu%2Fspb-subway/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ereminiu","download_url":"https://codeload.github.com/ereminiu/spb-subway/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224911752,"owners_count":17390845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dijkstra","dijkstra-algorithm","dijkstra-shortest-path","go","golang","levenshtein-distance","subway","subway-time","subway-train","web","web-app","web-application"],"created_at":"2024-11-16T12:09:55.892Z","updated_at":"2025-10-29T11:46:57.203Z","avatar_url":"https://github.com/ereminiu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spb-subway\n\n(scroll down for english description)\n\nСимулятор метро Санкт Петербурга. *Yandex metro clone\n\n## Функции\n0) Отрисовывает карту метро\n1) Находит самый короткий путь между заданными станциями \n2) Отрисовывает оптимальный маршрут на экран и выводит его время\n3) Исправляет ошибки ввода и неправильную раскладку клавиатуры\n\n### 0. Отображение карты метро\n\n![image](https://user-images.githubusercontent.com/111375726/226001931-1626532b-4c38-4973-90ad-c2603d3cf7f2.png)\n\nHomeHandler (handlers/handlers.go) загружает файл assets/stations.json, получает информацию про станции и расстояния между ними, затем отобржает их в index.tmpl, строит неориентированный взвешенный граф по нему. Также HomeHandler сохраняет названия станций и сортирует их в алфавитном порядке. \n\nструктура stations.json:\n\n```json\n\"st_g0\": {\n  \"Name\": \"Беговая\",\n  \"X\": 93,\n  \"Y\": 140,\n  \"Adj\": [\"st_g1\"],\n  \"Dist\": [4],\n  \"Line\": \"green\",\n  \"Shift\": \"left\",\n  \"Dx\": 0,\n  \"Dy\": 0\n}\n```\n\nName, X, Y, Line означает название станции, позиция по X Y и цвет ветки соответственно. Adj - станции, на которые можно проехать от данной станции, Dist - время проезда до них, Shift - с какой стороны находится текст относительно X, Y. Dx, Dy - смешение текста по X, Y. \n\n### 1. Поиск самого короткого пути между станциями \nFindRouteHandler (handlers/handlers.go) считывает две строки from, to из формы index.tmpl, находит подходящую станцию (см п.3), находит оптимальный маршрут и его время. \n\nКратчайший путь находится с помощью алгоритма Дейкстры (dijkstra/dijkstra.go), который принимает номера станций в алфавитном порядке, возвращает минимальное время и массив из номеров станций, которые входят в этот путь. \n\nпример.\n| From      | To           | Best route                                                                    | Duration |\n|-----------|--------------|:-----------------------------------------------------------------------------:|---------:|\n|Горьковская|Обводный канал|Горьковская, Невский, проспект, Сенная, Садовая, Звенигородская, Обводный канал| 18 минут |\n\n### 2. Отображение кратчайшего маршрута.\n\n![image](https://user-images.githubusercontent.com/111375726/226002641-9811083e-3962-4493-bf20-741bdd26c923.png)\n\nShowRouteHandler (handlers/handlers.go) строит карту метро, к ребрам не входящим в кратчайший маршрут добавляется эффект прозрачности 80%. \n\n### 3. Исправление ошибок ввода и неправильной раскладки клавиатуры\n..* utils.EnToRu(s) - приминает строку, возвращает строку с замененными английскими буквами на русские, находящиеся на тех же клавищах клавиатуры. \n\n..* getIdx(s) - возвращает максимально \"похожую\" на s строку из всех названий станций. Строка s1 больше похоже на строку s, чем s2, если расстояние Левенштейна (utils.EditDistance()) между s1 и s меньше, чем между s2 и s. \n\n#### English desription.\n\nSaint Petersburg subway simulator. *Yandex metro clone\n\n## Functions \n0) Draw subway map\n1) Find the shortes path between given stations\n2) Draw this route\n3) Correct mistakes in input\n\n### 0. Subway stations drawing \n\n![image](https://user-images.githubusercontent.com/111375726/226001931-1626532b-4c38-4973-90ad-c2603d3cf7f2.png)\n\nHomeHandler (handlers/handlers.go) loads asstes/stations.json file witch is describing stations, builds graph of stations and distances between them and draw it. Also HomeHandler saves stations names and sort them in alphabetic order. \n\nstations.json structure: \n\n```json\n\"st_g0\": {\n  \"Name\": \"Беговая\",\n  \"X\": 93,\n  \"Y\": 140,\n  \"Adj\": [\"st_g1\"],\n  \"Dist\": [4],\n  \"Line\": \"green\",\n  \"Shift\": \"left\",\n  \"Dx\": 0,\n  \"Dy\": 0\n}\n```\n\nName, X, Y, Line stands for station name, X Y position and color of branch respectively. Adj is array of stations connecting with this one. Dist - time to reach them, Shift - offset side of the text. Dx, Dy - text shift by X and Y. \n\n### 1. Search the shortest route between given stations\nFindRouteHandler (handlers/handlers.go) reads two string \"from\", \"to\" from the form in index.tmpl page, find the station you mean (p.3) and, finally, search the best route between from and to. \n\nDijkstra algorithm (dijkstra/dijkstra.go) return the shortest path between two nodes. \n\n### 2. Shortest route Visualization \n\n![image](https://user-images.githubusercontent.com/111375726/226002641-9811083e-3962-4493-bf20-741bdd26c923.png)\n\nShowRouteHandler (handlers/handlers.go) builds subway map. Edges wich are not in shortest path are drawing transparent. \n\n### 3. Input mistakes correction\n\ngetIdx(s) - returns the most similar stations name to s. Similarity between string s and string t is the Levenshtein distance from s to t. Levenshtein distance is a string metric for measuring the difference between two strings. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fereminiu%2Fspb-subway","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fereminiu%2Fspb-subway","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fereminiu%2Fspb-subway/lists"}