From a5f04dd9cd9ee889a264f67fe7246c60fa82787a Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Fri, 15 Jan 2021 22:29:20 +0100 Subject: [PATCH] Determine allowed zone from admin boundaries (#359) --- .eslintignore | 1 + .prettierignore | 1 + gulpfile.js | 25 +- index.html | 8 +- js/Util.js | 13 + js/index.js | 21 +- js/plugin/CircleGoArea.js | 400 ++- js/plugin/NogoAreas.js | 36 + js/router/BRouter.js | 10 +- locales/en.json | 4 +- package.json | 13 +- resources/boundaries/README.md | 11 + resources/boundaries/germany-states.geojson | 1 + yarn.lock | 2552 +++++++++++-------- 14 files changed, 1925 insertions(+), 1171 deletions(-) create mode 100644 resources/boundaries/README.md create mode 100644 resources/boundaries/germany-states.geojson diff --git a/.eslintignore b/.eslintignore index ab52b3f..565447d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,3 +2,4 @@ layers/josm/extract.js layers/collection/extract.js gulpfile.js dist/brouter-web.js +dist/turf.min.js diff --git a/.prettierignore b/.prettierignore index dda0423..6644623 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,3 +8,4 @@ yarn.lock .tx/ layers/ locales/*.json +resources/boundaries/ diff --git a/gulpfile.js b/gulpfile.js index d834c0b..590e64f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -34,7 +34,12 @@ var debug = false; var paths = { // see overrides in package.json - scriptsConfig: mainNpmFiles().filter((f) => RegExp('url-search-params/.*\\.js', 'i').test(f)), + scriptsConfig: mainNpmFiles() + .filter((f) => RegExp('url-search-params/.*\\.js', 'i').test(f)) + .concat([ + // large lib as extra file for faster parallel loading (*.min.js already excluded from bundle) + 'node_modules/@turf/turf/turf.min.js', + ]), scripts: [ 'node_modules/jquery/dist/jquery.js', 'node_modules/async/lib/async.js', @@ -74,6 +79,7 @@ var paths = { 'layers/config/geometry.js', ], layersConfigDestName: 'layersConf.js', + boundaries: 'resources/boundaries/*.geojson', zip: ['dist/**', 'index.html', 'config.template.js', 'keys.template.js'], dest: 'dist', destName: 'brouter-web', @@ -153,6 +159,10 @@ gulp.task('locales', function () { return gulp.src(paths.locales).pipe(gulp.dest(paths.dest + '/locales')); }); +gulp.task('boundaries', function () { + return gulp.src(paths.boundaries).pipe(gulp.dest(paths.dest + '/boundaries')); +}); + gulp.task('reload', function (done) { server.reload(); done(); @@ -303,7 +313,18 @@ gulp.task('layers', function () { gulp.task( 'default', - gulp.series('clean', 'scripts_config', 'layers_config', 'layers', 'scripts', 'styles', 'images', 'fonts', 'locales') + gulp.series( + 'clean', + 'scripts_config', + 'layers_config', + 'layers', + 'scripts', + 'styles', + 'images', + 'fonts', + 'locales', + 'boundaries' + ) ); gulp.task( diff --git a/index.html b/index.html index ad56b2f..fda3271 100644 --- a/index.html +++ b/index.html @@ -143,7 +143,7 @@