Skip to content

Commit

Permalink
implement cli & static renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
morganherlocker committed Jul 15, 2019
1 parent e7f2d9a commit 2d3fd91
Show file tree
Hide file tree
Showing 19 changed files with 1,798 additions and 635 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ typings/

# default data dirs
data
graph
shst
cache
public

# config
config.json
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CHANGELOG
---

## 1.4.0

- deprecate server in favor of static site
- introduce mobility-metrics CLI
- add example directory, including scripts to reproduce the public demo with 4 simulated providers in Nashville, TN
- add report directory listing (no more guessing which days have data)
- fleet size tracker
- configurable map zoom
- Custom mapbox layer (enables custom polygons in the background) feature
- setup changelog docs
- add geometry type to geojson export file name behavior feature
- log version when generating backfill feature
- set date in UI to 1 day prior to current behavior ui
2 changes: 2 additions & 0 deletions assets/d3.v5.min.js

Large diffs are not rendered by default.

Binary file added assets/shst-logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions example/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"boundary": [
-86.84881210327148,
36.12262352221241,
-86.73688888549805,
36.2049447642222
],
"center": [-86.77705764770508, 36.16202793326575],
"privacyMinimum": 3,
"providers": {
"Flipr": {
"type": "local",
"trips": "example/data/Flipr/trips.json",
"status_changes": "example/data/Flipr/changes.json",
"enabled": true
},
"Scoob": {
"type": "local",
"trips": "example/data/Scoob/trips.json",
"status_changes": "example/data/Scoob/changes.json",
"enabled": true
},
"BikeMe": {
"type": "local",
"trips": "example/data/BikeMe/trips.json",
"status_changes": "example/data/BikeMe/changes.json",
"enabled": true
},
"Spuun": {
"type": "local",
"trips": "example/data/Spuun/trips.json",
"status_changes": "example/data/Spuun/changes.json",
"enabled": true
}
}
}
68 changes: 68 additions & 0 deletions example/simulate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const path = require("path");
const fs = require("fs");
const rimraf = require("rimraf");
const mkdirp = require("mkdirp");
const moment = require("moment");
const exec = require("child_process").execSync;

console.log("setting up data...");
const dir = path.join(__dirname, "data");
rimraf.sync(dir);
mkdirp.sync(dir);

console.log("generating graph...");
const graph = path.join(__dirname, "graph");
rimraf.sync(graph);
mkdirp.sync(graph);
exec(
"curl https://s3.amazonaws.com/metro-extracts.nextzen.org/nashville_tennessee.osm.pbf -o graph/nashville.osm.pbf"
);
exec(
'osmium extract -b "-86.84881210327148,36.12262352221241,-86.73688888549805,36.2049447642222" graph/nashville.osm.pbf -o graph/nash.osm.pbf -s "complete_ways"'
);
exec(
"../node_modules/osrm/lib/binding/osrm-extract graph/nash.osm.pbf -p ../node_modules/osrm/profiles/foot.lua;"
);
exec("../node_modules/osrm/lib/binding/osrm-contract graph/nash.osrm");

const providers = ["Flipr", "Scoob", "BikeMe", "Spuun"];

const days = 45;

const start = 1563087600000; // Sunday, July 14, 2019 3:00:00 AM GMT-04:00

var cmd = "trip-simulator ";
cmd += "--config scooter ";
cmd += "--pbf graph/nash.osm.pbf ";
cmd += "--graph graph/nash.osrm ";
cmd += "--agents {agents} ";
cmd += "--start {start} ";
cmd += "--seconds 60000 ";
cmd += "--changes data/{provider}/changes.json ";
cmd += "--trips data/{provider}/trips.json ";
cmd += "--quiet ";

const minAgents = 25;
const maxAgents = 200;

console.log("running simulations...");

for (var day = 1; day <= days; day++) {
console.log(day + " / " + days);
console.log("- - -");
const time = start + day * 86400000;

for (let provider of providers) {
console.log(" " + provider);
mkdirp.sync(path.join(dir, provider));
const agents = Math.round(
Math.random() * (maxAgents - minAgents) + minAgents
);

var run = cmd;
run = run.split("{agents}").join(agents);
run = run.split("{start}").join(time.toString());
run = run.split("{provider}").join(provider);
exec(run);
}
}
Loading

0 comments on commit 2d3fd91

Please sign in to comment.