Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nearest-mrt

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nearest-mrt

Helper function for geospatial feature engineering

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

nearest-mrt

A helper function for geospatial feature engineering. To find the nearest MRT station given a location's longitude & latitude.

Credits Singapore Land Authority (SLA) OneMap API service for location data.

To use

npm install --save nearest-mrt
import getNearestMrt from 'nearest-mrt'

const target = [103.736083, 1.341832]

/**
 * @param lnglat - coordinates of query location (required)
 * @param excludeFuture - whether to exclude future stations ({boolean}, default false)
 * @param radius - limit radius of search in meters ({numeric}, default 1000)
 */
const nearestMRT = getNearestMrt(target, false, 2000)
console.log(nearestMRT)

Sample output

{
  "query": {
    "lnglat": [
      103.736083,
      1.341832
    ],
    "excludeFuture": false,
    "radius": 2000
  },
  "result": [
    {
      "rank": 1,
      "station": {
        "name": "CHINESE GARDEN",
        "code": "EW25",
        "longitude": 103.7327666,
        "latitude": 1.3422449,
        "x": 16809.69,
        "y": 36044.45,
        "line": {
          "NSL": 0,
          "EWL": 1,
          "CGL": 0,
          "NEL": 0,
          "CCL": 0,
          "DTL": 0,
          "TEL": 0,
          "JRL": 0
        },
        "operational": 1,
        "interchange": 0,
        "locations": [
          {
            "platform": "EW25",
            "longitude": 103.7327663,
            "latitude": 1.3422443,
            "x": 16809.65,
            "y": 36044.37
          }
        ],
        "transfers": []
      },
      "distance": 372
    },
    {
      "rank": 2,
      "station": {
        "name": "JURONG EAST",
        "code": "NS1 EW24 JE5",
        "longitude": 103.7421539,
        "latitude": 1.3332951,
        "x": 17854.36,
        "y": 35054.77,
        "line": {
          "NSL": 1,
          "EWL": 1,
          "CGL": 0,
          "NEL": 0,
          "CCL": 0,
          "DTL": 0,
          "TEL": 0,
          "JRL": 2
        },
        "operational": 1,
        "interchange": 1,
        "locations": [
          {
            "platform": "NS1",
            "longitude": 103.7422651,
            "latitude": 1.3330741,
            "x": 17866.73,
            "y": 35030.34
          },
          {
            "platform": "EW24",
            "longitude": 103.7422651,
            "latitude": 1.3330741,
            "x": 17866.73,
            "y": 35030.34
          }
        ],
        "transfers": [
          {
            "from": "NSL",
            "to": "EWL",
            "distance": 0
          },
          {
            "from": "EWL",
            "to": "NSL",
            "distance": 0
          }
        ]
      },
      "distance": 1161
    },
    {
      "rank": 3,
      "station": {
        "name": "BUKIT BATOK",
        "code": "NS2",
        "longitude": 103.7495558,
        "latitude": 1.348992,
        "x": 18678.17,
        "y": 36790.44,
        "line": {
          "NSL": 1,
          "EWL": 0,
          "CGL": 0,
          "NEL": 0,
          "CCL": 0,
          "DTL": 0,
          "TEL": 0,
          "JRL": 0
        },
        "operational": 1,
        "interchange": 0,
        "locations": [
          {
            "platform": "NS2",
            "longitude": 103.7495554,
            "latitude": 1.3489914,
            "x": 18678.13,
            "y": 36790.36
          }
        ],
        "transfers": []
      },
      "distance": 1695
    },
    {
      "rank": 4,
      "station": {
        "name": "LAKESIDE",
        "code": "EW26",
        "longitude": 103.7209246,
        "latitude": 1.3442249,
        "x": 15491.81,
        "y": 36263.44,
        "line": {
          "NSL": 0,
          "EWL": 1,
          "CGL": 0,
          "NEL": 0,
          "CCL": 0,
          "DTL": 0,
          "TEL": 0,
          "JRL": 0
        },
        "operational": 1,
        "interchange": 0,
        "locations": [
          {
            "platform": "EW26",
            "longitude": 103.7209243,
            "latitude": 1.3442242,
            "x": 15491.77,
            "y": 36263.36
          }
        ],
        "transfers": []
      },
      "distance": 1708
    }
  ],
  "accurateAsOf": 1539273600000
}

If you prefer a CSV output

const nearestMRT = getNearestMrt(target, false, 2000)
console.log(nearestMRT.toFlatObjects())
console.log(nearestMRT.toTable())
console.log(nearestMRT.toCSV())

Sample flat object output:

Sample CSV output

Interpreting output

  • 0 - False
  • 1 - True
  • 2 - Will be true in future (Planned but under construction)

Keywords

FAQs

Package last updated on 29 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc