Changeset 43fd35c
- Timestamp:
- Apr 19, 2020, 4:27:01 PM (7 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 2a31181
- Parents:
- 77cd9cf
- Files:
-
- 9 added
- 21 deleted
- 2 edited
- 143 moved
-
.coveragerc (moved) (moved from src/common/.coveragerc )
-
.gitignore (modified) (1 diff)
-
MANIFEST.in (added)
-
README (added)
-
buildhelpers/code_generator (added)
-
buildhelpers/codegen/openapi-generator-cli (moved) (moved from src/mapservice/codegen/openapi-generator-cli )
-
buildhelpers/codegen/templates/__init__.mustache (moved) (moved from src/mapservice/codegen/templates/__init__.mustache )
-
buildhelpers/codegen/templates/__init__model.mustache (moved) (moved from src/mapservice/codegen/templates/__init__model.mustache )
-
buildhelpers/codegen/templates/__init__test.mustache (moved) (moved from src/mapservice/codegen/templates/__init__test.mustache ) (2 diffs)
-
buildhelpers/codegen/templates/__main__.mustache (moved) (moved from src/mapservice/codegen/templates/__main__.mustache ) (1 diff)
-
buildhelpers/codegen/templates/base_model_.mustache (moved) (moved from src/mapservice/codegen/templates/base_model_.mustache )
-
buildhelpers/codegen/templates/controller.mustache (moved) (moved from src/mapservice/codegen/templates/controller.mustache ) (1 diff)
-
buildhelpers/codegen/templates/controller_test.mustache (moved) (moved from src/mapservice/codegen/templates/controller_test.mustache ) (1 diff)
-
buildhelpers/codegen/templates/encoder.mustache (moved) (moved from src/mapservice/codegen/templates/encoder.mustache )
-
buildhelpers/codegen/templates/model.mustache (moved) (moved from src/mapservice/codegen/templates/model.mustache ) (1 diff)
-
buildhelpers/codegen/templates/openapi.mustache (moved) (moved from src/mapservice/codegen/templates/openapi.mustache )
-
buildhelpers/codegen/templates/param_type.mustache (moved) (moved from src/mapservice/codegen/templates/param_type.mustache )
-
buildhelpers/codegen/templates/security_controller_.mustache (moved) (moved from src/mapservice/codegen/templates/security_controller_.mustache )
-
buildhelpers/codegen/templates/util.mustache (moved) (moved from src/mapservice/codegen/templates/util.mustache )
-
python-style.yapf (moved) (moved from src/python-style.yapf )
-
requirements.txt (moved) (moved from src/common/requirements.txt )
-
setup.py (added)
-
src/common/README (deleted)
-
src/common/setup.py (deleted)
-
src/common/tox.ini (deleted)
-
src/gnuboat/MANIFEST.in (deleted)
-
src/gnuboat/README (deleted)
-
src/gnuboat/__init__.py (added)
-
src/gnuboat/common/__init__.py (moved) (moved from src/common/gnuboat_common/__init__.py ) (2 diffs)
-
src/gnuboat/common/bin/gdal2tiles-gnuboat.py (moved) (moved from src/common/bin/gdal2tiles-gnuboat.py ) (87 diffs)
-
src/gnuboat/common/bin/gdal2tiles-tilesize.patch (moved) (moved from src/common/bin/gdal2tiles-tilesize.patch )
-
src/gnuboat/common/bin/gnuboat-log-analyser (moved) (moved from src/common/bin/gnuboat-log-analyser ) (1 diff)
-
src/gnuboat/common/bin/gnuboat-log-converter (moved) (moved from src/common/bin/gnuboat-log-converter ) (1 diff)
-
src/gnuboat/common/bin/gnuboat-log-uploader (moved) (moved from src/common/bin/gnuboat-log-uploader ) (1 diff)
-
src/gnuboat/common/css/GnuBoat.Colors.css (moved) (moved from src/common/css/GnuBoat.Colors.css ) (1 diff)
-
src/gnuboat/common/css/side-menu.css (moved) (moved from src/common/css/side-menu.css ) (1 diff)
-
src/gnuboat/common/datahandler/__init__.py (moved) (moved from src/common/gnuboat_common/datahandler/__init__.py ) (1 diff)
-
src/gnuboat/common/datahandler/logdataset.py (moved) (moved from src/common/gnuboat_common/datahandler/logdataset.py ) (1 diff)
-
src/gnuboat/common/datahandler/loghandler.py (moved) (moved from src/common/gnuboat_common/datahandler/loghandler.py ) (2 diffs)
-
src/gnuboat/common/icon/gnuboat-256-256-transparent.png (moved) (moved from src/common/icon/gnuboat-256-256-transparent.png )
-
src/gnuboat/common/icon/gnuboat-256-256.png (moved) (moved from src/common/icon/gnuboat-256-256.png )
-
src/gnuboat/common/icon/gnuboat-device.svg (moved) (moved from src/common/icon/gnuboat-device.svg )
-
src/gnuboat/common/icon/gnuboat-gauge.svg (moved) (moved from src/common/icon/gnuboat-gauge.svg )
-
src/gnuboat/common/icon/gnuboat-logfile.svg (moved) (moved from src/common/icon/gnuboat-logfile.svg )
-
src/gnuboat/common/icon/gnuboat-splashscreen.png (moved) (moved from src/common/icon/gnuboat-splashscreen.png )
-
src/gnuboat/common/icon/gnuboat-water.svg (moved) (moved from src/common/icon/gnuboat-water.svg )
-
src/gnuboat/common/icon/gnuboat.svg (moved) (moved from src/common/icon/gnuboat.svg )
-
src/gnuboat/common/icon/log-deployed.svg (moved) (moved from src/common/icon/log-deployed.svg )
-
src/gnuboat/common/icon/log-excluded.svg (moved) (moved from src/common/icon/log-excluded.svg )
-
src/gnuboat/common/icon/log-queued.svg (moved) (moved from src/common/icon/log-queued.svg )
-
src/gnuboat/common/icon/log-undefined.svg (moved) (moved from src/common/icon/log-undefined.svg )
-
src/gnuboat/common/icon/processing.svg (moved) (moved from src/common/icon/processing.svg )
-
src/gnuboat/common/js/GnuBoat.js (moved) (moved from src/common/js/GnuBoat.js ) (1 diff)
-
src/gnuboat/common/lib/css/leaflet/images/layers-2x.png (moved) (moved from src/common/lib/css/leaflet/images/layers-2x.png )
-
src/gnuboat/common/lib/css/leaflet/images/layers.png (moved) (moved from src/common/lib/css/leaflet/images/layers.png )
-
src/gnuboat/common/lib/css/leaflet/images/marker-icon-2x.png (moved) (moved from src/common/lib/css/leaflet/images/marker-icon-2x.png )
-
src/gnuboat/common/lib/css/leaflet/images/marker-icon.png (moved) (moved from src/common/lib/css/leaflet/images/marker-icon.png )
-
src/gnuboat/common/lib/css/leaflet/images/marker-shadow.png (moved) (moved from src/common/lib/css/leaflet/images/marker-shadow.png )
-
src/gnuboat/common/lib/css/leaflet/leaflet.css (moved) (moved from src/common/lib/css/leaflet/leaflet.css )
-
src/gnuboat/common/lib/css/pure/base-context-min.css (moved) (moved from src/common/lib/css/pure/base-context-min.css )
-
src/gnuboat/common/lib/css/pure/base-min.css (moved) (moved from src/common/lib/css/pure/base-min.css )
-
src/gnuboat/common/lib/css/pure/buttons-core-min.css (moved) (moved from src/common/lib/css/pure/buttons-core-min.css )
-
src/gnuboat/common/lib/css/pure/buttons-min.css (moved) (moved from src/common/lib/css/pure/buttons-min.css )
-
src/gnuboat/common/lib/css/pure/forms-min.css (moved) (moved from src/common/lib/css/pure/forms-min.css )
-
src/gnuboat/common/lib/css/pure/forms-nr-min.css (moved) (moved from src/common/lib/css/pure/forms-nr-min.css )
-
src/gnuboat/common/lib/css/pure/grids-core-min.css (moved) (moved from src/common/lib/css/pure/grids-core-min.css )
-
src/gnuboat/common/lib/css/pure/grids-min.css (moved) (moved from src/common/lib/css/pure/grids-min.css )
-
src/gnuboat/common/lib/css/pure/grids-responsive-min.css (moved) (moved from src/common/lib/css/pure/grids-responsive-min.css )
-
src/gnuboat/common/lib/css/pure/grids-responsive-old-ie-min.css (moved) (moved from src/common/lib/css/pure/grids-responsive-old-ie-min.css )
-
src/gnuboat/common/lib/css/pure/grids-units-min.css (moved) (moved from src/common/lib/css/pure/grids-units-min.css )
-
src/gnuboat/common/lib/css/pure/menus-core-min.css (moved) (moved from src/common/lib/css/pure/menus-core-min.css )
-
src/gnuboat/common/lib/css/pure/menus-dropdown-min.css (moved) (moved from src/common/lib/css/pure/menus-dropdown-min.css )
-
src/gnuboat/common/lib/css/pure/menus-horizontal-min.css (moved) (moved from src/common/lib/css/pure/menus-horizontal-min.css )
-
src/gnuboat/common/lib/css/pure/menus-min.css (moved) (moved from src/common/lib/css/pure/menus-min.css )
-
src/gnuboat/common/lib/css/pure/menus-scrollable-min.css (moved) (moved from src/common/lib/css/pure/menus-scrollable-min.css )
-
src/gnuboat/common/lib/css/pure/menus-skin-min.css (moved) (moved from src/common/lib/css/pure/menus-skin-min.css )
-
src/gnuboat/common/lib/css/pure/pure-min.css (moved) (moved from src/common/lib/css/pure/pure-min.css )
-
src/gnuboat/common/lib/css/pure/pure-nr-min.css (moved) (moved from src/common/lib/css/pure/pure-nr-min.css )
-
src/gnuboat/common/lib/css/pure/tables-min.css (moved) (moved from src/common/lib/css/pure/tables-min.css )
-
src/gnuboat/common/lib/js/additional-methods.min.js (moved) (moved from src/common/lib/js/additional-methods.min.js )
-
src/gnuboat/common/lib/js/jquery-3.2.1.min.js (moved) (moved from src/common/lib/js/jquery-3.2.1.min.js )
-
src/gnuboat/common/lib/js/jquery-ui/AUTHORS.txt (moved) (moved from src/common/lib/js/jquery-ui/AUTHORS.txt )
-
src/gnuboat/common/lib/js/jquery-ui/LICENSE.txt (moved) (moved from src/common/lib/js/jquery-ui/LICENSE.txt )
-
src/gnuboat/common/lib/js/jquery-ui/external/jquery/jquery.js (moved) (moved from src/common/lib/js/jquery-ui/external/jquery/jquery.js )
-
src/gnuboat/common/lib/js/jquery-ui/images/ui-icons_444444_256x240.png (moved) (moved from src/common/lib/js/jquery-ui/images/ui-icons_444444_256x240.png )
-
src/gnuboat/common/lib/js/jquery-ui/images/ui-icons_555555_256x240.png (moved) (moved from src/common/lib/js/jquery-ui/images/ui-icons_555555_256x240.png )
-
src/gnuboat/common/lib/js/jquery-ui/images/ui-icons_777620_256x240.png (moved) (moved from src/common/lib/js/jquery-ui/images/ui-icons_777620_256x240.png )
-
src/gnuboat/common/lib/js/jquery-ui/images/ui-icons_777777_256x240.png (moved) (moved from src/common/lib/js/jquery-ui/images/ui-icons_777777_256x240.png )
-
src/gnuboat/common/lib/js/jquery-ui/images/ui-icons_cc0000_256x240.png (moved) (moved from src/common/lib/js/jquery-ui/images/ui-icons_cc0000_256x240.png )
-
src/gnuboat/common/lib/js/jquery-ui/images/ui-icons_ffffff_256x240.png (moved) (moved from src/common/lib/js/jquery-ui/images/ui-icons_ffffff_256x240.png )
-
src/gnuboat/common/lib/js/jquery-ui/index.html (moved) (moved from src/common/lib/js/jquery-ui/index.html )
-
src/gnuboat/common/lib/js/jquery-ui/jquery-ui.css (moved) (moved from src/common/lib/js/jquery-ui/jquery-ui.css )
-
src/gnuboat/common/lib/js/jquery-ui/jquery-ui.js (moved) (moved from src/common/lib/js/jquery-ui/jquery-ui.js )
-
src/gnuboat/common/lib/js/jquery-ui/jquery-ui.min.css (moved) (moved from src/common/lib/js/jquery-ui/jquery-ui.min.css )
-
src/gnuboat/common/lib/js/jquery-ui/jquery-ui.min.js (moved) (moved from src/common/lib/js/jquery-ui/jquery-ui.min.js )
-
src/gnuboat/common/lib/js/jquery-ui/jquery-ui.structure.css (moved) (moved from src/common/lib/js/jquery-ui/jquery-ui.structure.css )
-
src/gnuboat/common/lib/js/jquery-ui/jquery-ui.structure.min.css (moved) (moved from src/common/lib/js/jquery-ui/jquery-ui.structure.min.css )
-
src/gnuboat/common/lib/js/jquery-ui/jquery-ui.theme.css (moved) (moved from src/common/lib/js/jquery-ui/jquery-ui.theme.css )
-
src/gnuboat/common/lib/js/jquery-ui/jquery-ui.theme.min.css (moved) (moved from src/common/lib/js/jquery-ui/jquery-ui.theme.min.css )
-
src/gnuboat/common/lib/js/jquery-ui/package.json (moved) (moved from src/common/lib/js/jquery-ui/package.json )
-
src/gnuboat/common/lib/js/jquery.validate.min.js (moved) (moved from src/common/lib/js/jquery.validate.min.js )
-
src/gnuboat/common/lib/js/leaflet.hotline.min.js (moved) (moved from src/common/lib/js/leaflet.hotline.min.js )
-
src/gnuboat/common/lib/js/leaflet.js (moved) (moved from src/common/lib/js/leaflet.js )
-
src/gnuboat/common/lib/js/three.OrbitControls.js (moved) (moved from src/common/lib/js/three.OrbitControls.js )
-
src/gnuboat/common/lib/js/three.min.js (moved) (moved from src/common/lib/js/three.min.js )
-
src/gnuboat/common/resources/layers-2x.png (moved) (moved from src/common/resources/layers-2x.png )
-
src/gnuboat/common/resources/layers.png (moved) (moved from src/common/resources/layers.png )
-
src/gnuboat/common/spatial/__init__.py (moved) (moved from src/common/gnuboat_common/spatial/__init__.py ) (1 diff)
-
src/gnuboat/common/spatial/tilegenerator.py (moved) (moved from src/common/gnuboat_common/spatial/tilegenerator.py ) (1 diff)
-
src/gnuboat/common/tests/__init__.py (moved) (moved from src/common/tests/__init__.py ) (1 diff)
-
src/gnuboat/common/tests/data/slice-log1.csv (moved) (moved from src/common/tests/data/slice-log1.csv )
-
src/gnuboat/common/tests/data/slice-log2.csv (moved) (moved from src/common/tests/data/slice-log2.csv )
-
src/gnuboat/common/tests/data/slice-log2.csvt (moved) (moved from src/common/tests/data/slice-log2.csvt )
-
src/gnuboat/common/tests/data/slice-log2.vrt (moved) (moved from src/common/tests/data/slice-log2.vrt )
-
src/gnuboat/common/tests/test_tilegenerator.py (moved) (moved from src/common/tests/test_tilegenerator.py ) (2 diffs)
-
src/gnuboat/device/__init__.py (added)
-
src/gnuboat/device/bin/gnuboat (moved) (moved from src/gnuboat/bin/gnuboat ) (9 diffs)
-
src/gnuboat/device/bin/gnuboat-data-generator (moved) (moved from src/gnuboat/bin/gnuboat-data-generator ) (8 diffs)
-
src/gnuboat/device/bin/gnuboat-splashscreen (moved) (moved from src/gnuboat/bin/gnuboat-splashscreen ) (2 diffs)
-
src/gnuboat/device/config/gnuboat.service (moved) (moved from src/gnuboat/config/gnuboat.service )
-
src/gnuboat/device/daemon/__init__.py (added)
-
src/gnuboat/device/daemon/displayhandler.py (moved) (moved from src/gnuboat/gnuboat/daemon/displayhandler.py ) (8 diffs)
-
src/gnuboat/device/daemon/gpsdpoller.py (moved) (moved from src/gnuboat/gnuboat/daemon/gpsdpoller.py ) (7 diffs)
-
src/gnuboat/device/daemon/n2kdpoller.py (moved) (moved from src/gnuboat/gnuboat/daemon/n2kdpoller.py ) (6 diffs)
-
src/gnuboat/device/daemon/rrdhandler.py (added)
-
src/gnuboat/gnuboat/__init__.py (deleted)
-
src/gnuboat/gnuboat/daemon/__init__.py (deleted)
-
src/gnuboat/gnuboat/daemon/rrdhandler.py (deleted)
-
src/gnuboat/mapservice.yaml (moved) (moved from src/mapservice/openapi.yaml ) (1 diff)
-
src/gnuboat/mapservice_impl/CeleryWorker.py (moved) (moved from src/mapservice/server_impl/CeleryWorker.py ) (5 diffs)
-
src/gnuboat/mapservice_impl/Config.py (moved) (moved from src/mapservice/server_impl/Config.py ) (6 diffs)
-
src/gnuboat/mapservice_impl/HttpErrors.py (moved) (moved from src/mapservice/server_impl/HttpErrors.py ) (2 diffs)
-
src/gnuboat/mapservice_impl/ValidatorWorkaround.py (moved) (moved from src/mapservice/server_impl/ValidatorWorkaround.py ) (2 diffs)
-
src/gnuboat/mapservice_impl/__init__.py (moved) (moved from src/mapservice/server_impl/__init__.py ) (3 diffs)
-
src/gnuboat/mapservice_impl/controllers/DevicesController.py (moved) (moved from src/mapservice/server_impl/controllers/DevicesController.py ) (2 diffs)
-
src/gnuboat/mapservice_impl/controllers/LogsController.py (moved) (moved from src/mapservice/server_impl/controllers/LogsController.py ) (2 diffs)
-
src/gnuboat/mapservice_impl/controllers/TilesController.py (moved) (moved from src/mapservice/server_impl/controllers/TilesController.py ) (8 diffs)
-
src/gnuboat/mapservice_impl/controllers/UsersController.py (moved) (moved from src/mapservice/server_impl/controllers/UsersController.py ) (4 diffs)
-
src/gnuboat/mapservice_impl/controllers/WatersController.py (moved) (moved from src/mapservice/server_impl/controllers/WatersController.py ) (2 diffs)
-
src/gnuboat/mapservice_impl/controllers/__init__.py (moved) (moved from src/mapservice/server_impl/controllers/__init__.py )
-
src/gnuboat/mapservice_impl/database/Model.py (moved) (moved from src/mapservice/server_impl/database/Model.py ) (7 diffs)
-
src/gnuboat/mapservice_impl/database/__init__.py (moved) (moved from src/mapservice/server_impl/database/__init__.py )
-
src/gnuboat/mapservice_impl/demo/DbSetup.py (moved) (moved from src/mapservice/server_impl/demo/DbSetup.py ) (4 diffs)
-
src/gnuboat/mapservice_impl/demo/__init__.py (moved) (moved from src/mapservice/server_impl/demo/__init__.py )
-
src/gnuboat/mapservice_impl/security/Security.py (moved) (moved from src/mapservice/server_impl/security/Security.py ) (1 diff)
-
src/gnuboat/mapservice_impl/security/__init__.py (moved) (moved from src/mapservice/server_impl/security/__init__.py )
-
src/gnuboat/mapservice_impl/tasks/__init__.py (moved) (moved from src/mapservice/server_impl/tasks/__init__.py ) (1 diff)
-
src/gnuboat/mapservice_impl/tasks/tasks.py (moved) (moved from src/mapservice/server_impl/tasks/tasks.py ) (17 diffs)
-
src/gnuboat/mapservice_impl/tasks/tileconfig.py (moved) (moved from src/mapservice/server_impl/tasks/tileconfig.py ) (2 diffs)
-
src/gnuboat/mapservice_impl/templates/activation_mail.html (moved) (moved from src/mapservice/templates/activation_mail.html )
-
src/gnuboat/mapservice_impl/templates/log_parsed.html (moved) (moved from src/mapservice/templates/log_parsed.html )
-
src/gnuboat/mapservice_impl/templates/log_parsing_error.html (moved) (moved from src/mapservice/templates/log_parsing_error.html )
-
src/gnuboat/mapservice_impl/templates/log_processed.html (moved) (moved from src/mapservice/templates/log_processed.html )
-
src/gnuboat/mapservice_impl/tests/data/nmea0183-2017-12-09.log (moved) (moved from src/mapservice/tests/data/nmea0183-2017-12-09.log )
-
src/gnuboat/mapservice_impl/tests/db_test_setup.py (moved) (moved from src/mapservice/tests/db_test_setup.py ) (3 diffs)
-
src/gnuboat/mapservice_impl/tests/test_config.py (moved) (moved from src/mapservice/tests/test_config.py ) (4 diffs)
-
src/gnuboat/mapservice_impl/tests/test_logs.py (moved) (moved from src/mapservice/tests/test_logs.py ) (6 diffs)
-
src/gnuboat/mapservice_impl/tests/test_users.py (moved) (moved from src/mapservice/tests/test_users.py ) (4 diffs)
-
src/gnuboat/mapservice_impl/tests/test_waters.py (moved) (moved from src/mapservice/tests/test_waters.py ) (6 diffs)
-
src/gnuboat/setup.py (deleted)
-
src/gnuboat/tox.ini (deleted)
-
src/mapservice-webclient/package.json (modified) (1 diff)
-
src/mapservice/codegen/code_generator (deleted)
-
src/mapservice/codegen/openapi-generator-cli-3.3.4.jar (deleted)
-
src/mapservice/codegen/templates/Dockerfile.mustache (deleted)
-
src/mapservice/codegen/templates/README.mustache (deleted)
-
src/mapservice/codegen/templates/dockerignore.mustache (deleted)
-
src/mapservice/codegen/templates/git_push.sh.mustache (deleted)
-
src/mapservice/codegen/templates/gitignore.mustache (deleted)
-
src/mapservice/codegen/templates/requirements.mustache (deleted)
-
src/mapservice/codegen/templates/setup.mustache (deleted)
-
src/mapservice/codegen/templates/tox.mustache (deleted)
-
src/mapservice/codegen/templates/travis.mustache (deleted)
-
test-requirements.txt (moved) (moved from src/mapservice/codegen/templates/test-requirements.mustache ) (1 diff)
-
tox.ini (added)
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r77cd9cf r43fd35c 1 build/2 1 # Compiled python modules. 3 2 *.pyc 3 __pycache__/ 4 .directory 4 5 5 6 # Setuptools distribution folder. 6 7 dist/ 7 8 build/ 8 9 # Python egg metadata, regenerated from source files by setuptools. 9 10 *.egg-info 10 11 11 12 .tox/ 13 .pytest_cache/ 12 14 .coverage 15 .coverage.* 13 16 reports 14 17 15 src/mapservice/src-gen 18 buildhelpers/codegen/openapi-generator-cli-*.jar 19 src/gnuboat/mapservice/ 16 20 src/mapservice-webclient/src-gen 17 21 src/mapservice/codegen/openapi-generator-cli-*.jar -
buildhelpers/codegen/templates/__init__test.mustache
r77cd9cf r43fd35c 14 14 15 15 from {{packageName}}.encoder import JSONEncoder 16 from {{packageName}}.server_impl.database.Model import db, db_setup, load_spatialite 17 from . import db_test_setup 16 from {{packageName}}_impl.database.Model import ( 17 db, db_setup, load_spatialite 18 ) 19 from {{packageName}}_impl.tests import db_test_setup 18 20 19 21 class BaseTestCase(TestCase): … … 27 29 app.add_api('openapi.yaml') 28 30 29 application.config.from_object('{{packageName}} .server_impl.Config.TestingConfig')30 application.template_folder = os.path.join(os.path.dirname(__file__), '../ templates')31 application.config.from_object('{{packageName}}_impl.Config.TestingConfig') 32 application.template_folder = os.path.join(os.path.dirname(__file__), '../../mapservice_impl/templates') 31 33 celery = Celery(__name__, broker=application.config['CELERY_BROKER_URL']) 32 34 celery.config_from_object(application.config) -
buildhelpers/codegen/templates/__main__.mustache
r77cd9cf r43fd35c 8 8 import os 9 9 10 from {{packageName}}.server_impl import app, application, mail, celery, setup_app, config_object 10 from {{packageName}}_impl import ( 11 app, application, mail, celery, setup_app, config_object 12 ) 11 13 12 14 def main(): -
buildhelpers/codegen/templates/controller.mustache
r77cd9cf r43fd35c 8 8 {{#operation}} 9 9 10 from {{packageName}} .server_impl.controllers import {{classname}}10 from {{packageName}}_impl.controllers import {{classname}} 11 11 12 12 def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}): # noqa: E501 -
buildhelpers/codegen/templates/controller_test.mustache
r77cd9cf r43fd35c 21 21 def test_{{operationId}}(self): 22 22 """Test case for {{{operationId}}} 23 24 23 {{{summary}}} 25 24 """ -
buildhelpers/codegen/templates/model.mustache
r77cd9cf r43fd35c 23 23 {{#model}} 24 24 class {{classname}}(Model): 25 """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 25 """NOTE: This class is auto generated by OpenAPI Generator 26 (https://openapi-generator.tech). 26 27 27 28 Do not edit the class manually. -
src/gnuboat/common/__init__.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2017 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2017 - 2020 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 16 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 17 ''' 18 from .datahandler.loghandler import LogHandler19 from .datahandler.logdataset import LogDataset20 from .spatial.tilegenerator import TileGenerator18 from gnuboat.common.datahandler.loghandler import LogHandler 19 from gnuboat.common.datahandler.logdataset import LogDataset 20 from gnuboat.common.spatial.tilegenerator import TileGenerator -
src/gnuboat/common/bin/gdal2tiles-gnuboat.py
r77cd9cf r43fd35c 64 64 __version__ = "$Id: gdal2tiles.py fae3a65f16af509cf9e0dd16cd16858d8e49eb25 2019-03-12 15:23:57 -0700 Kevin Mehall $" 65 65 66 resampling_list = ('average', 'near', 'bilinear', 'cubic', 'cubicspline', 'lanczos', 'antialias') 66 resampling_list = ( 67 'average', 'near', 'bilinear', 'cubic', 'cubicspline', 'lanczos', 68 'antialias' 69 ) 67 70 profile_list = ('mercator', 'geodetic', 'raster') 68 71 webviewer_list = ('all', 'google', 'openlayers', 'leaflet', 'none') … … 207 210 AUTHORITY["EPSG","9001"]]] 208 211 """ 209 210 212 def __init__(self, tile_size=256): 211 213 "Initialize the TMS Global Mercator pyramid" … … 220 222 221 223 mx = lon * self.originShift / 180.0 222 my = math.log(math.tan((90 + lat) * math.pi / 360.0)) / (math.pi / 180.0) 224 my = math.log(math.tan((90 + lat) * math.pi / 360.0) 225 ) / (math.pi / 180.0) 223 226 224 227 my = my * self.originShift / 180.0 … … 231 234 lat = (my / self.originShift) * 180.0 232 235 233 lat = 180 / math.pi * (2 * math.atan(math.exp(lat * math.pi / 180.0)) - math.pi / 2.0) 236 lat = 180 / math.pi * ( 237 2 * math.atan(math.exp(lat * math.pi / 180.0)) - math.pi / 2.0 238 ) 234 239 return lat, lon 235 240 … … 272 277 "Returns bounds of the given tile in EPSG:3857 coordinates" 273 278 274 minx, miny = self.PixelsToMeters(tx * self.tile_size, ty * self.tile_size, zoom) 275 maxx, maxy = self.PixelsToMeters((tx + 1) * self.tile_size, (ty + 1) * self.tile_size, zoom) 279 minx, miny = self.PixelsToMeters( 280 tx * self.tile_size, ty * self.tile_size, zoom 281 ) 282 maxx, maxy = self.PixelsToMeters((tx + 1) * self.tile_size, 283 (ty + 1) * self.tile_size, zoom) 276 284 return (minx, miny, maxx, maxy) 277 285 … … 296 304 for i in range(MAXZOOMLEVEL): 297 305 if pixelSize > self.Resolution(i): 298 return max(0, i - 1) # We don't want to scale up306 return max(0, i - 1) # We don't want to scale up 299 307 return MAXZOOMLEVEL - 1 300 308 … … 356 364 WMS, KML Web Clients, Google Earth TileMapService 357 365 """ 358 359 366 def __init__(self, tmscompatible, tile_size=256): 360 367 self.tile_size = tile_size … … 400 407 for i in range(MAXZOOMLEVEL): 401 408 if pixelSize > self.Resolution(i): 402 return max(0, i - 1) # We don't want to scale up409 return max(0, i - 1) # We don't want to scale up 403 410 return MAXZOOMLEVEL - 1 404 411 … … 407 414 res = self.resFact / 2**zoom 408 415 return ( 409 tx * self.tile_size * res - 180, 410 ty * self.tile_size * res - 90, 416 tx * self.tile_size * res - 180, ty * self.tile_size * res - 90, 411 417 (tx + 1) * self.tile_size * res - 180, 412 418 (ty + 1) * self.tile_size * res - 90 … … 424 430 ---------------------------------------- 425 431 """ 426 427 432 def __init__(self, width, height, tile_size=256, tileformat='jpg'): 428 433 """Initialization of the Zoomify tile tree""" … … 442 447 443 448 while (imagesize[0] > tile_size or imagesize[1] > tile_size): 444 imagesize = (math.floor(imagesize[0] / 2), math.floor(imagesize[1] / 2)) 445 tiles = (math.ceil(imagesize[0] / tile_size), math.ceil(imagesize[1] / tile_size)) 449 imagesize = ( 450 math.floor(imagesize[0] / 2), math.floor(imagesize[1] / 2) 451 ) 452 tiles = ( 453 math.ceil(imagesize[0] / tile_size), 454 math.ceil(imagesize[1] / tile_size) 455 ) 446 456 self.tierSizeInTiles.append(tiles) 447 457 self.tierImageSize.append(imagesize) … … 458 468 for i in range(1, self.numberOfTiers + 1): 459 469 self.tileCountUpToTier.append( 460 self.tierSizeInTiles[i - 1][0] * self.tierSizeInTiles[i - 1][1] +461 self.ti leCountUpToTier[i - 1]470 self.tierSizeInTiles[i - 1][0] * 471 self.tierSizeInTiles[i - 1][1] + self.tileCountUpToTier[i - 1] 462 472 ) 463 473 … … 465 475 """Returns filename for tile with given coordinates""" 466 476 467 tileIndex = x + y * self.tierSizeInTiles[z][0] + self.tileCountUpToTier[z] 468 return os.path.join("TileGroup%.0f" % math.floor(tileIndex / 256), 469 "%s-%s-%s.%s" % (z, x, y, self.tileformat)) 477 tileIndex = x + y * self.tierSizeInTiles[z][ 478 0] + self.tileCountUpToTier[z] 479 return os.path.join( 480 "TileGroup%.0f" % math.floor(tileIndex / 256), 481 "%s-%s-%s.%s" % (z, x, y, self.tileformat) 482 ) 470 483 471 484 … … 485 498 486 499 487 def generate_kml(tx, ty, tz, tileext, tile_size, tileswne, options, children=None, **args): 500 def generate_kml( 501 tx, ty, tz, tileext, tile_size, tileswne, options, children=None, **args 502 ): 488 503 """ 489 504 Template for the KML. Returns filled string. … … 510 525 tilekml = True 511 526 args['title'] = "%d/%d/%d.kml" % (tz, tx, ty) 512 args['south'], args['west'], args['north'], args['east'] = tileswne(tx, ty, tz) 527 args['south'], args['west'], args['north'], args['east'] = tileswne( 528 tx, ty, tz 529 ) 513 530 514 531 if tx == 0: … … 587 604 </Link> 588 605 </NetworkLink> 589 """ % (cz, cx, cy, args['tileformat'], cnorth, csouth, ceast, cwest, 590 args['minlodpixels'], url, cz, cx, cy) 606 """ % ( 607 cz, cx, cy, args['tileformat'], cnorth, csouth, ceast, cwest, 608 args['minlodpixels'], url, cz, cx, cy 609 ) 591 610 592 611 s += """ </Document> … … 608 627 for i in range(1, tilebands + 1): 609 628 # Black border around NODATA 610 res = gdal.RegenerateOverview(dsquery.GetRasterBand(i), dstile.GetRasterBand(i), 611 'average') 629 res = gdal.RegenerateOverview( 630 dsquery.GetRasterBand(i), dstile.GetRasterBand(i), 'average' 631 ) 612 632 if res != 0: 613 exit_with_error("RegenerateOverview() failed on %s, error %d" % ( 614 tilefilename, res)) 633 exit_with_error( 634 "RegenerateOverview() failed on %s, error %d" % 635 (tilefilename, res) 636 ) 615 637 616 638 elif options.resampling == 'antialias' and numpy_available: … … 619 641 array = numpy.zeros((querysize, querysize, tilebands), numpy.uint8) 620 642 for i in range(tilebands): 621 array[:, :, i] = gdalarray.BandReadAsArray(dsquery.GetRasterBand(i + 1), 622 0, 0, querysize, querysize) 623 im = Image.fromarray(array, 'RGBA') # Always four bands 643 array[:, :, i] = gdalarray.BandReadAsArray( 644 dsquery.GetRasterBand(i + 1), 0, 0, querysize, querysize 645 ) 646 im = Image.fromarray(array, 'RGBA') # Always four bands 624 647 im1 = im.resize((tile_size, tile_size), Image.ANTIALIAS) 625 648 if os.path.exists(tilefilename): … … 646 669 647 670 # Other algorithms are implemented by gdal.ReprojectImage(). 648 dsquery.SetGeoTransform((0.0, tile_size / float(querysize), 0.0, 0.0, 0.0, 649 tile_size / float(querysize))) 671 dsquery.SetGeoTransform(( 672 0.0, tile_size / float(querysize), 0.0, 0.0, 0.0, 673 tile_size / float(querysize) 674 )) 650 675 dstile.SetGeoTransform((0.0, 1.0, 0.0, 0.0, 0.0, 1.0)) 651 676 652 677 res = gdal.ReprojectImage(dsquery, dstile, None, None, gdal_resampling) 653 678 if res != 0: 654 exit_with_error("ReprojectImage() failed on %s, error %d" % (tilefilename, res)) 679 exit_with_error( 680 "ReprojectImage() failed on %s, error %d" % 681 (tilefilename, res) 682 ) 655 683 656 684 … … 663 691 nds = list(map(float, options.srcnodata.split(','))) 664 692 if len(nds) < input_dataset.RasterCount: 665 in_nodata = (nds * input_dataset.RasterCount)[:input_dataset.RasterCount] 693 in_nodata = (nds * 694 input_dataset.RasterCount)[:input_dataset.RasterCount] 666 695 else: 667 696 in_nodata = nds … … 722 751 723 752 def has_georeference(dataset): 724 return (dataset.GetGeoTransform() != (0.0, 1.0, 0.0, 0.0, 0.0, 1.0) or 725 dataset.GetGCPCount() != 0) 753 return ( 754 dataset.GetGeoTransform() != (0.0, 1.0, 0.0, 0.0, 0.0, 1.0) 755 or dataset.GetGCPCount() != 0 756 ) 726 757 727 758 … … 732 763 """ 733 764 if not from_srs or not to_srs: 734 raise GDALError("from and to SRS must be defined to reproject the dataset") 735 736 if (from_srs.ExportToProj4() != to_srs.ExportToProj4()) or (from_dataset.GetGCPCount() != 0): 737 to_dataset = gdal.AutoCreateWarpedVRT(from_dataset, 738 from_srs.ExportToWkt(), to_srs.ExportToWkt()) 765 raise GDALError( 766 "from and to SRS must be defined to reproject the dataset" 767 ) 768 769 if (from_srs.ExportToProj4() != 770 to_srs.ExportToProj4()) or (from_dataset.GetGCPCount() != 0): 771 to_dataset = gdal.AutoCreateWarpedVRT( 772 from_dataset, from_srs.ExportToWkt(), to_srs.ExportToWkt() 773 ) 739 774 740 775 if options and options.verbose: 741 print("Warping of the raster by AutoCreateWarpedVRT (result saved into 'tiles.vrt')") 776 print( 777 "Warping of the raster by AutoCreateWarpedVRT (result saved into 'tiles.vrt')" 778 ) 742 779 to_dataset.GetDriver().CreateCopy("tiles.vrt", to_dataset) 743 780 … … 778 815 779 816 vrt_string = add_gdal_warp_options_to_string( 780 vrt_string, {"INIT_DEST": "NO_DATA", "UNIFIED_SRC_NODATA": "YES"}) 781 782 # TODO: gbataille - check the need for this replacement. Seems to work without 783 # # replace BandMapping tag for NODATA bands.... 784 # for i in range(len(nodata_values)): 785 # s = s.replace( 786 # '<BandMapping src="%i" dst="%i"/>' % ((i+1), (i+1)), 787 # """ 788 # <BandMapping src="%i" dst="%i"> 789 # <SrcNoDataReal>%i</SrcNoDataReal> 790 # <SrcNoDataImag>0</SrcNoDataImag> 791 # <DstNoDataReal>%i</DstNoDataReal> 792 # <DstNoDataImag>0</DstNoDataImag> 793 # </BandMapping> 794 # """ % ((i+1), (i+1), nodata_values[i], nodata_values[i])) 817 vrt_string, { 818 "INIT_DEST": "NO_DATA", 819 "UNIFIED_SRC_NODATA": "YES" 820 } 821 ) 822 823 # TODO: gbataille - check the need for this replacement. Seems to work without 824 # # replace BandMapping tag for NODATA bands.... 825 # for i in range(len(nodata_values)): 826 # s = s.replace( 827 # '<BandMapping src="%i" dst="%i"/>' % ((i+1), (i+1)), 828 # """ 829 # <BandMapping src="%i" dst="%i"> 830 # <SrcNoDataReal>%i</SrcNoDataReal> 831 # <SrcNoDataImag>0</SrcNoDataImag> 832 # <DstNoDataReal>%i</DstNoDataReal> 833 # <DstNoDataImag>0</DstNoDataImag> 834 # </BandMapping> 835 # """ % ((i+1), (i+1), nodata_values[i], nodata_values[i])) 795 836 796 837 corrected_dataset = gdal.Open(vrt_string) … … 798 839 # set NODATA_VALUE metadata 799 840 corrected_dataset.SetMetadataItem( 800 'NODATA_VALUES', ' '.join([str(i) for i in nodata_values])) 841 'NODATA_VALUES', ' '.join([str(i) for i in nodata_values]) 842 ) 801 843 802 844 if options and options.verbose: … … 831 873 832 874 tb = ElementTree.TreeBuilder() 833 tb.start("VRTRasterBand", 834 {'dataType': "Byte", "band": str(nb_bands + 1), "subClass": "VRTWarpedRasterBand"}) 875 tb.start( 876 "VRTRasterBand", { 877 'dataType': "Byte", 878 "band": str(nb_bands + 1), 879 "subClass": "VRTWarpedRasterBand" 880 } 881 ) 835 882 tb.start("ColorInterp", {}) 836 883 tb.data("Alpha") … … 887 934 """ 888 935 alphaband = dataset.GetRasterBand(1).GetMaskBand() 889 if ((alphaband.GetMaskFlags() & gdal.GMF_ALPHA) or 890 dataset.RasterCount == 4 or 891 dataset.RasterCount == 2): 936 if ((alphaband.GetMaskFlags() & gdal.GMF_ALPHA) or dataset.RasterCount == 4 937 or dataset.RasterCount == 2): 892 938 return dataset.RasterCount - 1 893 939 return dataset.RasterCount 940 894 941 895 942 def create_base_tile(tile_job_info, tile_detail, queue=None): … … 929 976 # Tile dataset in memory 930 977 tilefilename = os.path.join( 931 output, str(tz), str(tx), "%s.%s" % (ty, tileext)) 978 output, str(tz), str(tx), "%s.%s" % (ty, tileext) 979 ) 932 980 dstile = mem_drv.Create('', tile_size, tile_size, tilebands) 933 981 … … 935 983 936 984 if options.verbose: 937 print("\tReadRaster Extent: ", 938 (rx, ry, rxsize, rysize), (wx, wy, wxsize, wysize)) 985 print( 986 "\tReadRaster Extent: ", (rx, ry, rxsize, rysize), 987 (wx, wy, wxsize, wysize) 988 ) 939 989 940 990 # Query is in 'nearest neighbour' but can be bigger in then the tile_size … … 945 995 946 996 # Detect totally transparent tile and skip its creation 947 if tile_job_info.exclude_transparent and len(alpha) == alpha.count('\x00'.encode('ascii')): 997 if tile_job_info.exclude_transparent and len(alpha) == alpha.count( 998 '\x00'.encode('ascii') 999 ): 948 1000 return 949 1001 950 data = ds.ReadRaster(rx, ry, rxsize, rysize, wxsize, wysize, 951 band_list=list(range(1, dataBandsCount + 1))) 1002 data = ds.ReadRaster( 1003 rx, 1004 ry, 1005 rxsize, 1006 rysize, 1007 wxsize, 1008 wysize, 1009 band_list=list(range(1, dataBandsCount + 1)) 1010 ) 952 1011 953 1012 # The tile in memory is a transparent file by default. Write pixel values into it if … … 956 1015 if tile_size == querysize: 957 1016 # Use the ReadRaster result directly in tiles ('nearest neighbour' query) 958 dstile.WriteRaster(wx, wy, wxsize, wysize, data, 959 band_list=list(range(1, dataBandsCount + 1))) 960 dstile.WriteRaster(wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) 1017 dstile.WriteRaster( 1018 wx, 1019 wy, 1020 wxsize, 1021 wysize, 1022 data, 1023 band_list=list(range(1, dataBandsCount + 1)) 1024 ) 1025 dstile.WriteRaster( 1026 wx, wy, wxsize, wysize, alpha, band_list=[tilebands] 1027 ) 961 1028 962 1029 # Note: For source drivers based on WaveLet compression (JPEG2000, ECW, … … 970 1037 # TODO: fill the null value in case a tile without alpha is produced (now 971 1038 # only png tiles are supported) 972 dsquery.WriteRaster(wx, wy, wxsize, wysize, data, 973 band_list=list(range(1, dataBandsCount + 1))) 974 dsquery.WriteRaster(wx, wy, wxsize, wysize, alpha, band_list=[tilebands]) 975 976 scale_query_to_tile(dsquery, dstile, tile_job_info.tile_driver, options, 977 tilefilename=tilefilename) 1039 dsquery.WriteRaster( 1040 wx, 1041 wy, 1042 wxsize, 1043 wysize, 1044 data, 1045 band_list=list(range(1, dataBandsCount + 1)) 1046 ) 1047 dsquery.WriteRaster( 1048 wx, wy, wxsize, wysize, alpha, band_list=[tilebands] 1049 ) 1050 1051 scale_query_to_tile( 1052 dsquery, 1053 dstile, 1054 tile_job_info.tile_driver, 1055 options, 1056 tilefilename=tilefilename 1057 ) 978 1058 del dsquery 979 1059 … … 991 1071 if not options.resume or not os.path.exists(kmlfilename): 992 1072 with open(kmlfilename, 'wb') as f: 993 f.write(generate_kml( 994 tx, ty, tz, tile_job_info.tile_extension, tile_job_info.tile_size, 995 get_tile_swne(tile_job_info, options), tile_job_info.options 996 ).encode('utf-8')) 1073 f.write( 1074 generate_kml( 1075 tx, ty, tz, tile_job_info.tile_extension, 1076 tile_job_info.tile_size, 1077 get_tile_swne(tile_job_info, 1078 options), tile_job_info.options 1079 ).encode('utf-8') 1080 ) 997 1081 998 1082 if queue: … … 1032 1116 1033 1117 ti += 1 1034 tilefilename = os.path.join( output_folder,1035 str(tz),1036 str(tx),1037 "%s.%s" % (ty, tile_job_info.tile_extension))1118 tilefilename = os.path.join( 1119 output_folder, str(tz), str(tx), 1120 "%s.%s" % (ty, tile_job_info.tile_extension) 1121 ) 1038 1122 1039 1123 if options.verbose: … … 1051 1135 os.makedirs(os.path.dirname(tilefilename)) 1052 1136 1053 dsquery = mem_driver.Create('', 2 * tile_job_info.tile_size, 1054 2 * tile_job_info.tile_size, tilebands) 1137 dsquery = mem_driver.Create( 1138 '', 2 * tile_job_info.tile_size, 1139 2 * tile_job_info.tile_size, tilebands 1140 ) 1055 1141 # TODO: fill the null value 1056 dstile = mem_driver.Create('', tile_job_info.tile_size, tile_job_info.tile_size, 1057 tilebands) 1142 dstile = mem_driver.Create( 1143 '', tile_job_info.tile_size, tile_job_info.tile_size, 1144 tilebands 1145 ) 1058 1146 1059 1147 # TODO: Implement more clever walking on the tiles with cache functionality … … 1067 1155 minx, miny, maxx, maxy = tile_job_info.tminmax[tz + 1] 1068 1156 if x >= minx and x <= maxx and y >= miny and y <= maxy: 1069 base_tile_path = os.path.join(output_folder, str(tz + 1), str(x), 1070 "%s.%s" % (y, tile_job_info.tile_extension)) 1157 base_tile_path = os.path.join( 1158 output_folder, str(tz + 1), str(x), 1159 "%s.%s" % (y, tile_job_info.tile_extension) 1160 ) 1071 1161 if not os.path.isfile(base_tile_path): 1072 1162 continue 1073 1163 1074 1164 dsquerytile = gdal.Open( 1075 base_tile_path, 1076 gdal.GA_ReadOnly) 1077 if (ty == 0 and y == 1) or (ty != 0 and (y % (2 * ty)) != 0): 1165 base_tile_path, gdal.GA_ReadOnly 1166 ) 1167 if (ty == 0 and 1168 y == 1) or (ty != 0 and (y % (2 * ty)) != 0): 1078 1169 tileposy = 0 1079 1170 else: 1080 1171 tileposy = tile_job_info.tile_size 1081 1172 if tx: 1082 tileposx = x % (2 * tx) * tile_job_info.tile_size 1173 tileposx = x % ( 1174 2 * tx 1175 ) * tile_job_info.tile_size 1083 1176 elif tx == 0 and x == 1: 1084 1177 tileposx = tile_job_info.tile_size … … 1086 1179 tileposx = 0 1087 1180 dsquery.WriteRaster( 1088 tileposx, tileposy, tile_job_info.tile_size, 1181 tileposx, 1182 tileposy, 1089 1183 tile_job_info.tile_size, 1090 dsquerytile.ReadRaster(0, 0, 1091 tile_job_info.tile_size, 1092 tile_job_info.tile_size), 1093 band_list=list(range(1, tilebands + 1))) 1184 tile_job_info.tile_size, 1185 dsquerytile.ReadRaster( 1186 0, 0, tile_job_info.tile_size, 1187 tile_job_info.tile_size 1188 ), 1189 band_list=list(range(1, tilebands + 1)) 1190 ) 1094 1191 children.append([x, y, tz + 1]) 1095 1192 1096 1193 if children: 1097 scale_query_to_tile(dsquery, dstile, tile_driver, options, 1098 tilefilename=tilefilename) 1194 scale_query_to_tile( 1195 dsquery, 1196 dstile, 1197 tile_driver, 1198 options, 1199 tilefilename=tilefilename 1200 ) 1099 1201 # Write a copy of tile to png/jpg 1100 1202 if options.resampling != 'antialias': … … 1103 1205 1104 1206 if options.verbose: 1105 print("\tbuild from zoom", tz + 1, 1106 " tiles:", (2 * tx, 2 * ty), (2 * tx + 1, 2 * ty), 1107 (2 * tx, 2 * ty + 1), (2 * tx + 1, 2 * ty + 1)) 1207 print( 1208 "\tbuild from zoom", tz + 1, " tiles:", 1209 (2 * tx, 2 * ty), (2 * tx + 1, 2 * ty), 1210 (2 * tx, 2 * ty + 1), (2 * tx + 1, 2 * ty + 1) 1211 ) 1108 1212 1109 1213 # Create a KML file for this tile. 1110 1214 if tile_job_info.kml: 1111 with open(os.path.join( 1112 output_folder, 1113 '%d/%d/%d.kml' % (tz, tx, ty) 1114 ), 'wb') as f: 1115 f.write(generate_kml( 1116 tx, ty, tz, tile_job_info.tile_extension, tile_job_info.tile_size, 1117 get_tile_swne(tile_job_info, options), options, children 1118 ).encode('utf-8')) 1215 with open( 1216 os.path.join( 1217 output_folder, '%d/%d/%d.kml' % (tz, tx, ty) 1218 ), 'wb' 1219 ) as f: 1220 f.write( 1221 generate_kml( 1222 tx, ty, tz, tile_job_info.tile_extension, 1223 tile_job_info.tile_size, 1224 get_tile_swne(tile_job_info, 1225 options), options, children 1226 ).encode('utf-8') 1227 ) 1119 1228 1120 1229 if not options.verbose and not options.quiet: … … 1128 1237 usage = "Usage: %prog [options] input_file [output]" 1129 1238 p = OptionParser(usage, version="%prog " + __version__) 1130 p.add_option("-p", "--profile", dest='profile', 1131 type='choice', choices=profile_list, 1132 help=("Tile cutting profile (%s) - default 'mercator' " 1133 "(Google Maps compatible)" % ",".join(profile_list))) 1134 p.add_option("-r", "--resampling", dest="resampling", 1135 type='choice', choices=resampling_list, 1136 help="Resampling method (%s) - default 'average'" % ",".join(resampling_list)) 1137 p.add_option('-s', '--s_srs', dest="s_srs", metavar="SRS", 1138 help="The spatial reference system used for the source input data") 1139 p.add_option('-z', '--zoom', dest="zoom", 1140 help="Zoom levels to render (format:'2-5' or '10').") 1141 p.add_option('-e', '--resume', dest="resume", action="store_true", 1142 help="Resume mode. Generate only missing files.") 1143 p.add_option('-a', '--srcnodata', dest="srcnodata", metavar="NODATA", 1144 help="NODATA transparency value to assign to the input data") 1145 p.add_option('-d', '--tmscompatible', dest="tmscompatible", action="store_true", 1146 help=("When using the geodetic profile, specifies the base resolution " 1147 "as 0.703125 or 2 tiles at zoom level 0.")) 1148 p.add_option("-v", "--verbose", 1149 action="store_true", dest="verbose", 1150 help="Print status messages to stdout") 1151 p.add_option("-x", "--exclude", 1152 action="store_true", dest="exclude_transparent", 1153 help="Exclude transparent tiles from result tileset") 1154 p.add_option("-q", "--quiet", 1155 action="store_true", dest="quiet", 1156 help="Disable messages and status to stdout") 1157 p.add_option("--processes", 1158 dest="nb_processes", 1159 type='int', 1160 help="Number of processes to use for tiling") 1161 p.add_option("--tilesize", dest="tilesize", default=256, 1162 type='int', 1163 help="Tile size in pixel of a tile") 1239 p.add_option( 1240 "-p", 1241 "--profile", 1242 dest='profile', 1243 type='choice', 1244 choices=profile_list, 1245 help=( 1246 "Tile cutting profile (%s) - default 'mercator' " 1247 "(Google Maps compatible)" % ",".join(profile_list) 1248 ) 1249 ) 1250 p.add_option( 1251 "-r", 1252 "--resampling", 1253 dest="resampling", 1254 type='choice', 1255 choices=resampling_list, 1256 help="Resampling method (%s) - default 'average'" % 1257 ",".join(resampling_list) 1258 ) 1259 p.add_option( 1260 '-s', 1261 '--s_srs', 1262 dest="s_srs", 1263 metavar="SRS", 1264 help="The spatial reference system used for the source input data" 1265 ) 1266 p.add_option( 1267 '-z', 1268 '--zoom', 1269 dest="zoom", 1270 help="Zoom levels to render (format:'2-5' or '10')." 1271 ) 1272 p.add_option( 1273 '-e', 1274 '--resume', 1275 dest="resume", 1276 action="store_true", 1277 help="Resume mode. Generate only missing files." 1278 ) 1279 p.add_option( 1280 '-a', 1281 '--srcnodata', 1282 dest="srcnodata", 1283 metavar="NODATA", 1284 help="NODATA transparency value to assign to the input data" 1285 ) 1286 p.add_option( 1287 '-d', 1288 '--tmscompatible', 1289 dest="tmscompatible", 1290 action="store_true", 1291 help=( 1292 "When using the geodetic profile, specifies the base resolution " 1293 "as 0.703125 or 2 tiles at zoom level 0." 1294 ) 1295 ) 1296 p.add_option( 1297 "-v", 1298 "--verbose", 1299 action="store_true", 1300 dest="verbose", 1301 help="Print status messages to stdout" 1302 ) 1303 p.add_option( 1304 "-x", 1305 "--exclude", 1306 action="store_true", 1307 dest="exclude_transparent", 1308 help="Exclude transparent tiles from result tileset" 1309 ) 1310 p.add_option( 1311 "-q", 1312 "--quiet", 1313 action="store_true", 1314 dest="quiet", 1315 help="Disable messages and status to stdout" 1316 ) 1317 p.add_option( 1318 "--processes", 1319 dest="nb_processes", 1320 type='int', 1321 help="Number of processes to use for tiling" 1322 ) 1323 p.add_option( 1324 "--tilesize", 1325 dest="tilesize", 1326 default=256, 1327 type='int', 1328 help="Tile size in pixel of a tile" 1329 ) 1164 1330 1165 1331 # KML options 1166 g = OptionGroup(p, "KML (Google Earth) options", 1167 "Options for generated Google Earth SuperOverlay metadata") 1168 g.add_option("-k", "--force-kml", dest='kml', action="store_true", 1169 help=("Generate KML for Google Earth - default for 'geodetic' profile and " 1170 "'raster' in EPSG:4326. For a dataset with different projection use " 1171 "with caution!")) 1172 g.add_option("-n", "--no-kml", dest='kml', action="store_false", 1173 help="Avoid automatic generation of KML files for EPSG:4326") 1174 g.add_option("-u", "--url", dest='url', 1175 help="URL address where the generated tiles are going to be published") 1332 g = OptionGroup( 1333 p, "KML (Google Earth) options", 1334 "Options for generated Google Earth SuperOverlay metadata" 1335 ) 1336 g.add_option( 1337 "-k", 1338 "--force-kml", 1339 dest='kml', 1340 action="store_true", 1341 help=( 1342 "Generate KML for Google Earth - default for 'geodetic' profile and " 1343 "'raster' in EPSG:4326. For a dataset with different projection use " 1344 "with caution!" 1345 ) 1346 ) 1347 g.add_option( 1348 "-n", 1349 "--no-kml", 1350 dest='kml', 1351 action="store_false", 1352 help="Avoid automatic generation of KML files for EPSG:4326" 1353 ) 1354 g.add_option( 1355 "-u", 1356 "--url", 1357 dest='url', 1358 help="URL address where the generated tiles are going to be published" 1359 ) 1176 1360 p.add_option_group(g) 1177 1361 1178 1362 # HTML options 1179 g = OptionGroup(p, "Web viewer options", 1180 "Options for generated HTML viewers a la Google Maps") 1181 g.add_option("-w", "--webviewer", dest='webviewer', type='choice', choices=webviewer_list, 1182 help="Web viewer to generate (%s) - default 'all'" % ",".join(webviewer_list)) 1183 g.add_option("-t", "--title", dest='title', 1184 help="Title of the map") 1185 g.add_option("-c", "--copyright", dest='copyright', 1186 help="Copyright for the map") 1187 g.add_option("-g", "--googlekey", dest='googlekey', 1188 help="Google Maps API key from http://code.google.com/apis/maps/signup.html") 1189 g.add_option("-b", "--bingkey", dest='bingkey', 1190 help="Bing Maps API key from https://www.bingmapsportal.com/") 1363 g = OptionGroup( 1364 p, "Web viewer options", 1365 "Options for generated HTML viewers a la Google Maps" 1366 ) 1367 g.add_option( 1368 "-w", 1369 "--webviewer", 1370 dest='webviewer', 1371 type='choice', 1372 choices=webviewer_list, 1373 help="Web viewer to generate (%s) - default 'all'" % 1374 ",".join(webviewer_list) 1375 ) 1376 g.add_option("-t", "--title", dest='title', help="Title of the map") 1377 g.add_option( 1378 "-c", "--copyright", dest='copyright', help="Copyright for the map" 1379 ) 1380 g.add_option( 1381 "-g", 1382 "--googlekey", 1383 dest='googlekey', 1384 help= 1385 "Google Maps API key from http://code.google.com/apis/maps/signup.html" 1386 ) 1387 g.add_option( 1388 "-b", 1389 "--bingkey", 1390 dest='bingkey', 1391 help="Bing Maps API key from https://www.bingmapsportal.com/" 1392 ) 1191 1393 p.add_option_group(g) 1192 1394 1193 p.set_defaults(verbose=False, profile="mercator", kml=False, url='', 1194 webviewer='all', copyright='', resampling='average', resume=False, 1195 googlekey='INSERT_YOUR_KEY_HERE', bingkey='INSERT_YOUR_KEY_HERE', 1196 processes=1) 1395 p.set_defaults( 1396 verbose=False, 1397 profile="mercator", 1398 kml=False, 1399 url='', 1400 webviewer='all', 1401 copyright='', 1402 resampling='average', 1403 resume=False, 1404 googlekey='INSERT_YOUR_KEY_HERE', 1405 bingkey='INSERT_YOUR_KEY_HERE', 1406 processes=1 1407 ) 1197 1408 1198 1409 return p … … 1205 1416 # Args should be either an input file OR an input file and an output folder 1206 1417 if not args: 1207 exit_with_error("You need to specify at least an input file as argument to the script") 1418 exit_with_error( 1419 "You need to specify at least an input file as argument to the script" 1420 ) 1208 1421 if len(args) > 2: 1209 exit_with_error("Processing of several input files is not supported.", 1210 "Please first use a tool like gdal_vrtmerge.py or gdal_merge.py on the " 1211 "files: gdal_vrtmerge.py -o merged.vrt %s" % " ".join(args)) 1422 exit_with_error( 1423 "Processing of several input files is not supported.", 1424 "Please first use a tool like gdal_vrtmerge.py or gdal_merge.py on the " 1425 "files: gdal_vrtmerge.py -o merged.vrt %s" % " ".join(args) 1426 ) 1212 1427 1213 1428 input_file = args[0] 1214 1429 if not os.path.isfile(input_file): 1215 exit_with_error("The provided input file %s does not exist or is not a file" % input_file) 1430 exit_with_error( 1431 "The provided input file %s does not exist or is not a file" % 1432 input_file 1433 ) 1216 1434 1217 1435 if len(args) == 2: … … 1240 1458 # Supported options 1241 1459 if options.resampling == 'antialias' and not numpy_available: 1242 exit_with_error("'antialias' resampling algorithm is not available.", 1243 "Install PIL (Python Imaging Library) and numpy.") 1460 exit_with_error( 1461 "'antialias' resampling algorithm is not available.", 1462 "Install PIL (Python Imaging Library) and numpy." 1463 ) 1244 1464 1245 1465 try: … … 1253 1473 if not full_ascii and 'UTF-8' not in os.environ.get("LC_CTYPE", ""): 1254 1474 if not options.quiet: 1255 print("\nWARNING: " 1256 "You are running gdal2tiles.py with a LC_CTYPE environment variable that is " 1257 "not UTF-8 compatible, and your input file contains non-ascii characters. " 1258 "The generated sample googlemaps, openlayers or " 1259 "leaflet files might contain some invalid characters as a result\n") 1475 print( 1476 "\nWARNING: " 1477 "You are running gdal2tiles.py with a LC_CTYPE environment variable that is " 1478 "not UTF-8 compatible, and your input file contains non-ascii characters. " 1479 "The generated sample googlemaps, openlayers or " 1480 "leaflet files might contain some invalid characters as a result\n" 1481 ) 1260 1482 1261 1483 # Output the results … … 1340 1562 1341 1563 class GDAL2Tiles(object): 1342 1343 1564 def __init__(self, input_file, output_folder, options): 1344 1565 """Constructor function - initialization""" … … 1375 1596 self.tileext = 'png' 1376 1597 self.tmp_dir = tempfile.mkdtemp() 1377 self.tmp_vrt_filename = os.path.join(self.tmp_dir, str(uuid4()) + '.vrt') 1598 self.tmp_vrt_filename = os.path.join( 1599 self.tmp_dir, 1600 str(uuid4()) + '.vrt' 1601 ) 1378 1602 1379 1603 # Should we read bigger window of the input raster and scale it down? … … 1427 1651 1428 1652 if not self.out_drv: 1429 raise Exception("The '%s' driver was not found, is it available in this GDAL build?" % 1430 self.tiledriver) 1653 raise Exception( 1654 "The '%s' driver was not found, is it available in this GDAL build?" 1655 % self.tiledriver 1656 ) 1431 1657 if not self.mem_drv: 1432 raise Exception("The 'MEM' driver was not found, is it available in this GDAL build?") 1658 raise Exception( 1659 "The 'MEM' driver was not found, is it available in this GDAL build?" 1660 ) 1433 1661 1434 1662 # Open the input file … … 1440 1668 1441 1669 if self.options.verbose: 1442 print("Input file:", 1443 "( %sP x %sL - %s bands)" % (input_dataset.RasterXSize, 1444 input_dataset.RasterYSize, 1445 input_dataset.RasterCount)) 1670 print( 1671 "Input file:", "( %sP x %sL - %s bands)" % ( 1672 input_dataset.RasterXSize, input_dataset.RasterYSize, 1673 input_dataset.RasterCount 1674 ) 1675 ) 1446 1676 1447 1677 if not input_dataset: 1448 1678 # Note: GDAL prints the ERROR message too 1449 exit_with_error("It is not possible to open the input file '%s'." % self.input_file) 1679 exit_with_error( 1680 "It is not possible to open the input file '%s'." % 1681 self.input_file 1682 ) 1450 1683 1451 1684 # Read metadata from the input file 1452 1685 if input_dataset.RasterCount == 0: 1453 exit_with_error("Input file '%s' has no raster band" % self.input_file) 1686 exit_with_error( 1687 "Input file '%s' has no raster band" % self.input_file 1688 ) 1454 1689 1455 1690 if input_dataset.GetRasterBand(1).GetRasterColorTable(): … … 1465 1700 1466 1701 if self.options.verbose: 1467 print("Preprocessed file:", 1468 "( %sP x %sL - %s bands)" % (input_dataset.RasterXSize, 1469 input_dataset.RasterYSize, 1470 input_dataset.RasterCount)) 1702 print( 1703 "Preprocessed file:", "( %sP x %sL - %s bands)" % ( 1704 input_dataset.RasterXSize, input_dataset.RasterYSize, 1705 input_dataset.RasterCount 1706 ) 1707 ) 1471 1708 1472 1709 in_srs, self.in_srs_wkt = setup_input_srs(input_dataset, self.options) … … 1484 1721 exit_with_error( 1485 1722 "Input file has unknown SRS.", 1486 "Use --s_srs ESPG:xyz (or similar) to provide source reference system.") 1723 "Use --s_srs ESPG:xyz (or similar) to provide source reference system." 1724 ) 1487 1725 1488 1726 if not has_georeference(input_dataset): … … 1494 1732 ) 1495 1733 1496 if ((in_srs.ExportToProj4() != self.out_srs.ExportToProj4()) or1497 (input_dataset.GetGCPCount() != 0)):1734 if ((in_srs.ExportToProj4() != self.out_srs.ExportToProj4()) 1735 or (input_dataset.GetGCPCount() != 0)): 1498 1736 self.warped_input_dataset = reproject_dataset( 1499 input_dataset, in_srs, self.out_srs) 1737 input_dataset, in_srs, self.out_srs 1738 ) 1500 1739 1501 1740 if in_nodata: 1502 1741 self.warped_input_dataset = update_no_data_values( 1503 self.warped_input_dataset, in_nodata, options=self.options) 1742 self.warped_input_dataset, 1743 in_nodata, 1744 options=self.options 1745 ) 1504 1746 else: 1505 1747 self.warped_input_dataset = update_alpha_value_for_non_alpha_inputs( 1506 self.warped_input_dataset, options=self.options) 1748 self.warped_input_dataset, options=self.options 1749 ) 1507 1750 1508 1751 if self.warped_input_dataset and self.options.verbose: 1509 print("Projected file:", "tiles.vrt", "( %sP x %sL - %s bands)" % ( 1510 self.warped_input_dataset.RasterXSize, 1511 self.warped_input_dataset.RasterYSize, 1512 self.warped_input_dataset.RasterCount)) 1752 print( 1753 "Projected file:", "tiles.vrt", 1754 "( %sP x %sL - %s bands)" % ( 1755 self.warped_input_dataset.RasterXSize, 1756 self.warped_input_dataset.RasterYSize, 1757 self.warped_input_dataset.RasterCount 1758 ) 1759 ) 1513 1760 1514 1761 if not self.warped_input_dataset: 1515 1762 self.warped_input_dataset = input_dataset 1516 1763 1517 gdal.GetDriverByName('VRT').CreateCopy(self.tmp_vrt_filename, 1518 self.warped_input_dataset) 1764 gdal.GetDriverByName('VRT').CreateCopy( 1765 self.tmp_vrt_filename, self.warped_input_dataset 1766 ) 1519 1767 1520 1768 # Get alpha band (either directly or from NODATA value) 1521 self.alphaband = self.warped_input_dataset.GetRasterBand(1).GetMaskBand() 1769 self.alphaband = self.warped_input_dataset.GetRasterBand( 1770 1 1771 ).GetMaskBand() 1522 1772 self.dataBandsCount = nb_data_bands(self.warped_input_dataset) 1523 1773 … … 1526 1776 srs4326 = osr.SpatialReference() 1527 1777 srs4326.ImportFromEPSG(4326) 1528 if self.out_srs and srs4326.ExportToProj4() == self.out_srs.ExportToProj4(): 1778 if self.out_srs and srs4326.ExportToProj4( 1779 ) == self.out_srs.ExportToProj4(): 1529 1780 self.kml = True 1530 1781 self.isepsg4326 = True … … 1539 1790 # Report error in case rotation/skew is in geotransform (possible only in 'raster' profile) 1540 1791 if (self.out_gt[2], self.out_gt[4]) != (0, 0): 1541 exit_with_error("Georeference of the raster contains rotation or skew. " 1542 "Such raster is not supported. Please use gdalwarp first.") 1792 exit_with_error( 1793 "Georeference of the raster contains rotation or skew. " 1794 "Such raster is not supported. Please use gdalwarp first." 1795 ) 1543 1796 1544 1797 # Here we expect: pixel is square, no rotation on the raster … … 1546 1799 # Output Bounds - coordinates in the output SRS 1547 1800 self.ominx = self.out_gt[0] 1548 self.omaxx = self.out_gt[0] + self.warped_input_dataset.RasterXSize * self.out_gt[1] 1801 self.omaxx = self.out_gt[ 1802 0] + self.warped_input_dataset.RasterXSize * self.out_gt[1] 1549 1803 self.omaxy = self.out_gt[3] 1550 self.ominy = self.out_gt[3] - self.warped_input_dataset.RasterYSize * self.out_gt[1] 1804 self.ominy = self.out_gt[ 1805 3] - self.warped_input_dataset.RasterYSize * self.out_gt[1] 1551 1806 # Note: maybe round(x, 14) to avoid the gdal_translate behaviour, when 0 becomes -1e-15 1552 1807 1553 1808 if self.options.verbose: 1554 print("Bounds (output srs):", round(self.ominx, 13), self.ominy, self.omaxx, self.omaxy) 1809 print( 1810 "Bounds (output srs):", round(self.ominx, 13), self.ominy, 1811 self.omaxx, self.omaxy 1812 ) 1555 1813 1556 1814 # Calculating ranges for tiles in different zoom levels … … 1565 1823 self.tminmax = list(range(0, 32)) 1566 1824 for tz in range(0, 32): 1567 tminx, tminy = self.mercator.MetersToTile(self.ominx, self.ominy, tz) 1568 tmaxx, tmaxy = self.mercator.MetersToTile(self.omaxx, self.omaxy, tz) 1825 tminx, tminy = self.mercator.MetersToTile( 1826 self.ominx, self.ominy, tz 1827 ) 1828 tmaxx, tmaxy = self.mercator.MetersToTile( 1829 self.omaxx, self.omaxy, tz 1830 ) 1569 1831 # crop tiles extending world limits (+-180,+-90) 1570 1832 tminx, tminy = max(0, tminx), max(0, tminy) … … 1577 1839 if self.tminz is None: 1578 1840 self.tminz = self.mercator.ZoomForPixelSize( 1579 self.out_gt[1] * 1580 max(self.warped_input_dataset.RasterXSize, 1581 self.warped_input_dataset.RasterYSize) / 1582 float(self.tile_size)) 1841 self.out_gt[1] * max( 1842 self.warped_input_dataset.RasterXSize, 1843 self.warped_input_dataset.RasterYSize 1844 ) / float(self.tile_size) 1845 ) 1583 1846 1584 1847 # Get the maximal zoom level … … 1588 1851 1589 1852 if self.options.verbose: 1590 print("Bounds (latlong):", 1591 self.mercator.MetersToLatLon(self.ominx, self.ominy), 1592 self.mercator.MetersToLatLon(self.omaxx, self.omaxy)) 1853 print( 1854 "Bounds (latlong):", 1855 self.mercator.MetersToLatLon(self.ominx, self.ominy), 1856 self.mercator.MetersToLatLon(self.omaxx, self.omaxy) 1857 ) 1593 1858 print('MinZoomLevel:', self.tminz) 1594 print("MaxZoomLevel:", 1595 self.tmaxz, 1596 "(", 1597 self.mercator.Resolution(self.tmaxz), 1598 ")") 1859 print( 1860 "MaxZoomLevel:", self.tmaxz, "(", 1861 self.mercator.Resolution(self.tmaxz), ")" 1862 ) 1599 1863 1600 1864 if self.options.profile == 'geodetic': 1601 1865 1602 self.geodetic = GlobalGeodetic(self.options.tmscompatible, tile_size=self.tile_size) 1866 self.geodetic = GlobalGeodetic( 1867 self.options.tmscompatible, tile_size=self.tile_size 1868 ) 1603 1869 1604 1870 # Function which generates SWNE in LatLong for given tile … … 1608 1874 self.tminmax = list(range(0, 32)) 1609 1875 for tz in range(0, 32): 1610 tminx, tminy = self.geodetic.LonLatToTile(self.ominx, self.ominy, tz) 1611 tmaxx, tmaxy = self.geodetic.LonLatToTile(self.omaxx, self.omaxy, tz) 1876 tminx, tminy = self.geodetic.LonLatToTile( 1877 self.ominx, self.ominy, tz 1878 ) 1879 tmaxx, tmaxy = self.geodetic.LonLatToTile( 1880 self.omaxx, self.omaxy, tz 1881 ) 1612 1882 # crop tiles extending world limits (+-180,+-90) 1613 1883 tminx, tminy = max(0, tminx), max(0, tminy) 1614 tmaxx, tmaxy = min(2**(tz + 1) - 1, tmaxx), min(2**tz - 1, tmaxy) 1884 tmaxx, tmaxy = min(2**(tz + 1) - 1, 1885 tmaxx), min(2**tz - 1, tmaxy) 1615 1886 self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) 1616 1887 … … 1621 1892 if self.tminz is None: 1622 1893 self.tminz = self.geodetic.ZoomForPixelSize( 1623 self.out_gt[1] * 1624 max(self.warped_input_dataset.RasterXSize, 1625 self.warped_input_dataset.RasterYSize) / 1626 float(self.tile_size)) 1894 self.out_gt[1] * max( 1895 self.warped_input_dataset.RasterXSize, 1896 self.warped_input_dataset.RasterYSize 1897 ) / float(self.tile_size) 1898 ) 1627 1899 1628 1900 # Get the maximal zoom level … … 1632 1904 1633 1905 if self.options.verbose: 1634 print("Bounds (latlong):", self.ominx, self.ominy, self.omaxx, self.omaxy) 1906 print( 1907 "Bounds (latlong):", self.ominx, self.ominy, self.omaxx, 1908 self.omaxy 1909 ) 1635 1910 1636 1911 if self.options.profile == 'raster': … … 1640 1915 1641 1916 self.nativezoom = int( 1642 max(math.ceil(log2(self.warped_input_dataset.RasterXSize / float(self.tile_size))), 1643 math.ceil(log2(self.warped_input_dataset.RasterYSize / float(self.tile_size))))) 1917 max( 1918 math.ceil( 1919 log2( 1920 self.warped_input_dataset.RasterXSize / 1921 float(self.tile_size) 1922 ) 1923 ), 1924 math.ceil( 1925 log2( 1926 self.warped_input_dataset.RasterYSize / 1927 float(self.tile_size) 1928 ) 1929 ) 1930 ) 1931 ) 1644 1932 1645 1933 if self.options.verbose: … … 1660 1948 tsize = 2.0**(self.nativezoom - tz) * self.tile_size 1661 1949 tminx, tminy = 0, 0 1662 tmaxx = int(math.ceil(self.warped_input_dataset.RasterXSize / tsize)) - 1 1663 tmaxy = int(math.ceil(self.warped_input_dataset.RasterYSize / tsize)) - 1 1950 tmaxx = int( 1951 math.ceil(self.warped_input_dataset.RasterXSize / tsize) 1952 ) - 1 1953 tmaxy = int( 1954 math.ceil(self.warped_input_dataset.RasterYSize / tsize) 1955 ) - 1 1664 1956 self.tsize[tz] = math.ceil(tsize) 1665 1957 self.tminmax[tz] = (tminx, tminy, tmaxx, tmaxy) … … 1670 1962 1671 1963 def rastertileswne(x, y, z): 1672 pixelsizex = (2**(self.tmaxz - z) * self.out_gt[1]) # X-pixel size in level 1964 pixelsizex = ( 1965 2**(self.tmaxz - z) * self.out_gt[1] 1966 ) # X-pixel size in level 1673 1967 west = self.out_gt[0] + x * self.tile_size * pixelsizex 1674 1968 east = west + self.tile_size * pixelsizex … … 1683 1977 self.tileswne = rastertileswne 1684 1978 else: 1685 self.tileswne = lambda x, y, z: (0, 0, 0, 0) # noqa1979 self.tileswne = lambda x, y, z: (0, 0, 0, 0) # noqa 1686 1980 1687 1981 def generate_metadata(self): … … 1703 1997 1704 1998 # Generate googlemaps.html 1705 if self.options.webviewer in ('all', 'google') and self.options.profile == 'mercator': 1706 if (not self.options.resume or not 1707 os.path.exists(os.path.join(self.output_folder, 'googlemaps.html'))): 1708 with open(os.path.join(self.output_folder, 'googlemaps.html'), 'wb') as f: 1999 if self.options.webviewer in ( 2000 'all', 'google' 2001 ) and self.options.profile == 'mercator': 2002 if ( 2003 not self.options.resume or not os.path.exists( 2004 os.path.join(self.output_folder, 'googlemaps.html') 2005 ) 2006 ): 2007 with open( 2008 os.path.join(self.output_folder, 'googlemaps.html'), 2009 'wb' 2010 ) as f: 1709 2011 f.write(self.generate_googlemaps().encode('utf-8')) 1710 2012 1711 2013 # Generate openlayers.html 1712 2014 if self.options.webviewer in ('all', 'openlayers'): 1713 if (not self.options.resume or not 1714 os.path.exists(os.path.join(self.output_folder, 'openlayers.html'))): 1715 with open(os.path.join(self.output_folder, 'openlayers.html'), 'wb') as f: 2015 if ( 2016 not self.options.resume or not os.path.exists( 2017 os.path.join(self.output_folder, 'openlayers.html') 2018 ) 2019 ): 2020 with open( 2021 os.path.join(self.output_folder, 'openlayers.html'), 2022 'wb' 2023 ) as f: 1716 2024 f.write(self.generate_openlayers().encode('utf-8')) 1717 2025 1718 2026 # Generate leaflet.html 1719 2027 if self.options.webviewer in ('all', 'leaflet'): 1720 if (not self.options.resume or not 1721 os.path.exists(os.path.join(self.output_folder, 'leaflet.html'))): 1722 with open(os.path.join(self.output_folder, 'leaflet.html'), 'wb') as f: 2028 if ( 2029 not self.options.resume or not os.path.exists( 2030 os.path.join(self.output_folder, 'leaflet.html') 2031 ) 2032 ): 2033 with open( 2034 os.path.join(self.output_folder, 'leaflet.html'), 'wb' 2035 ) as f: 1723 2036 f.write(self.generate_leaflet().encode('utf-8')) 1724 2037 … … 1733 2046 # Generate openlayers.html 1734 2047 if self.options.webviewer in ('all', 'openlayers'): 1735 if (not self.options.resume or not 1736 os.path.exists(os.path.join(self.output_folder, 'openlayers.html'))): 1737 with open(os.path.join(self.output_folder, 'openlayers.html'), 'wb') as f: 2048 if ( 2049 not self.options.resume or not os.path.exists( 2050 os.path.join(self.output_folder, 'openlayers.html') 2051 ) 2052 ): 2053 with open( 2054 os.path.join(self.output_folder, 'openlayers.html'), 2055 'wb' 2056 ) as f: 1738 2057 f.write(self.generate_openlayers().encode('utf-8')) 1739 2058 … … 1747 2066 # Generate openlayers.html 1748 2067 if self.options.webviewer in ('all', 'openlayers'): 1749 if (not self.options.resume or not 1750 os.path.exists(os.path.join(self.output_folder, 'openlayers.html'))): 1751 with open(os.path.join(self.output_folder, 'openlayers.html'), 'wb') as f: 2068 if ( 2069 not self.options.resume or not os.path.exists( 2070 os.path.join(self.output_folder, 'openlayers.html') 2071 ) 2072 ): 2073 with open( 2074 os.path.join(self.output_folder, 'openlayers.html'), 2075 'wb' 2076 ) as f: 1752 2077 f.write(self.generate_openlayers().encode('utf-8')) 1753 2078 1754 2079 # Generate tilemapresource.xml. 1755 if not self.options.resume or not os.path.exists(os.path.join(self.output_folder, 'tilemapresource.xml')): 1756 with open(os.path.join(self.output_folder, 'tilemapresource.xml'), 'wb') as f: 2080 if not self.options.resume or not os.path.exists( 2081 os.path.join(self.output_folder, 'tilemapresource.xml') 2082 ): 2083 with open( 2084 os.path.join(self.output_folder, 'tilemapresource.xml'), 'wb' 2085 ) as f: 1757 2086 f.write(self.generate_tilemapresource().encode('utf-8')) 1758 2087 … … 1767 2096 # Generate Root KML 1768 2097 if self.kml: 1769 if (not self.options.resume or not 1770 os.path.exists(os.path.join(self.output_folder, 'doc.kml'))): 1771 with open(os.path.join(self.output_folder, 'doc.kml'), 'wb') as f: 1772 f.write(generate_kml( 1773 None, None, None, self.tileext, self.tile_size, self.tileswne, 1774 self.options, children 1775 ).encode('utf-8')) 2098 if ( 2099 not self.options.resume or not os.path.exists( 2100 os.path.join(self.output_folder, 'doc.kml') 2101 ) 2102 ): 2103 with open( 2104 os.path.join(self.output_folder, 'doc.kml'), 'wb' 2105 ) as f: 2106 f.write( 2107 generate_kml( 2108 None, None, None, self.tileext, self.tile_size, 2109 self.tileswne, self.options, children 2110 ).encode('utf-8') 2111 ) 1776 2112 1777 2113 def generate_base_tiles(self): … … 1811 2147 ti += 1 1812 2148 tilefilename = os.path.join( 1813 self.output_folder, str(tz), str(tx), "%s.%s" % (ty, self.tileext)) 2149 self.output_folder, str(tz), str(tx), 2150 "%s.%s" % (ty, self.tileext) 2151 ) 1814 2152 if self.options.verbose: 1815 2153 print(ti, '/', tcount, tilefilename) … … 1839 2177 nativesize = wb[0] + wb[2] 1840 2178 if self.options.verbose: 1841 print("\tNative Extent (querysize", nativesize, "): ", rb, wb) 2179 print( 2180 "\tNative Extent (querysize", nativesize, "): ", 2181 rb, wb 2182 ) 1842 2183 1843 2184 # Tile bounds in raster coordinates for ReadRaster query 1844 rb, wb = self.geo_query(ds, b[0], b[3], b[2], b[1], querysize=querysize) 2185 rb, wb = self.geo_query( 2186 ds, b[0], b[3], b[2], b[1], querysize=querysize 2187 ) 1845 2188 1846 2189 rx, ry, rxsize, rysize = rb 1847 2190 wx, wy, wxsize, wysize = wb 1848 2191 1849 else: # 'raster' profile: 1850 1851 tsize = int(self.tsize[tz]) # tile_size in raster coordinates for actual zoom 1852 xsize = self.warped_input_dataset.RasterXSize # size of the raster in pixels 2192 else: # 'raster' profile: 2193 2194 tsize = int( 2195 self.tsize[tz] 2196 ) # tile_size in raster coordinates for actual zoom 2197 xsize = self.warped_input_dataset.RasterXSize # size of the raster in pixels 1853 2198 ysize = self.warped_input_dataset.RasterYSize 1854 2199 if tz >= self.nativezoom: … … 1879 2224 tile_details.append( 1880 2225 TileDetail( 1881 tx=tx, ty=ty, tz=tz, rx=rx, ry=ry, rxsize=rxsize, rysize=rysize, wx=wx, 1882 wy=wy, wxsize=wxsize, wysize=wysize, querysize=querysize, 2226 tx=tx, 2227 ty=ty, 2228 tz=tz, 2229 rx=rx, 2230 ry=ry, 2231 rxsize=rxsize, 2232 rysize=rysize, 2233 wx=wx, 2234 wy=wy, 2235 wxsize=wxsize, 2236 wysize=wysize, 2237 querysize=querysize, 1883 2238 ) 1884 2239 ) … … 1984 2339 <TileFormat width="%(tile_size)d" height="%(tile_size)d" mime-type="image/%(tileformat)s" extension="%(tileformat)s"/> 1985 2340 <TileSets profile="%(profile)s"> 1986 """ % args # noqa2341 """ % args # noqa 1987 2342 for z in range(self.tminz, self.tmaxz + 1): 1988 2343 if self.options.profile == 'raster': 1989 2344 s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( 1990 args['publishurl'], z, (2**(self.nativezoom - z) * self.out_gt[1]), z) 2345 args['publishurl'], z, 2346 (2**(self.nativezoom - z) * self.out_gt[1]), z 2347 ) 1991 2348 elif self.options.profile == 'mercator': 1992 2349 s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( 1993 args['publishurl'], z, 156543.0339 / 2**z, z) 2350 args['publishurl'], z, 156543.0339 / 2**z, z 2351 ) 1994 2352 elif self.options.profile == 'geodetic': 1995 2353 s += """ <TileSet href="%s%d" units-per-pixel="%.14f" order="%d"/>\n""" % ( 1996 args['publishurl'], z, 0.703125 / 2**z, z) 2354 args['publishurl'], z, 0.703125 / 2**z, z 2355 ) 1997 2356 s += """ </TileSets> 1998 2357 </TileMap> … … 2241 2600 map.addControl(new GHierarchicalMapTypeControl()); 2242 2601 map.addControl(new CTransparencyControl( overlay )); 2243 """ % args # noqa2602 """ % args # noqa 2244 2603 if self.kml: 2245 2604 s += """ … … 2278 2637 } 2279 2638 } 2280 """ % args # noqa2639 """ % args # noqa 2281 2640 s += """ 2282 2641 onresize=function(){ resize(); }; … … 2293 2652 </body> 2294 2653 </html> 2295 """ % args # noqa2654 """ % args # noqa 2296 2655 2297 2656 return s … … 2424 2783 </html> 2425 2784 2426 """ % args # noqa2785 """ % args # noqa 2427 2786 2428 2787 return s … … 2468 2827 .olImageLoadError { display: none; } 2469 2828 .olControlLayerSwitcher .layersDiv { border-radius: 10px 0 0 10px; } 2470 </style>""" % args # noqa2829 </style>""" % args # noqa 2471 2830 2472 2831 if self.options.profile == 'mercator': … … 2566 2925 2567 2926 map.zoomToExtent(mapBounds.transform(map.displayProjection, map.projection)); 2568 """ % args # noqa2927 """ % args # noqa 2569 2928 2570 2929 elif self.options.profile == 'geodetic': … … 2604 2963 2605 2964 map.zoomToExtent(mapBounds); 2606 """ % args # noqa2965 """ % args # noqa 2607 2966 2608 2967 elif self.options.profile == 'raster': … … 2628 2987 map.addLayer(layer); 2629 2988 map.zoomToExtent(mapBounds); 2630 """ % args # noqa2989 """ % args # noqa 2631 2990 2632 2991 s += """ … … 2661 3020 } 2662 3021 } 2663 """ % args # noqa3022 """ % args # noqa 2664 3023 2665 3024 elif self.options.profile == 'geodetic': … … 2682 3041 } 2683 3042 } 2684 """ % args # noqa3043 """ % args # noqa 2685 3044 2686 3045 elif self.options.profile == 'raster': … … 2703 3062 } 2704 3063 } 2705 """ % args # noqa3064 """ % args # noqa 2706 3065 2707 3066 s += """ … … 2745 3104 <script type="text/javascript" >resize()</script> 2746 3105 </body> 2747 </html>""" % args # noqa3106 </html>""" % args # noqa 2748 3107 2749 3108 return s … … 2775 3134 2776 3135 class ProgressBar(object): 2777 2778 3136 def __init__(self, total_items): 2779 3137 self.total_items = total_items … … 2820 3178 2821 3179 def rastertileswne(x, y, z): 2822 pixelsizex = (2 ** (tile_job_info.tmaxz - z) * tile_job_info.out_geo_trans[1]) 2823 west = tile_job_info.out_geo_trans[0] + x * tile_job_info.tile_size * pixelsizex 3180 pixelsizex = ( 3181 2**(tile_job_info.tmaxz - z) * 3182 tile_job_info.out_geo_trans[1] 3183 ) 3184 west = tile_job_info.out_geo_trans[ 3185 0] + x * tile_job_info.tile_size * pixelsizex 2824 3186 east = west + tile_job_info.tile_size * pixelsizex 2825 3187 south = tile_job_info.ominy + y * tile_job_info.tile_size * pixelsizex … … 2833 3195 tile_swne = rastertileswne 2834 3196 else: 2835 tile_swne = lambda x, y, z: (0, 0, 0, 0) # noqa3197 tile_swne = lambda x, y, z: (0, 0, 0, 0) # noqa 2836 3198 else: 2837 tile_swne = lambda x, y, z: (0, 0, 0, 0) # noqa3199 tile_swne = lambda x, y, z: (0, 0, 0, 0) # noqa 2838 3200 2839 3201 return tile_swne … … 2847 3209 if options.verbose: 2848 3210 print("Begin tiles details calc") 2849 conf, tile_details = worker_tile_details(input_file, output_folder, options) 3211 conf, tile_details = worker_tile_details( 3212 input_file, output_folder, options 3213 ) 2850 3214 2851 3215 if options.verbose: … … 2880 3244 if options.verbose: 2881 3245 print("Begin tiles details calc") 2882 p = Process(target=worker_tile_details, 2883 args=[input_file, output_folder, options], 2884 kwargs={"send_pipe": conf_sender}) 3246 p = Process( 3247 target=worker_tile_details, 3248 args=[input_file, output_folder, options], 3249 kwargs={"send_pipe": conf_sender} 3250 ) 2885 3251 p.start() 2886 3252 # Make sure to consume the queue before joining. If the payload is too big, it won't be put in … … 2899 3265 # TODO: gbataille - assign an ID to each job for print in verbose mode "ReadRaster Extent ..." 2900 3266 for tile_detail in tile_details: 2901 pool.apply_async(create_base_tile, (conf, tile_detail), {"queue": queue}) 3267 pool.apply_async( 3268 create_base_tile, (conf, tile_detail), {"queue": queue} 3269 ) 2902 3270 2903 3271 if not options.verbose and not options.quiet: 2904 p = Process(target=progress_printer_thread, args=[queue, len(tile_details)]) 3272 p = Process( 3273 target=progress_printer_thread, args=[queue, 3274 len(tile_details)] 3275 ) 2905 3276 p.start() 2906 3277 2907 3278 pool.close() 2908 pool.join() # Jobs finished3279 pool.join() # Jobs finished 2909 3280 if not options.verbose and not options.quiet: 2910 p.join() # Traces done3281 p.join() # Traces done 2911 3282 2912 3283 create_overview_tiles(conf, output_folder, options) -
src/gnuboat/common/bin/gnuboat-log-analyser
r77cd9cf r43fd35c 2 2 # -*- coding: utf-8 -*- 3 3 ''' 4 Copyright (C) 2018 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.4 Copyright (C) 2018 - 2020 EngSaS - Langenbach. All rights reserved. 5 5 6 6 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/bin/gnuboat-log-converter
r77cd9cf r43fd35c 2 2 # -*- coding: utf-8 -*- 3 3 ''' 4 Copyright (C) 2016 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.4 Copyright (C) 2016 - 2020 EngSaS - Langenbach. All rights reserved. 5 5 6 6 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/bin/gnuboat-log-uploader
r77cd9cf r43fd35c 2 2 # -*- coding: utf-8 -*- 3 3 ''' 4 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.4 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 5 5 6 6 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/css/GnuBoat.Colors.css
r77cd9cf r43fd35c 1 1 /* 2 Copyright (C) 2018 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2018 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/css/side-menu.css
r77cd9cf r43fd35c 1 1 /* 2 Copyright (C) 2017 - 2019 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2017 - 2019 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/datahandler/__init__.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2018 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2018 - 2020 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/datahandler/logdataset.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2016 - 2018 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2016 - 2018 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/datahandler/loghandler.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2016 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2016 - 2020 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 25 25 import math 26 26 27 from gnuboat _common.datahandler import logdataset27 from gnuboat.common.datahandler import logdataset 28 28 29 29 -
src/gnuboat/common/js/GnuBoat.js
r77cd9cf r43fd35c 1 1 /* 2 2 3 Copyright (C) 2016 - 2018 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2016 - 2018 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This library is free software; you can redistribute it and/or -
src/gnuboat/common/spatial/__init__.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/spatial/tilegenerator.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/tests/__init__.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify -
src/gnuboat/common/tests/test_tilegenerator.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 28 28 from osgeo import osr 29 29 30 from gnuboat _common.spatial import tilegenerator30 from gnuboat.common.spatial import tilegenerator 31 31 32 32 -
src/gnuboat/device/bin/gnuboat
r77cd9cf r43fd35c 2 2 # -*- coding: utf-8 -*- 3 3 ''' 4 Copyright (C) 2016 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.4 Copyright (C) 2016 - 2020 EngSaS - Langenbach. All rights reserved. 5 5 6 6 This program is free software: you can redistribute it and/or modify … … 33 33 import math 34 34 35 from gnuboat import daemon 36 from gnuboat_common.datahandler import loghandler, logdataset 35 from gnuboat.device.daemon import ( 36 n2kdpoller as n2kdpoller, 37 gpsdpoller as gpsdpoller, 38 displayhandler as displayhandler, 39 rrdhandler as rrdhandler 40 ) 41 from gnuboat.common.datahandler import loghandler, logdataset 37 42 38 43 WHITE = 1 … … 69 74 os.system("sudo shutdown -h now") 70 75 76 71 77 def main(argv): 72 78 global rrdfile … … 79 85 global log_handler 80 86 81 parser = argparse.ArgumentParser(description='Collects the data from canboat and gpsd and writes them to the rrd database and the nmea log file') 82 parser.add_argument('-r', '--rrdfile', dest='rrd_file', metavar='rrd_file', type=str, 83 help='Path to the rrd database used by the webservice to serve the clients', default=rrdfile) 84 parser.add_argument('-s', '--shutdownfile', dest='shutdown_file', metavar='shutdown_file', type=str, 85 help='Path to the shutdown request file, used by the webservice to request a shutdown of the system running gnuboat', default=shutdownfile) 86 parser.add_argument('-lp', '--logperiod', dest='log_period', metavar='log_period', type=int, 87 help='Time in seconds to update the logs', default=logperiod) 88 parser.add_argument('-lv', '--log-verbose', action='store_true', dest='log_verbose', 89 help='Log verbose information to nmea log file (Enables -ls and adds RMC sentences, with invalid GPS state, on non fixes (Default off)') 90 parser.add_argument('-ls', '--log-system-time', action='store_true', dest='log_system_time', 91 help='Add to enable prefixing every logline with the system time (Default off)') 92 parser.add_argument('-d', '--displayperiod', dest='display_period', metavar='display_period', type=int, 93 help='Time in seconds to update the display', default=displayperiod) 94 parser.add_argument('-o', '--output', dest='output', metavar='output', type=str, 95 help='Directory where the log files are stored (e.g. the NMEA0183 log files)', default=logdir) 87 parser = argparse.ArgumentParser( 88 description= 89 'Collects the data from canboat and gpsd and writes them to the rrd database and the nmea log file' 90 ) 91 parser.add_argument( 92 '-r', 93 '--rrdfile', 94 dest='rrd_file', 95 metavar='rrd_file', 96 type=str, 97 help= 98 'Path to the rrd database used by the webservice to serve the clients', 99 default=rrdfile 100 ) 101 parser.add_argument( 102 '-s', 103 '--shutdownfile', 104 dest='shutdown_file', 105 metavar='shutdown_file', 106 type=str, 107 help= 108 'Path to the shutdown request file, used by the webservice to request a shutdown of the system running gnuboat', 109 default=shutdownfile 110 ) 111 parser.add_argument( 112 '-lp', 113 '--logperiod', 114 dest='log_period', 115 metavar='log_period', 116 type=int, 117 help='Time in seconds to update the logs', 118 default=logperiod 119 ) 120 parser.add_argument( 121 '-lv', 122 '--log-verbose', 123 action='store_true', 124 dest='log_verbose', 125 help= 126 'Log verbose information to nmea log file (Enables -ls and adds RMC sentences, with invalid GPS state, on non fixes (Default off)' 127 ) 128 parser.add_argument( 129 '-ls', 130 '--log-system-time', 131 action='store_true', 132 dest='log_system_time', 133 help= 134 'Add to enable prefixing every logline with the system time (Default off)' 135 ) 136 parser.add_argument( 137 '-d', 138 '--displayperiod', 139 dest='display_period', 140 metavar='display_period', 141 type=int, 142 help='Time in seconds to update the display', 143 default=displayperiod 144 ) 145 parser.add_argument( 146 '-o', 147 '--output', 148 dest='output', 149 metavar='output', 150 type=str, 151 help= 152 'Directory where the log files are stored (e.g. the NMEA0183 log files)', 153 default=logdir 154 ) 96 155 arguments = parser.parse_args(argv) 97 156 98 157 if arguments.rrd_file is not None: 99 158 rrdfile = arguments.rrd_file … … 101 160 shutdownfile = arguments.shutdown_file 102 161 if arguments.log_period is not None: 103 logperiod = arguments.log_period 162 logperiod = arguments.log_period 104 163 if arguments.log_verbose is not None: 105 164 logverbose = arguments.log_verbose … … 113 172 114 173 if not os.path.exists(os.path.dirname(rrdfile)): 115 print('rrd database directory not found {}'.format(os.path.dirname(rrdfile))) 174 print( 175 'rrd database directory not found {}'.format( 176 os.path.dirname(rrdfile) 177 ) 178 ) 116 179 parser.print_help() 117 180 sys.exit(2) 118 181 119 182 if not os.path.exists(os.path.dirname(shutdownfile)): 120 print('Shutdown request directory not found {}'.format(os.path.dirname(shutdownfile))) 183 print( 184 'Shutdown request directory not found {}'.format( 185 os.path.dirname(shutdownfile) 186 ) 187 ) 121 188 parser.print_help() 122 189 sys.exit(2) … … 128 195 129 196 if displayperiod < 1 or displayperiod < logperiod: 130 print('Display period must be >= 1 and could not be faster than log period') 131 parser.print_help() 132 sys.exit(2) 133 134 daemon.rrd_create_database(rrdfile, logperiod) 197 print( 198 'Display period must be >= 1 and could not be faster than log period' 199 ) 200 parser.print_help() 201 sys.exit(2) 202 203 rrdhandler.rrd_create_database(rrdfile, logperiod) 135 204 136 205 if os.path.isfile(shutdownfile): 137 206 os.remove(shutdownfile) 138 207 139 displayHandler = d aemon.DisplayHandler(displayperiod)208 displayHandler = displayhandler.DisplayHandler(displayperiod) 140 209 log_handler = loghandler.LogHandler(logdir) 141 210 142 gpsp = daemon.GpsdPoller(logperiod)143 n2kd = daemon.N2kdPoller(logperiod)211 gpsp = gpsdpoller.GpsdPoller(logperiod) 212 n2kd = n2kdpoller.N2kdPoller(logperiod) 144 213 try: 145 214 gpsp.start() … … 159 228 160 229 # update rrd database for the webservice 161 daemon.rrd_update(rrdfile, 'N:{}:{}:{}:{}:{}:{}:{}:{}'.format( 162 latitude, longitude, speedThroughWater, speedOverGround, courseOverGround, waterDepth, waterTemperature, gpsFix)) 230 rrdhandler.rrd_update( 231 rrdfile, 'N:{}:{}:{}:{}:{}:{}:{}:{}'.format( 232 latitude, longitude, speedThroughWater, speedOverGround, 233 courseOverGround, waterDepth, waterTemperature, gpsFix 234 ) 235 ) 163 236 164 237 # append to log 165 dataset = logdataset.LogDataset(None, gpsp.status(), latitude, gpsp.latitudeDirection(), 166 longitude, gpsp.longitudeDirection(), courseOverGround, speedOverGround, 167 waterDepth, waterTemperature) 168 if not log_handler.gnuboat_write(gpsFix, gpsp.timeUtc(), dataset, n2kd.waterDepthValid(), logverbose, logsystemtime): 238 dataset = logdataset.LogDataset( 239 None, gpsp.status(), 240 latitude, gpsp.latitudeDirection(), longitude, 241 gpsp.longitudeDirection(), courseOverGround, speedOverGround, 242 waterDepth, waterTemperature 243 ) 244 if not log_handler.gnuboat_write( 245 gpsFix, gpsp.timeUtc(), dataset, n2kd.waterDepthValid(), 246 logverbose, logsystemtime 247 ): 169 248 sys.exit(2) 170 249 171 250 # display data 172 251 displayHandler.setValues( 173 speedThroughWater, speedOverGround, courseOverGround, waterDepth, waterTemperature, gpsFix) 252 speedThroughWater, speedOverGround, courseOverGround, 253 waterDepth, waterTemperature, gpsFix 254 ) 174 255 175 256 # check for shutdown request … … 190 271 displayHandler.join() 191 272 273 192 274 if __name__ == "__main__": 193 275 main(sys.argv[1:]) -
src/gnuboat/device/bin/gnuboat-data-generator
r77cd9cf r43fd35c 2 2 # -*- coding: utf-8 -*- 3 3 ''' 4 Copyright (C) 2017 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.4 Copyright (C) 2017 EngSaS - Langenbach. All rights reserved. 5 5 6 6 This program is free software: you can redistribute it and/or modify … … 25 25 import os 26 26 27 from gnuboat import daemon27 from gnuboat.device.daemon import rrdhandler as rrdhandler 28 28 29 29 # default values for command line arguments … … 37 37 longitude_max = 180 38 38 39 39 40 def main(argv): 40 41 global rrdfile … … 46 47 global logperiod 47 48 48 parser = argparse.ArgumentParser(description='Generates test data for gnuboat webservice and fills the rrd database') 49 parser.add_argument('-f', '--file', dest='rrd_database', metavar='rrd_database', type=str, 50 help='File path of the rrd database to fill', default="/var/lib/gnuboat/gnuboat.rrd") 51 parser.add_argument('-lat-min', '--latitude-min', dest='lat_min', metavar='lat_min', type=float, 52 help='Minimum latitude generated', default=latitude_min) 53 parser.add_argument('-lat-max', '--latitude-max', dest='lat_max', metavar='lat_max', type=float, 54 help='Maximum latitude generated', default=latitude_max) 55 parser.add_argument('-lon-min', '--longitude-min', dest='lon_min', metavar='lon_min', type=float, 56 help='Minimum longitude generated', default=longitude_min) 57 parser.add_argument('-lon-max', '--longitude-max', dest='lon_max', metavar='lon_max', type=float, 58 help='Maximum longitude generated', default=longitude_max) 59 parser.add_argument('-l', '--logperiod', dest='logperiod', metavar='logperiod', type=int, 60 help='Period of data generation (seconds between two values)', default=logperiod) 49 parser = argparse.ArgumentParser( 50 description= 51 'Generates test data for gnuboat webservice and fills the rrd database' 52 ) 53 parser.add_argument( 54 '-f', 55 '--file', 56 dest='rrd_database', 57 metavar='rrd_database', 58 type=str, 59 help='File path of the rrd database to fill', 60 default="/var/lib/gnuboat/gnuboat.rrd" 61 ) 62 parser.add_argument( 63 '-lat-min', 64 '--latitude-min', 65 dest='lat_min', 66 metavar='lat_min', 67 type=float, 68 help='Minimum latitude generated', 69 default=latitude_min 70 ) 71 parser.add_argument( 72 '-lat-max', 73 '--latitude-max', 74 dest='lat_max', 75 metavar='lat_max', 76 type=float, 77 help='Maximum latitude generated', 78 default=latitude_max 79 ) 80 parser.add_argument( 81 '-lon-min', 82 '--longitude-min', 83 dest='lon_min', 84 metavar='lon_min', 85 type=float, 86 help='Minimum longitude generated', 87 default=longitude_min 88 ) 89 parser.add_argument( 90 '-lon-max', 91 '--longitude-max', 92 dest='lon_max', 93 metavar='lon_max', 94 type=float, 95 help='Maximum longitude generated', 96 default=longitude_max 97 ) 98 parser.add_argument( 99 '-l', 100 '--logperiod', 101 dest='logperiod', 102 metavar='logperiod', 103 type=int, 104 help='Period of data generation (seconds between two values)', 105 default=logperiod 106 ) 61 107 arguments = parser.parse_args(argv) 62 108 63 109 if arguments.rrd_database is not None: 64 110 rrdfile = arguments.rrd_database … … 78 124 79 125 if not os.path.exists(os.path.dirname(rrdfile)): 80 print('rrd database directory not found {}'.format(os.path.dirname(rrdfile))) 126 print( 127 'rrd database directory not found {}'.format( 128 os.path.dirname(rrdfile) 129 ) 130 ) 81 131 parser.print_help() 82 132 sys.exit(2) … … 84 134 timestamp = int(time.time()) 85 135 start_time = timestamp - duration - logperiod 86 136 87 137 if os.path.isfile(rrdfile): 88 138 print('Removing old database {}'.format(rrdfile)) … … 90 140 91 141 print('Creating {}'.format(rrdfile)) 92 daemon.rrd_create_database(rrdfile, logperiod, str(start_time)) 93 94 print('Filling database inside [{}, {}] --> [{}, {}]...'.format(latitude_min, longitude_min, latitude_max, longitude_max)) 142 rrdhandler.rrd_create_database(rrdfile, logperiod, str(start_time)) 143 144 print( 145 'Filling database inside [{}, {}] --> [{}, {}]...'.format( 146 latitude_min, longitude_min, latitude_max, longitude_max 147 ) 148 ) 95 149 for current_time in xrange(timestamp - duration, timestamp, logperiod): 96 150 latitude = random.uniform(latitude_min, latitude_max) … … 103 157 gpsFix = 3 104 158 # update rrd database for the webservice 105 daemon.rrd_update(rrdfile, '{}:{}:{}:{}:{}:{}:{}:{}:{}'.format( 106 current_time, latitude, longitude, speedThroughWater, speedOverGround, courseOverGround, waterDepth, waterTemperature, gpsFix)) 159 rrdhandler.rrd_update( 160 rrdfile, '{}:{}:{}:{}:{}:{}:{}:{}:{}'.format( 161 current_time, latitude, longitude, speedThroughWater, 162 speedOverGround, courseOverGround, waterDepth, 163 waterTemperature, gpsFix 164 ) 165 ) 166 107 167 108 168 if __name__ == "__main__": -
src/gnuboat/device/bin/gnuboat-splashscreen
r77cd9cf r43fd35c 1 1 #!/usr/bin/python 2 2 ''' 3 Copyright (C) 2016 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2016 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 77 77 displayImage(epd, image) 78 78 79 79 80 if __name__ == "__main__": 80 81 main(sys.argv[1:]) -
src/gnuboat/device/daemon/displayhandler.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2016 - 2017 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 29 29 epdEnabled = False 30 30 31 """@class DisplayHandler32 """33 34 31 35 32 class DisplayHandler(threading.Thread): 36 37 33 def __init__(self, displayperiod): 38 34 threading.Thread.__init__(self) … … 70 66 self._gpsFix = fix 71 67 72 def setValues(self, speedThroughWater, speedOverGround, courseOverGround, waterDepth, waterTemperature, gpsFix): 68 def setValues( 69 self, speedThroughWater, speedOverGround, courseOverGround, waterDepth, 70 waterTemperature, gpsFix 71 ): 73 72 self.setSpeedThroughWater(speedThroughWater) 74 73 self.setSpeedOverGround(speedOverGround) … … 86 85 try: 87 86 while self._running: 88 self.displayValues(self._epd, self._speedThroughWater, self._speedOverGround, self._courseOverGround, 89 self._waterDepth, self._waterTemperature, self._gpsFix) 87 self.displayValues( 88 self._epd, self._speedThroughWater, self._speedOverGround, 89 self._courseOverGround, self._waterDepth, 90 self._waterTemperature, self._gpsFix 91 ) 90 92 time.sleep(self._updatePeriod) 91 93 except StopIteration: 92 94 pass 93 95 94 def displayValues(self, epd, speedThroughWater, speedOverGround, courseOverGround, waterDepth, waterTemperature, gpsFix): 96 def displayValues( 97 self, epd, speedThroughWater, speedOverGround, courseOverGround, 98 waterDepth, waterTemperature, gpsFix 99 ): 95 100 if not epdEnabled: 96 101 return … … 98 103 # requires dejavu package!!!! 99 104 fontValues = ImageFont.truetype( 100 '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 34) 105 '/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf', 34 106 ) 101 107 fontTitles = ImageFont.truetype( 102 '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 24) 108 '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 24 109 ) 103 110 104 111 # initially set all white background … … 108 115 rowHeightTitles = 25 109 116 rowHeightValues = float( 110 height - 2 * rowHeightTitles - 3 * marginVertical) / 2.0 117 height - 2 * rowHeightTitles - 3 * marginVertical 118 ) / 2.0 111 119 columnWidthUnit = 30 112 120 columnWidthValues = int( 113 float(width - 3 * marginHorizontal - 2 * columnWidthUnit) / 2.0) 121 float(width - 3 * marginHorizontal - 2 * columnWidthUnit) / 2.0 122 ) 114 123 115 124 draw = ImageDraw.Draw(image) … … 120 129 draw.text((x, y), "STW", fill=BLACK, font=fontTitles) 121 130 if speedThroughWater is not None: 122 draw.text( 123 (x, y + rowHeightTitles), str(speedThroughWater), fill=BLACK, font=fontValues) 131 draw.text((x, y + rowHeightTitles), 132 str(speedThroughWater), 133 fill=BLACK, 134 font=fontValues) 124 135 draw.text((x + columnWidthValues, y + rowHeightTitles * 1.4), 125 "kts", fill=BLACK, font=fontTitles) 136 "kts", 137 fill=BLACK, 138 font=fontTitles) 126 139 127 140 x = x + marginHorizontal + columnWidthValues + columnWidthUnit 128 141 draw.text((x, y), "SOG", fill=BLACK, font=fontTitles) 129 142 if speedOverGround is not None: 130 draw.text((x, y + rowHeightTitles), str(speedOverGround), 131 fill=BLACK, font=fontValues) 143 draw.text((x, y + rowHeightTitles), 144 str(speedOverGround), 145 fill=BLACK, 146 font=fontValues) 132 147 draw.text((x + columnWidthValues, y + rowHeightTitles * 1.4), 133 "kts", fill=BLACK, font=fontTitles) 148 "kts", 149 fill=BLACK, 150 font=fontTitles) 134 151 135 152 x = marginHorizontal … … 137 154 draw.text((x, y), "Depth", fill=BLACK, font=fontTitles) 138 155 if waterDepth is not None: 139 draw.text( 140 (x, y + rowHeightTitles), str(waterDepth), fill=BLACK, font=fontValues) 141 draw.text((x + int(float(columnWidthValues) / 1.5), 142 y + rowHeightTitles * 1.4), "m", fill=BLACK, font=fontTitles) 156 draw.text((x, y + rowHeightTitles), 157 str(waterDepth), 158 fill=BLACK, 159 font=fontValues) 160 draw.text(( 161 x + int(float(columnWidthValues) / 1.5), y + rowHeightTitles * 1.4 162 ), 163 "m", 164 fill=BLACK, 165 font=fontTitles) 143 166 144 167 x = x + marginHorizontal + columnWidthValues + columnWidthUnit 145 168 draw.text((x, y), "Water", fill=BLACK, font=fontTitles) 146 169 if waterTemperature is not None: 147 draw.text( 148 (x, y + rowHeightTitles), str(waterTemperature), fill=BLACK, font=fontValues) 149 draw.text((x + int(float(columnWidthValues) / 1.5), 150 y + rowHeightTitles * 1.4), "C", fill=BLACK, font=fontTitles) 170 draw.text((x, y + rowHeightTitles), 171 str(waterTemperature), 172 fill=BLACK, 173 font=fontValues) 174 draw.text(( 175 x + int(float(columnWidthValues) / 1.5), y + rowHeightTitles * 1.4 176 ), 177 "C", 178 fill=BLACK, 179 font=fontTitles) 151 180 152 181 x = int((x + marginHorizontal + columnWidthValues) * 0.93) 153 182 draw.text((x, y), "Fix", fill=BLACK, font=fontTitles) 154 183 if gpsFix is not None: 155 draw.text( 156 (x, y + rowHeightTitles), str(gpsFix), fill=BLACK, font=fontValues) 184 draw.text((x, y + rowHeightTitles), 185 str(gpsFix), 186 fill=BLACK, 187 font=fontValues) 157 188 158 189 epd.display(image) 159 190 epd.update() 160 191 192 161 193 if __name__ == "__main__": 162 194 import sys -
src/gnuboat/device/daemon/gpsdpoller.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2016 - 2017 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 28 28 29 29 class GpsdPoller(threading.Thread): 30 31 30 def __init__(self, logperiod): 32 31 threading.Thread.__init__(self) … … 38 37 39 38 def latitude(self): 40 if self._currentValue is None or self.gpsFix() < 2 or 'lat' not in self._currentValue: 39 if self._currentValue is None or self.gpsFix( 40 ) < 2 or 'lat' not in self._currentValue: 41 41 return 0 42 42 return self._currentValue.lat … … 46 46 47 47 def longitude(self): 48 if self._currentValue is None or self.gpsFix() < 2 or 'lon' not in self._currentValue: 48 if self._currentValue is None or self.gpsFix( 49 ) < 2 or 'lon' not in self._currentValue: 49 50 return 0 50 51 return self._currentValue.lon … … 54 55 55 56 def speedOverGround(self): 56 if self._currentValue is None or self.gpsFix() < 2 or 'speed' not in self._currentValue: 57 if self._currentValue is None or self.gpsFix( 58 ) < 2 or 'speed' not in self._currentValue: 57 59 return 0 58 60 return self._currentValue.speed 59 61 60 62 def courseOverGround(self): 61 if self._currentValue is None or self.gpsFix() < 2 or 'track' not in self._currentValue: 63 if self._currentValue is None or self.gpsFix( 64 ) < 2 or 'track' not in self._currentValue: 62 65 return 0 63 66 return self._currentValue.track … … 74 77 75 78 def timeUtc(self): 76 if self._currentValue is None or self.gpsFix() < 2 or 'time' not in self._currentValue: 79 if self._currentValue is None or self.gpsFix( 80 ) < 2 or 'time' not in self._currentValue: 77 81 return None 78 82 currentTime = self._currentValue.time … … 105 109 pass 106 110 111 107 112 if __name__ == "__main__": 108 113 import sys -
src/gnuboat/device/daemon/n2kdpoller.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2016 - 2017 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2016 - 2017 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 23 23 import traceback 24 24 25 """@class N2kdPoller26 """27 28 25 29 26 class N2kdPoller(threading.Thread): 30 27 """ 28 N2kdPoller 29 """ 31 30 def __init__(self, logperiod): 32 31 threading.Thread.__init__(self) … … 69 68 except socket.error as error: 70 69 if not self._connectErrorPrinted: 71 print('Failed to connect to n2kd server at {}:{}: {}'.format(self._serverHost, self._serverPort, error)) 70 print( 71 'Failed to connect to n2kd server at {}:{}: {}'.format( 72 self._serverHost, self._serverPort, error 73 ) 74 ) 72 75 self._connectErrorPrinted = True 73 76 self._waterDepthValid = False 74 77 return 75 78 if self._connectErrorPrinted: 76 print('Connected to n2kd server at {}:{}'.format(self._serverHost, self._serverPort)) 79 print( 80 'Connected to n2kd server at {}:{}'.format( 81 self._serverHost, self._serverPort 82 ) 83 ) 77 84 self._connectErrorPrinted = False 78 85 … … 95 102 96 103 descriptions = [ 97 "Water Depth", "Speed", "Environmental Parameters", "Distance Log"] 104 "Water Depth", "Speed", "Environmental Parameters", "Distance Log" 105 ] 98 106 99 107 for key in data: … … 106 114 lineKeys = data[key][entryKey].keys() 107 115 if "fields" not in lineKeys: 108 print('No fields entry. Malformed json n2kd response in {}'.format(data[key][entryKey])) 116 print( 117 ('No fields entry. Malformed json n2kd response ' 118 'in {}').format(data[key][entryKey]) 119 ) 109 120 else: 110 121 fields = data[key][entryKey]["fields"] 111 122 # try water depth (NEED TO APPLY OFFSET?) 112 123 if "Depth" in fields: 113 if data[key][entryKey]["description"] == "Water Depth": 124 if data[key][entryKey]["description" 125 ] == "Water Depth": 114 126 self._waterDepth = fields["Depth"] 115 127 self._waterDepthValid = True 116 128 # try speed 117 129 if "Speed Water Referenced" in fields: 118 self._speedThroughWater = fields["Speed Water Referenced"] 130 self._speedThroughWater = fields[ 131 "Speed Water Referenced"] 119 132 # try sea temperature 120 if "Temperature Source" in fields and "Temperature" in fields: 121 if fields["Temperature Source"] == "Sea Temperature": 133 if ("Temperature Source" in fields and 134 "Temperature" in fields): 135 if fields["Temperature Source" 136 ] == "Sea Temperature": 122 137 self._waterTemperature = fields["Temperature"] 123 138 # try log … … 141 156 pass 142 157 158 143 159 if __name__ == "__main__": 144 160 import sys -
src/gnuboat/mapservice.yaml
r77cd9cf r43fd35c 748 748 type: http 749 749 scheme: basic 750 x-basicInfoFunc: gnuboat _mapservice.server_impl.security.Security.auth_basic750 x-basicInfoFunc: gnuboat.mapservice_impl.security.Security.auth_basic 751 751 apiKeyAuth: 752 752 type: apiKey 753 753 in: header 754 754 name: X-API-KEY 755 x-apikeyInfoFunc: gnuboat _mapservice.server_impl.security.Security.auth_api755 x-apikeyInfoFunc: gnuboat.mapservice_impl.security.Security.auth_api 756 756 schemas: 757 757 username: -
src/gnuboat/mapservice_impl/CeleryWorker.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 19 19 from sqlalchemy import event 20 20 21 from . import config_object, app, application, celery, setup_app 22 from .database.Model import db 23 from .tasks import tasks 21 from gnuboat.mapservice_impl import ( 22 config_object, app, application, celery, setup_app 23 ) 24 from gnuboat.mapservice_impl.database.Model import db 25 from gnuboat.mapservice_impl.tasks import tasks 24 26 25 27 … … 38 40 def load_spatialite(dbapi_conn, connection_record): 39 41 if 'sqlite' in flask.current_app.config[ 40 'SQLALCHEMY_DATABASE_URI']: 41 # From https://geoalchemy-2.readthedocs.io/en/latest/spatialite_tutorial.html 42 'SQLALCHEMY_DATABASE_URI']: 43 # From https://geoalchemy-2.readthedocs.io/en/ 44 # latest/spatialite_tutorial.html 42 45 dbapi_conn.enable_load_extension(True) 43 46 dbapi_conn.load_extension( … … 50 53 51 54 with flask_app.app_context(): 52 if not 'TILES_LITTLE_ZOOM_SCHEDULE'in flask.current_app.config:55 if 'TILES_LITTLE_ZOOM_SCHEDULE' not in flask.current_app.config: 53 56 flask.current_app.logger.error( 54 57 'TILES_LITTLE_ZOOM_SCHEDULE not configured' … … 61 64 'add-log_little_zoom_slice': { 62 65 'task': 63 'gnuboat_mapservice.server_impl.tasks.tasks.log_little_zoom_slice', 66 ('gnuboat.mapservice_impl.tasks.' 67 'tasks.log_little_zoom_slice'), 64 68 'schedule': 65 69 tiles_little_zoom_schedule -
src/gnuboat/mapservice_impl/Config.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 42 42 MAPSERVICE_WEBCLIENT = '/' 43 43 CELERY_BROKER_URL = 'pyamqp://guest@localhost//' 44 CELERY_IMPORTS = ("gnuboat _mapservice.server_impl.tasks")44 CELERY_IMPORTS = ("gnuboat.mapservice_impl.tasks") 45 45 CELERY_RESULT_BACKEND = "cache" 46 46 CELERY_CACHE_BACKEND = 'memcached://127.0.0.1:11211' … … 50 50 TILES_DENSITIES = [10, 100] 51 51 TILES_DENSITY_BASEE = 100 52 # How many years are data points allowed to be old, before they are excluded from calculations 52 # How many years are data points allowed to be old, 53 # before they are excluded from calculations 53 54 TILES_POINT_AGE_MAX = 10 54 # log_process generates tiles for this zoom range. all lower zoomlevels (0 - x) are generated by a periodic task (s. TILES_LITTLE_ZOOM_SCHEDULE option). 55 # Those zoomlevels are not rendered by log_process(), because they contain few details, but large areas 55 # log_process generates tiles for this zoom range. all lower 56 # zoomlevels (0 - x) are generated by a periodic task 57 # (s. TILES_LITTLE_ZOOM_SCHEDULE option). 58 # Those zoomlevels are not rendered by log_process(), 59 # because they contain few details, but large areas 56 60 TILES_ZOOM_RANGE = {'minimum': 10, 'maximum': 19} 57 # schedule, when to run the job to generate tiles for low zoomlevels (0 - TILES_ZOOM_RANGE['minimum']), 58 # As format see https://docs.celeryproject.org/en/stable/userguide/periodic-tasks.html#crontab-schedules 59 # If TILES_ZOOM_RANGE['minimum'] = 10 it might need up to 4097 slice jobs per tile_size and density 61 # schedule, when to run the job to generate tiles for low 62 # zoomlevels (0 - TILES_ZOOM_RANGE['minimum']), 63 # As format see https://docs.celeryproject.org/en/ 64 # stable/userguide/periodic-tasks.html#crontab-schedules 65 # If TILES_ZOOM_RANGE['minimum'] = 10 it might need up to 66 # 4097 slice jobs per tile_size and density 60 67 TILES_LITTLE_ZOOM_SCHEDULE = crontab( 61 68 0, 0, day_of_month='2' … … 67 74 68 75 class ProductionConfig(Config): 69 SQLALCHEMY_DATABASE_URI = 'mysql+mysqldb://gnuboat:gnuboat@localhost/gnuboat_mapservice' 70 # TEMPLATE_FOLDER could be used to use own templates residing in TEMPLATE_FOLDER 76 SQLALCHEMY_DATABASE_URI = ('mysql+mysqldb://gnuboat:gnuboat@localhost/' 77 'gnuboat_mapservice') 78 # TEMPLATE_FOLDER could be used to use own templates residing in 79 # TEMPLATE_FOLDER 71 80 TEMPLATE_FOLDER = '/usr/share/gnuboat/templates' 72 81 … … 77 86 SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/test.db' 78 87 MAPSERVICE_WEBCLIENT = 'http://localhost:8081' 79 # SERVER_NAME = 'gnuboat-mapservice:8080'88 # SERVER_NAME = 'gnuboat-mapservice:8080' 80 89 HOST = 'localhost' 81 90 SERVER_NAME = 'localhost:8080' … … 86 95 class TestingConfig(DevelopmentConfig): 87 96 """ 88 Configuration for testing purposes only (like tox/nosetests)89 """97 Configuration for testing purposes only (like tox/nosetests) 98 """ 90 99 TESTING = True 91 100 DEBUG = False -
src/gnuboat/mapservice_impl/HttpErrors.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 16 16 ''' 17 17 18 from werkzeug.exceptions import BadRequest, Unauthorized, NotFound, InternalServerError 18 from werkzeug.exceptions import ( 19 BadRequest, Unauthorized, NotFound, InternalServerError 20 ) 19 21 from connexion.exceptions import ProblemException 20 22 -
src/gnuboat/mapservice_impl/ValidatorWorkaround.py
r77cd9cf r43fd35c 13 13 from connexion.decorators.response import ResponseValidator 14 14 from connexion import problem 15 from connexion.exceptions import NonConformingResponseBody, NonConformingResponseHeaders 15 from connexion.exceptions import ( 16 NonConformingResponseBody, NonConformingResponseHeaders 17 ) 16 18 from connexion.utils import has_coroutine 17 19 … … 30 32 def __call__(self, function): 31 33 """ 32 :type function: types.FunctionType33 :rtype: types.FunctionType34 """34 :type function: types.FunctionType 35 :rtype: types.FunctionType 36 """ 35 37 def _wrapper(request, response): 36 38 connexion_response = \ -
src/gnuboat/mapservice_impl/__init__.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 25 25 import os 26 26 27 from .. import encoder 28 from .database.Model import db, User, ApiKey, db_setup, load_spatialite 29 from .ValidatorWorkaround import ValidatorWorkaround 27 from gnuboat.mapservice import encoder 28 from gnuboat.mapservice_impl.database.Model import ( 29 db, User, ApiKey, 30 db_setup, load_spatialite 31 ) 32 from gnuboat.mapservice_impl.ValidatorWorkaround import ValidatorWorkaround 30 33 31 34 32 35 def load_config_object(config_name): 33 36 return import_string( 34 'gnuboat _mapservice.server_impl.Config.{}Config'.format(config_name)37 'gnuboat.mapservice_impl.Config.{}Config'.format(config_name) 35 38 ) 36 39 … … 59 62 load_spatialite(dbapi_conn, connection_record) 60 63 61 if flask.current_app.config['CREATE_TEST_DATABASE'] ==True:64 if flask.current_app.config['CREATE_TEST_DATABASE'] is True: 62 65 from .demo import DbSetup as demoDbSetup 63 66 demoDbSetup.setup() -
src/gnuboat/mapservice_impl/controllers/DevicesController.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 17 17 import connexion 18 18 19 from ..database.Model import User, Device, db 20 from ..HttpErrors import MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound 19 from gnuboat.mapservice_impl.database.Model import User, Device, db 20 from gnuboat.mapservice_impl.HttpErrors import ( 21 MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound 22 ) 21 23 22 24 -
src/gnuboat/mapservice_impl/controllers/LogsController.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 17 17 import connexion 18 18 19 from ..database.Model import User, Log, LogEntry, Water, Device, Gauge, ProcessingStatus, Queue, db 20 from ..HttpErrors import MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound 21 from ..tasks.tasks import log_process 19 from gnuboat.mapservice_impl.database.Model import ( 20 User, Log, LogEntry, 21 Water, Device, Gauge, ProcessingStatus, Queue, db 22 ) 23 from gnuboat.mapservice_impl.HttpErrors import ( 24 MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound 25 ) 26 from gnuboat.mapservice_impl.tasks.tasks import log_process 22 27 23 28 -
src/gnuboat/mapservice_impl/controllers/TilesController.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 20 20 import os 21 21 22 from ..HttpErrors import MapserviceInternalServerError, MapserviceBadRequest, MapserviceNotFound 22 from gnuboat.mapservice_impl.HttpErrors import ( 23 MapserviceInternalServerError, MapserviceBadRequest, MapserviceNotFound 24 ) 23 25 24 26 25 27 def tiles_tile_get(accuracy, resolution, zoom, x_tile, y_tile): 26 if not 'TILES_CACHE_PATH'in flask.current_app.config or not os.access(28 if 'TILES_CACHE_PATH' not in flask.current_app.config or not os.access( 27 29 flask.current_app.config['TILES_CACHE_PATH'], os.R_OK 28 30 ): … … 32 34 tiles_cache_path = flask.current_app.config['TILES_CACHE_PATH'] 33 35 34 if not 'TILES_DENSITIES'in flask.current_app.config:36 if 'TILES_DENSITIES' not in flask.current_app.config: 35 37 raise MapserviceInternalServerError( 36 38 details='TILES_DENSITIES not configured' … … 38 40 tiles_densities = flask.current_app.config['TILES_DENSITIES'] 39 41 40 if not 'TILES_DENSITY_BASEE'in flask.current_app.config:42 if 'TILES_DENSITY_BASEE' not in flask.current_app.config: 41 43 raise MapserviceInternalServerError( 42 44 details='TILES_DENSITY_BASEE not configured' … … 44 46 tiles_densitiy_base = flask.current_app.config['TILES_DENSITY_BASEE'] 45 47 46 if not 'TILES_SKIP_EMPTY'in flask.current_app.config:48 if 'TILES_SKIP_EMPTY' not in flask.current_app.config: 47 49 raise MapserviceInternalServerError( 48 50 details='TILES_SKIP_EMPTY not configured' … … 56 58 else: 57 59 raise MapserviceBadRequest( 58 details= 59 'No valid accuracy requested. Valid are high, low. Requested was: {}'60 details=('No valid accuracy requested. ' 61 'Valid are high, low. Requested was: {}') 60 62 .format(accuracy) 61 63 ) … … 72 74 if not tiles_skip_empty or not os.path.isfile(tile__empty_path): 73 75 raise MapserviceNotFound( 74 detail= 75 'Tile ({}, {}) for accuracy {} with resolution {} at zoomlevel {} not found'76 detail=('Tile ({}, {}) for accuracy {} with resolution {} ' 77 'at zoomlevel {} not found') 76 78 .format(x_tile, y_tile, accuracy, resolution, zoom) 77 79 ) … … 85 87 ) 86 88 response.direct_passthrough = False 87 #response.headers['Content-Transfer-Encoding']='base64'88 89 return response -
src/gnuboat/mapservice_impl/controllers/UsersController.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 24 24 from flask_mail import Message 25 25 26 from .. import mail 27 from ..database.Model import User, ApiKey, db 28 from ..HttpErrors import MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound 26 from gnuboat.mapservice_impl import mail 27 from gnuboat.mapservice_impl.database.Model import User, ApiKey, db 28 from gnuboat.mapservice_impl.HttpErrors import ( 29 MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound 30 ) 29 31 30 mail_regex = re.compile('[^@]+@[^@]+\ .[^@]+')32 mail_regex = re.compile('[^@]+@[^@]+\\.[^@]+') 31 33 32 34 … … 107 109 detail='Email contains more than one @, no @ or no .' 108 110 ) 109 if user_creation.license_accepted is None or not user_creation.license_accepted: 111 if (user_creation.license_accepted is None or 112 not user_creation.license_accepted): 110 113 raise MapserviceBadRequest( 111 114 detail='You must accept the license to register an account' … … 128 131 129 132 message = Message("Activate your GNUBoat account", recipients=[user.email]) 130 message.body = 'Hello {},\nthank you for support the project with your own measurings. To activate your GNUBoat account, visit {}.\nKind regards,\nYour GNUBoat team'.format( 131 user.first_name, activation_url 133 message.body = ('Hello {},\nthank you for support the project with your ' 134 'own measurings. To activate your GNUBoat account, ' 135 'visit {}.\nKind regards,\nYour GNUBoat team').format( 136 user.first_name, activation_url 132 137 ) 133 138 message.html = render_template( -
src/gnuboat/mapservice_impl/controllers/WatersController.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 17 17 import connexion 18 18 19 from ..database.Model import User, Water, Gauge, Log, db 20 from ..HttpErrors import MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound 19 from gnuboat.mapservice_impl.database.Model import User, Water, Gauge, Log, db 20 from gnuboat.mapservice_impl.HttpErrors import ( 21 MapserviceBadRequest, 22 MapserviceUnauthorized, MapserviceNotFound 23 ) 21 24 22 25 -
src/gnuboat/mapservice_impl/database/Model.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 56 56 activated = db.Column(db.Boolean(), default=False) 57 57 activation_code = db.Column(db.String(255), default='1234') 58 #activation_code = db.Column(db.String(255), server_default=text('LEFT(MD5(NOW()), 50)')) 58 # activation_code = db.Column(db.String(255), 59 # server_default=text('LEFT(MD5(NOW()), 50)')) 59 60 license_accepted = db.Column(db.Boolean(), default=False) 60 61 … … 107 108 @staticmethod 108 109 def loggedin_username(): 109 if not 'user'in connexion.context:110 if 'user' not in connexion.context: 110 111 return None 111 112 return connexion.context['user'] … … 174 175 reference_water_level_gauge_height = db.Column(db.Float, nullable=False) 175 176 comment = db.Column(db.String(255)) 176 # osm_id = db.Column(db.Integer)177 # osm_type = db.Column(db.String(255))178 # osm_class = db.Column(db.String(255))177 # osm_id = db.Column(db.Integer) 178 # osm_type = db.Column(db.String(255)) 179 # osm_class = db.Column(db.String(255)) 179 180 manager = db.relationship("User", backref=db.backref("gauges"), lazy=True) 180 181 water = db.relationship("Water", backref=db.backref("gauges"), lazy=True) … … 430 431 if 'sqlite' in flask.current_app.config['SQLALCHEMY_DATABASE_URI']: 431 432 result = db.engine.execute( 432 'SELECT count(name) FROM sqlite_master WHERE type="table" AND name="spatial_ref_sys"' 433 ('SELECT count(name) FROM sqlite_master ' 434 'WHERE type="table" AND name="spatial_ref_sys"') 433 435 ) 434 436 if result.fetchone()[0] == 1: … … 443 445 444 446 def load_spatialite(dbapi_conn, connection_record): 445 if not 'sqlite'in flask.current_app.config['SQLALCHEMY_DATABASE_URI']:447 if 'sqlite' not in flask.current_app.config['SQLALCHEMY_DATABASE_URI']: 446 448 return 447 449 … … 462 464 if os.path.exists(path): 463 465 if flask.current_app.config['DEBUG'] and ( 464 not 'TESTING' in flask.current_app.config465 ornot flask.current_app.config['TESTING']466 'TESTING' not in flask.current_app.config or 467 not flask.current_app.config['TESTING'] 466 468 ): 467 469 print('Enabling spatial lite extension. This may take a while') 468 # From https://geoalchemy-2.readthedocs.io/en/latest/spatialite_tutorial.html 470 # From https://geoalchemy-2.readthedocs.io/en/latest/ 471 # spatialite_tutorial.html 469 472 dbapi_conn.enable_load_extension(True) 470 473 dbapi_conn.load_extension(str(path.resolve())) -
src/gnuboat/mapservice_impl/demo/DbSetup.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 20 20 import flask 21 21 22 from ..database.Model import db, User, ApiKey, Water, OsmType, Gauge, Device, Log, Queue, ProcessingStatus, db_setup 23 from ..tasks.tasks import log_process 22 from gnuboat.mapservice_impl.database.Model import ( 23 db, User, ApiKey, Water, 24 OsmType, Gauge, Device, Log, Queue, ProcessingStatus, db_setup 25 ) 26 from gnuboat.mapservice_impl.tasks.tasks import log_process 24 27 25 28 … … 127 130 location='SRID=4326;POINT(10.0427 48.4275)', 128 131 reference_water_level_gauge_height=0.4, 129 comment= 130 'Level zero is the level of the step where the handrail is fixed.'132 comment=('Level zero is the level of the step ' 133 'where the handrail is fixed.') 131 134 ) 132 135 db.session.add(pfuhlersee_gauge) … … 184 187 db.session.commit() 185 188 186 if not 'CELERY_BROKER_URL' in flask.current_app.config or not flask.current_app.config[ 187 'CELERY_BROKER_URL']: 189 if ('CELERY_BROKER_URL' not in flask.current_app.config or 190 not flask.current_app.config[ 191 'CELERY_BROKER_URL']): 188 192 print('Do not add log, since their is no CELERY_BROKER_URL configured') 189 193 return log -
src/gnuboat/mapservice_impl/security/Security.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify -
src/gnuboat/mapservice_impl/tasks/__init__.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify -
src/gnuboat/mapservice_impl/tasks/tasks.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 34 34 import mercantile 35 35 36 from gnuboat_common.datahandler import loghandler 37 from gnuboat_common.spatial import tilegenerator 38 from gnuboat_common.spatial.tilegenerator import RasterSlice, LngLatBbox, ZoomRange 39 40 from .. import mail, celery as celery_app 41 from ..database.Model import User, Log, LogEntry, Water, ProcessingStatus, Queue, db 42 from .tileconfig import TileConfig 36 from gnuboat.common.datahandler import loghandler 37 from gnuboat.common.spatial import tilegenerator 38 from gnuboat.common.spatial.tilegenerator import ( 39 RasterSlice, LngLatBbox, ZoomRange 40 ) 41 42 from gnuboat.mapservice_impl import mail, celery as celery_app 43 from gnuboat.mapservice_impl.database.Model import ( 44 User, Log, LogEntry, Water, ProcessingStatus, Queue, db 45 ) 46 from gnuboat.mapservice_impl.tasks.tileconfig import TileConfig 43 47 44 48 … … 84 88 class SliceJob(dict): 85 89 """ 86 Summarize all data needed to generate the tiles for a slice 87 and also to cleanup the whole generation chain afterwards 88 89 tile_slice: The slice, which should be rastered 90 query: query used in the vrt source file 91 log_id: Id of the log, initiating the job (before slicing) 92 envelope: Enlarged envelope of the complete job (TileGenerator.LngLatBbox) 93 94 It's derived from dict to be json serialisable 95 """ 90 Summarize all data needed to generate the tiles for a slice 91 and also to cleanup the whole generation chain afterwards 92 93 tile_slice: The slice, which should be rastered 94 query: query used in the vrt source file 95 log_id: Id of the log, initiating the job (before slicing) 96 envelope: Enlarged envelope of the complete job 97 (TileGenerator.LngLatBbox) 98 99 It's derived from dict to be json serialisable 100 """ 96 101 def __init__(self, tile_slice, query, log_id, envelope, epsg_code): 97 102 super(SliceJob, self).__init__({ … … 130 135 131 136 # query to get all logentries in the enlarged envelope, younger than age_date 132 query = """SELECT MakePointZ(ST_x(entries.location), ST_y(entries.location), (entries.water_depth + (logs.gauge_height - gauges.reference_water_level_gauge_height)), ST_srid(entries.location)) 137 query = """SELECT MakePointZ(ST_x(entries.location), ST_y(entries.location), 138 (entries.water_depth + 139 (logs.gauge_height - gauges.reference_water_level_gauge_height)), 140 ST_srid(entries.location)) 133 141 FROM logentries as entries, logs, gauges 134 142 WHERE entries.log_id=logs.id AND gauges.id=logs.gauge_id 135 AND ST_Within(entries.location, Envelope(MakeLine(PointFromText("POINT({longitude_west} {latitude_south})", {epsg_code}), PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code})))) 136 AND entries.datetime > \"{age_date}\"""" 143 AND ST_Within(entries.location, Envelope(MakeLine(PointFromText( 144 "POINT({longitude_west} {latitude_south})", {epsg_code}), 145 PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code})))) 146 AND entries.datetime > \"{age_date}\"""" 137 147 138 148 # query for retrieving processing state of affected logentries 139 149 query_select_processing_state = """SELECT COUNT(id) FROM logs 140 150 WHERE processing_state={processing_state} AND id IN ( 141 SELECT log_id FROM logentries WHERE 142 ST_Within(logentries.location, Envelope(MakeLine(PointFromText("POINT({longitude_west} {latitude_south})", {epsg_code}), PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code})))) 143 AND datetime {age_condition} \"{age_date}\" 144 GROUP BY log_id)""" 151 SELECT log_id FROM logentries WHERE 152 ST_Within(logentries.location, Envelope(MakeLine(PointFromText( 153 "POINT({longitude_west} {latitude_south})", {epsg_code}), 154 PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code})))) 155 AND datetime {age_condition} \"{age_date}\" 156 GROUP BY log_id)""" 145 157 146 158 # query for updateting processing state of all affected logentries 147 query_update_processing_state = """UPDATE logs SET processing_state={processing_state} 159 query_update_processing_state = """UPDATE logs SET 160 processing_state={processing_state} 148 161 WHERE id IN ( 149 SELECT log_id FROM logentries WHERE 150 ST_Within(logentries.location, Envelope(MakeLine(PointFromText("POINT({longitude_west} {latitude_south})", {epsg_code}), PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code})))) 151 AND datetime {age_condition} \"{age_date}\" 152 GROUP BY log_id)""" 162 SELECT log_id FROM logentries WHERE 163 ST_Within(logentries.location, Envelope(MakeLine(PointFromText( 164 "POINT({longitude_west} {latitude_south})", {epsg_code}), 165 PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code})))) 166 AND datetime {age_condition} \"{age_date}\" 167 GROUP BY log_id)""" 153 168 154 169 query_logs = """SELECT logentries.log_id, COUNT(logentries.id) as entries 155 170 FROM logentries 156 WHERE ST_Within(logentries.location, Envelope(MakeLine(PointFromText("POINT({longitude_west} {latitude_south})", {epsg_code}), PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code})))) 157 AND logentries.datetime > \"{age_date}\" GROUP BY log_id""" 171 WHERE ST_Within(logentries.location, Envelope(MakeLine(PointFromText( 172 "POINT({longitude_west} {latitude_south})", {epsg_code}), 173 PointFromText("POINT({longitude_east} {latitude_north})", {epsg_code})))) 174 AND logentries.datetime > \"{age_date}\" GROUP BY log_id""" 158 175 159 176 … … 161 178 def log_process(log_id, log_content): 162 179 """ 163 Chain for processing a new log164 1. Parse the log and add it to the datapase (s. log_parse)165 2. Generate tiles out of the new and old data (s. log_slice)166 """180 Chain for processing a new log 181 1. Parse the log and add it to the datapase (s. log_parse) 182 2. Generate tiles out of the new and old data (s. log_slice) 183 """ 167 184 chain = log_parse.s(log_id, log_content) | log_slice.s() 168 185 chain() … … 247 264 def log_slice(log_id): 248 265 """ 249 Background task to process new logs250 If another job is already processing the same logs, a LogsLocked Exception 251 is raised and an auto retry after 30 minutes is triggered.252 """266 Background task to process new logs 267 If another job is already processing the same logs, a LogsLocked 268 Exception is raised and an auto retry after 30 minutes is triggered. 269 """ 253 270 try: 254 271 tiles_config = _get_tile_config() … … 303 320 ) 304 321 305 # Check that none of the affected logs are currently processed by another job 322 # Check that none of the affected logs are currently processed by 323 # another job 306 324 result = db.engine.execute( 307 325 query_select_processing_state.format( … … 341 359 count_logentries += rows[1] 342 360 flask.current_app.logger.info( 343 'Processing log {}, found {} datasets from {} logs in enlarged envelope younger than {}' 361 ('Processing log {}, found {} datasets from {} logs in enlarged ' 362 'envelope younger than {}') 344 363 .format(log_id, count_logentries, logs, newer_than.isoformat('T')) 345 364 ) … … 388 407 except Exception as error: 389 408 flask.current_app.logger.error( 390 'Could not open the output file for the ogr data source description: {}'391 .format(error)409 ('Could not open the output file for the ogr data ' 410 'source description: {}').format(error) 392 411 ) 393 412 db.engine.execute( … … 461 480 except Exception as error: 462 481 flask.current_app.logger.error( 463 'Could not open the output file for the ogr data source description: {}'464 .format(error)482 ('Could not open the output file for the ogr data ' 483 'source description: {}').format(error) 465 484 ) 466 485 os.remove(datasource_file) … … 603 622 def log_little_zoom_slice(): 604 623 """ 605 Generate all little zoomlevels, which are not process per log with log_process 606 """ 624 Generate all little zoomlevels, which are not process per 625 log with log_process 626 """ 607 627 flask.current_app.logger.info('Recreating tiles for little zoomlevels') 608 628 try: … … 629 649 ) 630 650 631 ## query to get all logentries in the world, younger than age_date 632 query = """SELECT MakePointZ(ST_x(entries.location), ST_y(entries.location), (entries.water_depth + (logs.gauge_height - gauges.reference_water_level_gauge_height)), ST_srid(entries.location)) 651 # query to get all logentries in the world, younger than age_date 652 query = """SELECT MakePointZ(ST_x(entries.location), ST_y(entries.location), 653 (entries.water_depth + (logs.gauge_height - 654 gauges.reference_water_level_gauge_height)), ST_srid(entries.location)) 633 655 FROM logentries as entries, logs, gauges 634 WHERE entries.log_id=logs.id AND gauges.id=logs.gauge_id AND entries.datetime > \"{age_date}\"""".format( 656 WHERE entries.log_id=logs.id AND gauges.id=logs.gauge_id 657 AND entries.datetime > \"{age_date}\"""".format( 635 658 age_date=newer_than.isoformat('T') 636 659 ) … … 640 663 except Exception as error: 641 664 flask.current_app.logger.error( 642 'Could not open the output file for the ogr data source description: {}'643 .format(error)665 ('Could not open the output file for the ogr data ' 666 'source description: {}').format(error) 644 667 ) 645 668 os.remove(datasource_file) … … 675 698 ) 676 699 ) 677 # cleanup is not needed, because the processing state is not changed and also no mails are send 700 # cleanup is not needed, because the processing state 701 # is not changed and also no mails are send 678 702 celery.group((log_generate_tiles.s(slice_job) 679 703 for slice_job in slice_jobs)).delay() … … 745 769 746 770 def _get_database_uri(): 747 if not 'SQLALCHEMY_DATABASE_URI'in flask.current_app.config:771 if 'SQLALCHEMY_DATABASE_URI' not in flask.current_app.config: 748 772 raise ImportError('SQLALCHEMY_DATABASE_URI not configured') 749 773 return flask.current_app.config['SQLALCHEMY_DATABASE_URI'] … … 751 775 752 776 def _get_tile_config(): 753 if not 'TILES_CACHE_PATH'in flask.current_app.config:777 if 'TILES_CACHE_PATH' not in flask.current_app.config: 754 778 flask.current_app.logger.error('TILES_CACHE_PATH not configured') 755 779 raise ImportError('TILES_CACHE_PATH not configured') 756 780 757 if not 'TILES_SIZES'in flask.current_app.config:781 if 'TILES_SIZES' not in flask.current_app.config: 758 782 flask.current_app.logger.error('TILES_SIZES not configured') 759 783 raise ImportError('TILES_SIZES not configured') 760 784 761 if not 'TILES_DENSITIES'in flask.current_app.config:785 if 'TILES_DENSITIES' not in flask.current_app.config: 762 786 flask.current_app.logger.error('TILES_DENSITIES not configured') 763 787 raise ImportError('TILES_DENSITIES not configured') 764 788 765 if not 'TILES_DENSITY_BASEE'in flask.current_app.config:789 if 'TILES_DENSITY_BASEE' not in flask.current_app.config: 766 790 flask.current_app.logger.error('TILES_DENSITY_BASEE not configured') 767 791 raise ImportError('TILES_DENSITY_BASEE not configured') 768 792 769 if not 'TILES_POINT_AGE_MAX'in flask.current_app.config:793 if 'TILES_POINT_AGE_MAX' not in flask.current_app.config: 770 794 flask.current_app.logger.error('TILES_POINT_AGE_MAX not configured') 771 795 raise ImportError('TILES_POINT_AGE_MAX not configured') 772 796 773 if not 'TILES_ZOOM_RANGE'in flask.current_app.config:797 if 'TILES_ZOOM_RANGE' not in flask.current_app.config: 774 798 flask.current_app.logger.error('TILES_ZOOM_RANGE not configured') 775 799 raise ImportError('TILES_ZOOM_RANGE not configured') 776 800 777 if not 'TILES_SKIP_EMPTY'in flask.current_app.config:801 if 'TILES_SKIP_EMPTY' not in flask.current_app.config: 778 802 flask.current_app.logger.error('TILES_SKIP_EMPTY not configured') 779 803 raise ImportError('TILES_SKIP_EMPTY not configured') 780 804 781 if not 'TILES_RASTER_FILE_SIZE_MAX'in flask.current_app.config:805 if 'TILES_RASTER_FILE_SIZE_MAX' not in flask.current_app.config: 782 806 flask.current_app.logger.error( 783 807 'TILES_RASTER_FILE_SIZE_MAX not configured' … … 834 858 def _water_link(log_id): 835 859 webclient_url = '' 836 if not 'MAPSERVICE_WEBCLIENT'in flask.current_app.config:860 if 'MAPSERVICE_WEBCLIENT' not in flask.current_app.config: 837 861 flask.current_app.logger.error('MAPSERVICE_WEBCLIENT not configured') 838 862 else: -
src/gnuboat/mapservice_impl/tasks/tileconfig.py
r77cd9cf r43fd35c 1 1 # -*- coding: utf-8 -*- 2 2 ''' 3 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.3 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 4 4 5 5 This program is free software: you can redistribute it and/or modify … … 35 35 class TileConfig: 36 36 """ 37 Workaround for @dataclass, until python 3.7 is available in main distros 38 """ 37 Workaround for @dataclass, until python 3.7 is available 38 in main distros 39 """ 39 40 def __init__( 40 41 self, cache_path, sizes, densities, densitiy_base, points_age_max, -
src/gnuboat/mapservice_impl/tests/db_test_setup.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 20 20 import flask 21 21 22 from ..server_impl.database.Model import db, User, ApiKey, Water, OsmType, Gauge, Device, Log, Queue, ProcessingStatus, db_setup 23 from ..server_impl.demo import DbSetup as demoDbSetup 24 from ..server_impl.tasks.tasks import log_process 22 from gnuboat.mapservice_impl.database.Model import ( 23 db, User, ApiKey, Water, 24 OsmType, Gauge, Device, Log, Queue, ProcessingStatus, db_setup 25 ) 26 from gnuboat.mapservice_impl.demo import DbSetup as demoDbSetup 27 from gnuboat.mapservice_impl.tasks.tasks import log_process 25 28 26 29 … … 52 55 ) 53 56 user_activation.activated = False 54 user_activation.activation_code = 'dac9630aec642a428cd73f4be0a03569' 57 user_activation.activation_code = ('dac9630aec642a428cd73f4be0a' 58 '03569') 55 59 user_activation.first_name = 'Autotests' 56 60 user_activation.license_accepted = True -
src/gnuboat/mapservice_impl/tests/test_config.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 21 21 import os 22 22 23 from gnuboat _mapservice.server_impl import Config23 from gnuboat.mapservice_impl import Config 24 24 25 25 … … 27 27 def test_config_from_file(self): 28 28 """Test case load config from file 29 """29 """ 30 30 new_config = {'TESTING': True, 'DOES_NOT_EXISTS': 1234} 31 31 32 32 config = Config.Config() 33 assert config.TESTING ==False33 assert config.TESTING is False 34 34 35 35 config_file = tempfile.NamedTemporaryFile( … … 46 46 47 47 config = Config.load_from_file(config_file) 48 assert config.TESTING ==True48 assert config.TESTING is True 49 49 assert config.DOES_NOT_EXISTS == 1234 50 50 os.remove(config_file) -
src/gnuboat/mapservice_impl/tests/test_logs.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 20 20 import os 21 21 22 from .import BaseTestCase22 from gnuboat.mapservice.test import BaseTestCase 23 23 24 24 … … 30 30 def test_get(self): 31 31 """Test case getting log (src) 32 """32 """ 33 33 headers = {'Accept': 'application/json'} 34 34 response = self.client.open( … … 74 74 def test_get_by_manager(self): 75 75 """Test case getting log by submitter (src) 76 """76 """ 77 77 headers = {'Accept': 'application/json'} 78 78 … … 123 123 def test_create_log(self): 124 124 """Test case create log (src) 125 """125 """ 126 126 headers = { 127 127 'X-API-KEY': 'test_key', … … 158 158 159 159 # could not be tested without running CELERY_BROKER 160 #filename = '{}/data/nmea0183-2017-12-09.log'.format(os.path.dirname(os.path.abspath(__file__))) 161 #fileContent = open(filename, 'rb') 160 # filename = '{}/data/nmea0183-2017-12-09.log'.format( 161 # os.path.dirname(os.path.abspath(__file__))) 162 # fileContent = open(filename, 'rb') 162 163 # headers["Accept"] = "application/geo+json" 163 # response = self.client.post(164 # "{}/{}".format(self.base_url, data["logId"]),165 # data = fileContent,166 # headers = headers167 # )168 # assert response.status_code == 200164 # response = self.client.post( 165 # "{}/{}".format(self.base_url, data["logId"]), 166 # data = fileContent, 167 # headers = headers 168 # ) 169 # assert response.status_code == 200 169 170 170 171 -
src/gnuboat/mapservice_impl/tests/test_users.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 19 19 import json 20 20 21 from .import BaseTestCase21 from gnuboat.mapservice.test import BaseTestCase 22 22 23 23 … … 29 29 def test_users_get(self): 30 30 """Test case for getting users (src) 31 """31 """ 32 32 headers = {} 33 33 response = self.client.open( … … 58 58 def test_users_register(self): 59 59 """Test case for users_register (Src) 60 Register a new user61 """60 Register a new user 61 """ 62 62 user_creation = { 63 63 "username": "jane_doe", -
src/gnuboat/mapservice_impl/tests/test_waters.py
r77cd9cf r43fd35c 1 1 ''' 2 Copyright (C) 2019 - 2020 EngSaS - Engineering Solutions and ServicesLangenbach. All rights reserved.2 Copyright (C) 2019 - 2020 EngSaS - Langenbach. All rights reserved. 3 3 4 4 This program is free software: you can redistribute it and/or modify … … 19 19 import json 20 20 21 from .import BaseTestCase21 from gnuboat.mapservice.test import BaseTestCase 22 22 23 23 … … 29 29 def test_get(self): 30 30 """Test case getting waters (src) 31 """31 """ 32 32 headers = {} 33 33 response = self.client.open( … … 50 50 def test_get_by_name(self): 51 51 """Test case getting waters by name (src) 52 """52 """ 53 53 headers = {} 54 54 … … 83 83 def test_get_by_manager(self): 84 84 """Test case getting waters by manager (src) 85 """85 """ 86 86 headers = {} 87 87 … … 118 118 def test_get_by_name_manager(self): 119 119 """Test case getting waters by manager and water name (src) 120 """120 """ 121 121 headers = {} 122 122 -
src/mapservice-webclient/package.json
r77cd9cf r43fd35c 1 1 { 2 2 "name": "gnuboat-mapservice-webclient", 3 "version": "0. 1.0",3 "version": "0.5.90", 4 4 "scripts": { 5 5 "ng": "ng", -
test-requirements.txt
r77cd9cf r43fd35c 6 6 pytest-cov 7 7 pytest-pep8 8 Pillow
Note:
See TracChangeset
for help on using the changeset viewer.
