config switch for transit demo

This commit is contained in:
Norbert Renner 2016-06-03 13:28:01 +02:00
parent d96e023c60
commit 8bd8fc3256
5 changed files with 78 additions and 24 deletions

View file

@ -19,7 +19,8 @@
"leaflet-control-geocoder": "~1.1.0",
"Leaflet.EasyButton": "*",
"bootbox": "~4.4.0",
"seiyria-bootstrap-slider": "~4.8.1"
"seiyria-bootstrap-slider": "~4.8.1",
"url-search-params": "~0.5.0"
},
"overrides": {
"leaflet": {
@ -75,6 +76,9 @@
"Control.Geocoder.css",
"images/*.+(png|gif)"
]
},
"url-search-params": {
"main": "build/url-search-params.js"
}
},
"resolutions": {

View file

@ -1,23 +1,39 @@
(function() {
var hostname = window.location.hostname;
var params = new URLSearchParams(window.location.search.slice(1));
BR.conf = {};
// Switch for intermodal routing demo
//BR.conf.transit = true;
// or as query parameter (index.html?transit=true#zoom=...)
// (uses search/query (?) not hash (#) params, as config only executed once at load)
// TODO not included in permalink (better replace permalink with hash plugin)
BR.conf.transit = params.has('transit') && (params.get('transit') === 'true');
if (hostname === 'brouter.de' || hostname === 'h2096617.stratoserver.net') {
// online service (brouter.de) configuration
BR.conf.profiles = [
'../im/bike',
'../im/foot',
'../im/like-bike',
'../im/like-foot',
'trekking',
'fastbike',
'car-test',
'safety',
'shortest',
'trekking-ignore-cr',
'trekking-steep',
'trekking-noferries',
'trekking-nosteps',
'moped',
'car-test'
'rail',
'river',
'vm-forum-liegerad-schnell',
'vm-forum-velomobil-schnell',
'fastbike-lowtraffic',
'fastbike-asia-pacific',
'hiking-beta'
];
BR.conf.host = 'http://h2096617.stratoserver.net:443';
@ -28,10 +44,6 @@
// desktop configuration
BR.conf.profiles = [
'../im/bike',
'../im/foot',
'../im/like-bike',
'../im/like-foot',
'trekking',
'fastbike',
'shortest',
@ -66,4 +78,22 @@
// Minimum transparency slider value on load, values between 0 and 1 (0=invisible).
// 0 = no minimum, use stored setting; 1 = always reset to full visibility on load
BR.conf.minOpacity = 0.3;
// transit (intermodal routing) demo config
if (BR.conf.transit) {
BR.conf.profiles = [
'../im/bike',
'../im/foot',
'../im/like-bike',
'../im/like-foot',
'trekking',
'fastbike',
'shortest',
'moped',
'car-test'
];
}
})();

View file

@ -15,9 +15,11 @@ var inject = require('gulp-inject');
var paths = {
// see overrides in bower.json
scriptsConfig: mainBowerFiles('**/url-search-params/**/*.js'),
scripts: mainBowerFiles([
'**/*.js',
'!**/*.min.js'
'!**/*.min.js',
'!**/url-search-params/**/*.js'
]).concat([
'js/Util.js',
'js/router/BRouter.js',
@ -32,6 +34,13 @@ var paths = {
destName: 'brouter-web'
};
// libs that require loading before config.js
gulp.task('scripts_config', ['clean'], function() {
// just copy for now
return gulp.src(paths.scriptsConfig)
.pipe(gulp.dest(paths.dest));
});
gulp.task('scripts', function() {
return gulp.src(paths.scripts, { base: '.' })
.pipe(sourcemaps.init())
@ -114,4 +123,4 @@ gulp.task('inject', function () {
.pipe(gulp.dest('.'));
});
gulp.task('default', ['clean', 'scripts', 'styles', 'images', 'fonts']);
gulp.task('default', ['clean', 'scripts_config', 'scripts', 'styles', 'images', 'fonts']);

View file

@ -108,6 +108,7 @@
console.log('\r\n###\r\n### BRouter-Web\r\n###\r\n### Please note that the routing API used here is not public!\r\n###\r\n');
</script>
<script src="dist/url-search-params.js"></script>
<script src="config.js"></script>
<!-- "gulp inject" for debugging -->

View file

@ -188,8 +188,12 @@
nogos = new BR.NogoAreas();
nogos.on('update', updateRoute);
// stats = new BR.TrackStats();
iternity = new BR.Iternity();
// intermodal routing demo?
if (BR.conf.transit) {
iternity = new BR.Iternity();
} else {
stats = new BR.TrackStats();
}
download = new BR.Download();
elevation = new BR.Elevation();
profile = new BR.Profile();
@ -275,8 +279,11 @@
urls = {};
elevation.update(track, segmentsLayer);
// stats.update(track, segments);
iternity.update(track, segments);
if (BR.conf.transit) {
iternity.update(track, segments);
} else {
stats.update(track, segments);
}
trackMessages.update(track, segments);
if (latLngs.length > 1) {
@ -289,15 +296,18 @@
download.update(urls);
};
/*
map.addControl(new BR.Control({
heading: '',
divId: 'header'
}));
*/
if (!BR.conf.transit) {
map.addControl(new BR.Control({
heading: '',
divId: 'header'
}));
}
routingOptions.addTo(map);
// stats.addTo(map);
iternity.addTo(map);
if (BR.conf.transit) {
iternity.addTo(map);
} else {
stats.addTo(map);
}
download.addTo(map);
elevation.addTo(map);
map.addControl(new BR.Tabs({