added all files to project

This commit is contained in:
2022-03-10 10:36:59 +01:00
parent 09dd957b33
commit 46a936d7de
25351 changed files with 3883356 additions and 0 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+31
View File
@@ -0,0 +1,31 @@
'use strict'
const get = require('lodash.get')
const data = require('./simple')
const filterById = (id) => (data) =>
!!(data && ('object' === typeof data) && data.id === id)
const filterByKeys = (pattern) => (data) => {
if (!data || 'object' !== typeof data) return false
for (let key in pattern) {
if (get(data, key) !== pattern[key]) return false
}
return true
}
const stations = (pattern) => {
let matcher
if (pattern === 'all' || pattern === undefined) matcher = () => true
else if ('object' === typeof pattern) matcher = filterByKeys(pattern)
else matcher = filterById(pattern) // todo: make this more efficient
return data.filter(matcher)
}
module.exports = Object.assign(stations, {filterById, filterByKeys})
@@ -0,0 +1,5 @@
Copyright (c) 2021, Jannis R
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,89 @@
{
"_from": "vbb-stations@^7.1.0",
"_id": "vbb-stations@7.3.2",
"_inBundle": false,
"_integrity": "sha512-KETDgdAFmnfvRgGWg0fLT2/0ZxZiyYWxt4Ggy4Bsco+zpjBGPZxT23emR/KTBoZX9C8Y8hEoEqkPRQ7MzFmJ3g==",
"_location": "/vbb-stations",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "vbb-stations@^7.1.0",
"name": "vbb-stations",
"escapedName": "vbb-stations",
"rawSpec": "^7.1.0",
"saveSpec": null,
"fetchSpec": "^7.1.0"
},
"_requiredBy": [
"/hafas-client"
],
"_resolved": "https://registry.npmjs.org/vbb-stations/-/vbb-stations-7.3.2.tgz",
"_shasum": "5b9ac17adcfe38d8a7e773a59dc6d028e10e355e",
"_spec": "vbb-stations@^7.1.0",
"_where": "/home/pi/MagicMirror/modules/MMM-PublicTransportHafas/node_modules/hafas-client",
"author": {
"name": "Jannis R",
"email": "mail@jannisr.de"
},
"bugs": {
"url": "https://github.com/derhuerst/vbb-stations/issues"
},
"bundleDependencies": false,
"dependencies": {
"lodash.get": "^4.4.2"
},
"deprecated": false,
"description": "A list of VBB stations.",
"devDependencies": {
"csv-parser": "^2.0.0",
"is-roughly-equal": "^0.1.0",
"lodash.mapvalues": "^4.6.0",
"lodash.omit": "^4.5.0",
"strip-bom-stream": "^4.0.0",
"tap-min": "^2.0.0",
"tape": "^5.0.0",
"vbb-mode-weights": "^0.2.0",
"vbb-parse-line": "^1.0.0",
"vbb-short-station-name": "^1.0.0"
},
"engines": {
"node": ">=8"
},
"files": [
"index.js",
"simple.js",
"data.json",
"full.json",
"names.json",
"vbb-logo.jpg"
],
"homepage": "https://github.com/derhuerst/vbb-stations",
"keywords": [
"vbb",
"berlin",
"brandenburg",
"public transport",
"stations",
"open data",
"json",
"ndjson",
"gtfs"
],
"license": "ISC",
"main": "index.js",
"name": "vbb-stations",
"repository": {
"type": "git",
"url": "git+https://github.com/derhuerst/vbb-stations.git"
},
"scripts": {
"build": "npm run download && npm run convert && npm run cleanup",
"cleanup": "rm build/*.csv",
"convert": "node build/convert.js",
"download": "cd build; ./download.sh",
"prepublishOnly": "npm run build && npm test",
"test": "node test.js | tap-min"
},
"version": "7.3.2"
}
+118
View File
@@ -0,0 +1,118 @@
# vbb-stations 🚏
A **collection of all stations of the [Berlin Brandenburg public transport service (VBB)](http://www.vbb.de/)**, computed from [open](https://daten.berlin.de/datensaetze/vbb-fahrplandaten-gtfs) [GTFS](https://developers.google.com/transit/gtfs/) [data](https://vbb-gtfs.jannisr.de/).
[![npm version](https://img.shields.io/npm/v/vbb-stations.svg)](https://www.npmjs.com/package/vbb-stations)
[![build status](https://img.shields.io/travis/derhuerst/vbb-stations.svg)](https://travis-ci.org/derhuerst/vbb-stations)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/vbb-stations.svg)
[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)
[![chat with me on Twitter](https://img.shields.io/badge/chat%20with%20me-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst)
## Installing
```shell
npm install vbb-stations
```
## Usage
The [npm package](https://npmjs.com/vbb-stations) contains [*Friendly Public Transport Format* 1.2.1](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.1/spec/readme.md) `station`s and `stop`s. `weight` is the sum of all arrivals & departures at a station, weighted by mode of transport.
```js
[
{
type: 'station',
id: '900000009101',
name: 'U Amrumer Str.',
location: {
type: 'location',
latitude: 52.542202,
longitude: 13.349534
},
weight: 3563
}
]
```
You can filter all stations by `id` or any property ([`lodash.get`](https://lodash.com/docs/#get) will be used).
```js
const stations = require('vbb-stations')
console.log(stations('900000009101')) // query a single station
console.log(stations({ // filter by property
weight: 3563,
'location.latitude': 52.542202
}))
```
`full.json` contains all stops of each station and unshortened names.
```js
require('vbb-stations/full.json')['900000009101']
```
One entry looks like this:
```js
{
type: 'station',
id: '900000009101',
name: 'U Amrumer Str. (Berlin)',
location: {
type: 'location',
latitude: 52.542202,
longitude: 13.349534
},
weight: 3284.25,
stops: [
{
type: 'stop',
id: '070101000865',
name: 'U Amrumer Str. (Berlin)',
station: '900000009101',
location: {
type: 'location',
latitude: 52.542202,
longitude: 13.349534
}
},
// …
{
type: 'stop',
id: '070201092402',
name: 'U Amrumer Str. (Berlin)',
station: '900000009101',
location: {
type: 'location',
latitude: 52.542202,
longitude: 13.349534
}
}
]
}
```
`names.json` contains only shortened names.
```js
require('vbb-stations/names.json')['900000009101'] // U Amrumer Str.
```
## API
`stations([pattern])`
`pattern` can be one of the following:
- a station ID, like `900000009101`
- `'all'`
- an object like `{weight: 42, name: 'Alt Pinnow'}`, with each property being mandatory
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/vbb-stations/issues).
+21
View File
@@ -0,0 +1,21 @@
'use strict'
let rawData = require('./data.json')
const simple = []
for (let s of rawData) {
simple.push({
type: 'station',
id: s[0],
name: s[1],
location: {
type: 'location',
latitude: s[3],
longitude: s[4]
},
weight: s[2]
})
}
rawData = null // allow for gc
module.exports = simple
Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB