Comments (4)
@thekaveman To run the tooling out of the box, you need to have credentials to an active MDS endpoint (I have a feeling you have these, so feel free to email me for help setting up securely: [email protected]). There is a generic stream interface we use for status_changes and trips, and we have implemented a couple providers, with more on the way soon:
https://github.com/sharedstreets/sharedstreets-mobility-metrics/blob/master/src/providers/
The generic stream interface is subject to change a bit, but the basics are that each provider needs a changes
and trips
function that takes a stream to write to, a start timestamp, and a stop timestamp. Using this interface has made it easier to smooth over the auth and pagination quirks of each provider, as I've seen you and Hunter run into elsewhere. This project currently runs tests against a live MDS endpoint, which the stream interface has worked well to enable, but it also means only people with a specific set of provider creds can run the tests. This is far from ideal.
I have been working on another project called sharedstreets/trip-simulator, which aims to provide highly realistic synthetic trip data. I'm currently working to add support for MDS compliant data, with synthesized status_change events, in addition to the existing raw GPS. The goal is to be able to safely demo this for any city interested in implementing MDS, before having to get providers & legislators/regulators on board to acquire credentials. This would also allow for running tests against the metrics, guaranteeing that everyone (agencies & providers) is calculating regulatory heuristics with an aligned set of algorithms, regardless of implementation, helping with overall trust of the systems. All that said, trip-simulator essentially outputs giant line-delimitted JSON files, so I'll be digging into this shortly. Feel free to email me if you would like a hand writing a custom provider for the private data you have available for testing.
from mobility-metrics.
Yep, something like this would totally work. Line delimitted is used by trip-simulator just to make it easier to generate and ingest very large datasets, but normal JSON works too (and can be streamed with a bit more effort).
Assuming you had two files in your root directory that were simply big arrays of MDS trips and changes, something like this should do the trick:
const trips = require('../../trips.json')
const changes = require('../../changes.json')
function trips(stream, start, stop) {
trips
.filter(trip => {
return trip.start_time >= start && trip.start_time < stop
})
.forEach(trip => {
stream.write(trip)
})
stream.end();
}
function changes(stream, start, stop) {
changes
.filter(change => {
return change.event_time >= start && change.event_time < stop
})
.forEach(change => {
stream.write(change)
})
stream.end();
}
module.exports.trips = trips;
module.exports.changes = changes;
Update: added time filter, so you can split a big file into daily aggregates
from mobility-metrics.
All that said, trip-simulator essentially outputs giant line-delimitted JSON files, so I'll be digging into this shortly. Feel free to email me if you would like a hand writing a custom provider for the private data you have available for testing.
Interesting plans indeed. I may take a stab at an implementation for JSON files. You mention line-delimited, what are your thoughts on support for something closer to the raw MDS output format? e.g. for /trips
:
{
"version": "x.y.z",
"data": {
"trips": [{
"provider_id": "...",
"device_id": "...",
},
{
"provider_id": "...",
"device_id": "...",
}]
}
}
(or potentially an array of these objects, representing each of the "pages" of an API request)
from mobility-metrics.
This is now officially supported. To use a local provider, config a provider with local paths for trips and status_changes, then change the type to "local". Data should be line delimited JSON items in the MDS record level format.
"Synth": {
"type": "local",
"trips": "./sample/trips.json",
"status_changes": "./sample/changes.json",
"enabled": true
}
from mobility-metrics.
Related Issues (20)
- trip & status hashing HOT 1
- report hashing HOT 1
- Add report signature to report interface HOT 1
- export all dump failure HOT 1
- bug in weekly aggregates
- Map visualizations over an arbitrary date range HOT 2
- Make the timezone configurable
- Add ability to specify MDS version HOT 2
- document config options HOT 1
- Ability to configure which summary statistics appear HOT 2
- MDS specifies min_end_time query parameter for trips, but this uses start_time & end_time HOT 5
- add hover popup showing stats on maps
- polygon filter HOT 1
- vehicle type filter HOT 1
- docker based deployment HOT 1
- [Nodejs 12] Problem with Mapbox dependency during installation HOT 2
- --version,-v flag HOT 1
- Zones optionality brakes geo aggregation
- Problem installing mobility-metrics on Linux HOT 1
- Add User-Agent to Header HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mobility-metrics.