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

View file

@ -1,23 +1,39 @@
(function() { (function() {
var hostname = window.location.hostname; var hostname = window.location.hostname;
var params = new URLSearchParams(window.location.search.slice(1));
BR.conf = {}; 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') { if (hostname === 'brouter.de' || hostname === 'h2096617.stratoserver.net') {
// online service (brouter.de) configuration // online service (brouter.de) configuration
BR.conf.profiles = [ BR.conf.profiles = [
'../im/bike',
'../im/foot',
'../im/like-bike',
'../im/like-foot',
'trekking', 'trekking',
'fastbike', 'fastbike',
'car-test',
'safety',
'shortest', 'shortest',
'trekking-ignore-cr',
'trekking-steep',
'trekking-noferries',
'trekking-nosteps',
'moped', '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'; BR.conf.host = 'http://h2096617.stratoserver.net:443';
@ -28,10 +44,6 @@
// desktop configuration // desktop configuration
BR.conf.profiles = [ BR.conf.profiles = [
'../im/bike',
'../im/foot',
'../im/like-bike',
'../im/like-foot',
'trekking', 'trekking',
'fastbike', 'fastbike',
'shortest', 'shortest',
@ -66,4 +78,22 @@
// Minimum transparency slider value on load, values between 0 and 1 (0=invisible). // 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 // 0 = no minimum, use stored setting; 1 = always reset to full visibility on load
BR.conf.minOpacity = 0.3; 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 = { var paths = {
// see overrides in bower.json // see overrides in bower.json
scriptsConfig: mainBowerFiles('**/url-search-params/**/*.js'),
scripts: mainBowerFiles([ scripts: mainBowerFiles([
'**/*.js', '**/*.js',
'!**/*.min.js' '!**/*.min.js',
'!**/url-search-params/**/*.js'
]).concat([ ]).concat([
'js/Util.js', 'js/Util.js',
'js/router/BRouter.js', 'js/router/BRouter.js',
@ -32,6 +34,13 @@ var paths = {
destName: 'brouter-web' 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() { gulp.task('scripts', function() {
return gulp.src(paths.scripts, { base: '.' }) return gulp.src(paths.scripts, { base: '.' })
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
@ -114,4 +123,4 @@ gulp.task('inject', function () {
.pipe(gulp.dest('.')); .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'); 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>
<script src="dist/url-search-params.js"></script>
<script src="config.js"></script> <script src="config.js"></script>
<!-- "gulp inject" for debugging --> <!-- "gulp inject" for debugging -->

View file

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