@riaskov/metro-ru
v1.0.18
Published
Russian metro stations data
Downloads
17
Maintainers
Readme
Metro RU
Russian Cities metro (subway) stations data with methods for calculating a distance between given coordinate and station (using Haversine formula):
- Moscow Metro
- Saint Petersburg Metro
- Kazan Metro
- Ekaterinburg Metro
- in progress Nizhny Novgorod Metro
- in progress Novosibirsk Metro
- in progress Samara Metro
TODO
- add English translation of stations names
- add an address of each station
- automatically push browser minified version to CDN
- create super-minimal (<10 KBytes; now it's 40 KBytes) version for browser
- add mocha/chai tests
API
Data structures
Available cities:
enum City {
Moscow = "Moscow",
SaintPetersburg = "SaintPetersburg",
Ekaterinburg = "Ekaterinburg",
Kazan = "Kazan"
}
Metro station description:
interface MetroStation {
name: string
nameTranslit: string
lat: number
lon: number
lineColor: string
lineName: string
lineNameTranslit: string
order: number
}
| Field | Type | Description |
|--------------------|----------|------------------------------------------------------------------|
| name
| string
| Russian name of station |
| nameTranslit
| string
| Transliterated name of station |
| lat
| number
| Latitude of your coordinate |
| lon
| number
| Longitude of your coordinate |
| lineColor
| string
| Color of the line in #HEX |
| lineName
| string
| Russian name of the line |
| lineNameTranslit
| string
| Transliterated name of the line |
| order
| number
| Order of the station in the line (from 0 - the Northern station) |
Functions
Getting the closest station by city and coordinate (Lat+Lon)
function getClosestStation(
city: City,
lat: number,
lon: number,
): [MetroStation, number] | null
Params:
| Param | Type | Description |
|--------|----------|------------------------------|
| city
| City
| Name of the city in Russian |
| lat
| number
| Latitude of your coordinate |
| lon
| number
| Longitude of your coordinate |
Returns the closest station (MetroStation-part) with distance in meters (number-part) from the given coordinate.
Returns null
if you pass an incorrect city name.
Example:
import { City, getClosestStation } from "@riaskov/metro-ru"
console.log(getClosestStation(City.Moscow, 55.640918, 37.754337))
[
{
name: 'Алма-Атинская',
nameTranslit: 'Alma-Atinskaya',
lat: 55.63349,
lon: 37.765678,
lineColor: '#4FB04F',
lineName: 'Замоскворецкая',
lineNameTranslit: 'Zamoskvoretskaya',
order: 21
},
1090
]
Getting the N closest stations by city and coordinate (Lat+Lon)
import { City, getClosestStations } from "@riaskov/metro-ru"
function getClosestStations(
city: City,
lat: number,
lon: number,
n: number,
): [MetroStation, number][] | null
Params:
| Param | Type | Description |
|--------|----------|------------------------------|
| city
| City
| Name of the city in Russian |
| lat
| number
| Latitude of your coordinate |
| lon
| number
| Longitude of your coordinate |
Returns an array of N closest stations (MetroStation-part) with distances in meters (number-part)
(array of tuples like [MetroStation, number]
).
Returns null
if you pass an incorrect city name.
Example:
import { getClosestStations } from '@riaskov/metro-ru'
console.log(getClosestStations(City.Moscow, 55.640918, 37.754337, 2))
[
[
{
name: 'Алма-Атинская',
nameTranslit: 'Alma-Atinskaya',
lat: 55.63349,
lon: 37.765678,
lineColor: '#4FB04F',
lineName: 'Замоскворецкая',
lineNameTranslit: 'Zamoskvoretskaya',
order: 21
},
1090
],
[
{
name: 'Марьино',
nameTranslit: 'Marino',
lat: 55.649158,
lon: 37.743844,
lineColor: '#BED12C',
lineName: 'Люблинско-Дмитровская',
lineNameTranslit: 'Lyublinsko-Dmitrovskaya',
order: 16
},
1128
]
]
License
MIT (see the LICENSE file).
Acknowledgements
This project uses Open Data files provided data.mos.ru (Creative Commons Attribution 3.0)