Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including merge-vbb-stations with all npm packages installed. Try it out:

var mergeVbbStations = require("merge-vbb-stations")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

merge-vbb-stations v2.0.1

Heuristic to find VBB stations & stops that should be one.

merge-vbb-stations

Heuristic to find VBB stations & stops that should be one. Check out the automatic report!

npm version build status ISC-licensed chat on gitter support me on Patreon

Installing

npm install merge-vbb-stations

Usage

const analyze = require('merge-vbb-stations')

const s1 = {
    type: 'station',
    id: '900000003174',
    name: 'U Turmstr. (Berlin) [Bus Turmstr.]',
    coordinates: {latitude: 52.5263, longitude: 13.341988},
    weight: 5533.75,
    stops: [
        {
            type: 'stop',
            id: '070101000700',
            name: 'U Turmstr. (Berlin) [Bus Turmstr.]',
            station: '900000003174',
            coordinates: {latitude: 52.5263, longitude: 13.341988}
        }
        // …
    ]
}

const s2 = {
    type: 'station',
    id: '900000003104',
    name: 'U Turmstr. (Berlin)',
    coordinates: {latitude: 52.525938, longitude: 13.341417},
    weight: 2408,
    stops: [
        {
            type: 'stop',
            id: '070201092701',
            name: 'U Turmstr. (Berlin)',
            station: '900000003104',
            coordinates: {latitude: 52.525938, longitude: 13.341417}
        }
    ]
}

analyze(s1, s2)
{
    op: 'merge',
    src: /* s1 */,
    dest: /* s2 */,
    stopName: 'Bus Turmstr.'
}

API

analyze(station1, station2) will return either null (don't merge) or an object. The object looks like this:

  • op: right now, this can only be analyze.MERGE
  • src: station to merge from
  • dest: station to merge into
  • stopName: which name to use for the stops of src; if null, use the stops's original name

todo: s1.coordinates & s2.coordinates

Contributing

If you have a question or have difficulties using merge-vbb-stations, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free