npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@riaskov/metro-ru

v1.0.18

Published

Russian metro stations data

Downloads

24

Readme

Metro RU

Module type: MinChrome Module type: MinNode Module type: CJS+ESM Module type: target-ES2016

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)