Skip to content

Commit

Permalink
Add the example application from transition-legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
tahini committed Nov 7, 2022
1 parent 4c10ae5 commit 46810b3
Show file tree
Hide file tree
Showing 5 changed files with 307 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
This folder contains an example configuration file, as well as necessary files to run a demo of Transition. This demo corresponds to the territory of the [Réseau de transport de Longueuil](https://www.rtl-longueuil.qc.ca/) area.

# Running the demo

1. Make sure all the pre-requisites are installed. For complete installation instructions of all dependencies, see the [instructions for Ubuntu](../../docs/transition/installationUbuntu20.04.md).

2. Update the .env file and set the `PROJECT_CONFIG` to point to the config file in this directory

```
PROJECT_CONFIG=${rootDir}/examples/transition/config.js
```

3. Follow the [installations instructions](../../README.md#installation) at the root of this repo to setup the database and create users

4. Follow the [build and start instructions](../../README.md#build-and-start) at the root of this repo to compile and build the code, but do not start the nodejs server yet.

5. Get and prepare the road network for `osrm` to route. This step is optional, but required to create new lines that properly follow the road network. The first line will download the Open Street Map network data from the overpass API. The second line will prepare the data for the `osrm` servers. Data is prepared differently for different modes of tranportation. Selecting `driving` and `walking` are mandatory modes, as `driving` is the default mode for vehicles and `walking` is required to calculate access, transfer and egress times from transit.

```shell
yarn babel-node --max-old-space-size=4096 transition-app/chaire-lib/backend/lib/scripts/osrm/downloadOsmNetworkData.task.js --polygon-file examples/transition/polygon_rtl_area.geojson

yarn babel-node --max-old-space-size=4096 transition-app/chaire-lib/backend/lib/scripts/osrm/prepareOsmNetworkData.task.js
```

6. Start the nodejs server with `yarn start`.

7. Navigate to `http://localhost:8080` and log into the application.

8. Import [transit data for the Réseau de Transport de Longueuil](https://transitfeeds.com/p/reseau-de-transport-de-longueuil/37), that will work for the area of this demo. Lines and paths can be edited, added within this territory.

# Running the application for another territory

Copy or edit the config.js file and update for the area. The `projectDirectory` (where the road network will be stored) and `mapDefaultCenter` are the main fields to update. Be sure to point the `PROJECT_CONFIG` environment variable to this new file.

Download and prepare the road network data for another area. Simply save a geojson polygon feature to a file, similar to the [polygon_rtl_area.geojson](polygon_rtl_area.geojson) file. To easily create a polygon, [geojson.io](https://geojson.io) can be used.

134 changes: 134 additions & 0 deletions examples/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
module.exports = {

projectShortname: 'demo_transition',
projectDirectory: `${__dirname}/runtime/`,
auth: {
localLogin: {
allowRegistration: true,
confirmEmail: true
}
},

// Maximum number of parallel calculation
// TODO trRouting should support multi-threading so we shouldn't have to start multiple instances
// maxParallelCalculators: 2,

mapDefaultCenter: {
lat: 45.5092960,
lon: -73.4769080
},

languages: ['fr', 'en'],

locales: {
fr: 'fr-CA',
en: 'en-CA'
},

languageNames: {
fr: "Français",
en: "English"
},

title: {
fr: "Démo",
en: "Demo"
},

defaultLocale: "fr",
timezone: "America/Montreal",
gtfs: {
socketFileUploaderOptions: {
uploadDirectory : 'gtfs',
fileExtension : 'zip',
renamedFileNameWithoutExtension: 'import',
acceptTypes : ['application/zip'],
maxFileSizeMB : 256,
chunckSizeMB : 10240000,
overwriteExistingFile : true
}
},

defaultPreferences: {
osrmRouting: {
modes: {
driving: {
// !!! Be careful: use your own server, since you may be blocked on the osrm demo server after too many queries
port : 7000, // Port used to access OSRM, either locally or remotely
host : null, // If set to null, localhost will be used. Ignored if autoStart set to true
autoStart: true, // If true, a local instance of OSRM will be started
enabled : true // If true, this mode will be configured, otherwise will be left out
},
cycling: {
port : 8000,
host : null,
autoStart: true,
enabled : true
},
walking: {
port : 5001,
host : null,
autoStart: true,
enabled : true
},
bus_suburb: {
port : 7110,
host : null,
autoStart: true,
enabled : true
},
bus_urban: {
port : 7120,
host : null,
autoStart: true,
enabled : true
},
rail: {
port : 9000,
host : null,
autoStart: false,
enabled : false
},
tram: {
port : 9100,
host : null,
autoStart: false,
enabled : false
},
tram_train: {
port : 9200,
host : null,
autoStart: false,
enabled : false
},
metro: {
port : 9300,
host : null,
autoStart: false,
enabled : false
},
monorail: {
port : 9400,
host : null,
autoStart: false,
enabled : false
},
cable_car: {
port : 9500,
host : null,
autoStart: false,
enabled : false
}
}
},
transit: {
routing: {
batch: {
allowSavingOdTripsToDb: true
}
}
}
}

};

108 changes: 108 additions & 0 deletions examples/polygon_rtl_area.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
-73.45459620241586,
45.653617335517424
],
[
-73.47654816278192,
45.58565876688323
],
[
-73.5413244392731,
45.59724271457037
],
[
-73.54744219871979,
45.58540691538059
],
[
-73.53664615263793,
45.583643923225566
],
[
-73.53376720701601,
45.58742169576331
],
[
-73.48554486785049,
45.57432433065688
],
[
-73.52980865678605,
45.535265980921736
],
[
-73.5308882613941,
45.52694682719283
],
[
-73.55715864019355,
45.53350141477455
],
[
-73.5693941590864,
45.49744173039923
],
[
-73.54708233051691,
45.48154796364648
],
[
-73.55068101254456,
45.46539732262025
],
[
-73.50101920056755,
45.45984447079309
],
[
-73.5089363010289,
45.411612634769114
],
[
-73.43084490103683,
45.40630714260823
],
[
-73.40709359965733,
45.44192017282822
],
[
-73.35851139228895,
45.42373760266784
],
[
-73.27574170566112,
45.515348377957594
],
[
-73.34735547800419,
45.56626289505931
],
[
-73.42616661440175,
45.61360726019305
],
[
-73.42868569182079,
45.6523595920458
],
[
-73.45459620241586,
45.653617335517424
]
]
],
"type": "Polygon"
}
}
]
}
Binary file added public/favicon.ico
Binary file not shown.
29 changes: 29 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Transition</title>

<!-- generics -->
<link rel="icon" href="/dist/images/icons/favicons/favicon-32.png" sizes="32x32">
<link rel="icon" href="/dist/images/icons/favicons/favicon-128.png" sizes="128x128">
<link rel="icon" href="/dist/images/icons/favicons/favicon-192.png" sizes="192x192">
<!-- Android -->
<link rel="shortcut icon" href="/dist/images/icons/favicons/favicon-196.png" sizes="196x196">
<!-- iOS -->
<link rel="apple-touch-icon" href="/dist/images/icons/favicons/favicon-152.png" sizes="152x152">
<link rel="apple-touch-icon" href="/dist/images/icons/favicons/favicon-167.png" sizes="167x167">
<link rel="apple-touch-icon" href="/dist/images/icons/favicons/favicon-180.png" sizes="180x180">

</head>

<body>
<div id="app"></div>

</body>

</html>

0 comments on commit 46810b3

Please sign in to comment.