diff --git a/.coveragerc b/.coveragerc index 65e13c2234b..409fde55643 100644 --- a/.coveragerc +++ b/.coveragerc @@ -9,6 +9,7 @@ omit = ${INITIAL_PWD-.}/.github/* ${INITIAL_PWD-.}/bin.*/* ${INITIAL_PWD-.}/dist.*/* + **/gui/wxpython/*/** **/OBJ.*/* source = . diff --git a/.flake8 b/.flake8 index 32021622d7d..33920703ca6 100644 --- a/.flake8 +++ b/.flake8 @@ -15,76 +15,18 @@ per-file-ignores = # E501 line too long # E722 do not use bare 'except' # W605 invalid escape sequence - # F401 imported but unused # F821 undefined name 'unicode' # F841 local variable assigned to but never used # E741 ambiguous variable name 'l' - __init__.py: F401, F403 - lib/init/grass.py: E722, F821, F841 - man/build_check_rest.py: F403, F405 - man/build_full_index_rest.py: F403, F405 - man/parser_standard_options.py: F403, F405 - man/build_class.py: F403, F405 - man/build_class_rest.py: F403, F405 - man/build_check.py: F403, F405 - man/build_full_index.py: F403, F405 - man/build_index.py: F403, F405 - man/build_index_rest.py: F403, F405 - man/build_keywords.py: F403, F405, E722 - man/build_topics.py: F403, F405, E722 + __init__.py: F403 man/build_html.py: E501 - imagery/i.atcorr/create_iwave.py: F632, F821, W293 - doc/python/raster_example_ctypes.py: F403, F405 - doc/python/vector_example_ctypes.py: F403, F405 - doc/python/m.distance.py: F403, F405, E501 - doc/gui/wxpython/example/dialogs.py: F401 - locale/grass_po_stats.py: E122, E128, E231, E401, E722 + doc/python/m.distance.py: E501 gui/scripts/d.wms.py: E501 - gui/wxpython/core/gcmd.py: E402 - gui/wxpython/core/gthread.py: F841 - gui/wxpython/core/gconsole.py: E722 - gui/wxpython/core/toolboxes.py: E722 - gui/wxpython/core/utils.py: E722, F841 - gui/wxpython/core/workspace.py: E722 - gui/wxpython/core/render.py: E722, F841 - gui/wxpython/core/ws.py: F841 - gui/wxpython/core/settings.py: E722 - gui/wxpython/core/watchdog.py: E402 - gui/wxpython/datacatalog/tree.py: E731, E402 - gui/wxpython/dbmgr/base.py: E722 - gui/wxpython/dbmgr/dialogs.py: E722 - gui/wxpython/dbmgr/sqlbuilder.py: E722 - gui/wxpython/dbmgr/manager.py: E722 - gui/wxpython/docs/wxgui_sphinx/conf.py: E402, W291 - gui/wxpython/gcp/g.gui.gcp.py: F841 - gui/wxpython/gcp/manager.py: F841, E722 - gui/wxpython/gcp/mapdisplay.py: F841 - gui/wxpython/gui_core/*: F841, E266, E722 - gui/wxpython/gui_core/dialogs.py: E722, F841 - gui/wxpython/gui_core/forms.py: E722, F841 - gui/wxpython/gui_core/ghelp.py: E722 - gui/wxpython/gui_core/gselect.py: F841, E266, E722 - gui/wxpython/gui_core/preferences.py: E266, F841 - gui/wxpython/gui_core/treeview.py: F841 - gui/wxpython/gui_core/widgets.py: F841, E722, E266 - gui/wxpython/image2target/*: F841, E722, E265 - gui/wxpython/image2target/g.gui.image2target.py: E501, E265, F841 - gui/wxpython/iscatt/*: F841, E722, F405, F403 - gui/wxpython/lmgr/frame.py: F841, E722 - # layertree still includes some formatting issues (it is ignored by Black) - gui/wxpython/lmgr/layertree.py: E722, E266, W504, E225 - gui/wxpython/lmgr/workspace.py: F841 - gui/wxpython/modules/*: F841, E722 - gui/wxpython/nviz/*: F841, E266, E722, F403, F405 - gui/wxpython/photo2image/*: F841, E722, E265 - gui/wxpython/photo2image/g.gui.photo2image.py: E501, F841 - gui/wxpython/psmap/*: F841, E266, E722, F405, F403 + gui/wxpython/image2target/g.gui.image2target.py: E501 + gui/wxpython/photo2image/g.gui.photo2image.py: E501 + gui/wxpython/psmap/*: E501, E722 gui/wxpython/vdigit/*: F841, E722, F405, F403 - gui/wxpython/vnet/*: F841 - gui/wxpython/wxgui.py: F841 gui/wxpython/animation/g.gui.animation.py: E501 - gui/wxpython/animation/mapwindow.py: F841 - gui/wxpython/animation/provider.py: F841 gui/wxpython/tplot/frame.py: F841, E722 gui/wxpython/tplot/g.gui.tplot.py: E501 gui/wxpython/rdigit/g.gui.rdigit.py: F841 @@ -120,12 +62,9 @@ per-file-ignores = # TODO: Is this really needed? python/grass/pygrass/vector/__init__.py: E402 python/grass/pygrass/raster/__init__.py: E402 - python/grass/gunittest/invoker.py: E721 python/grass/pygrass/vector/__init__.py: E402 - python/grass/pygrass/modules/interface/*.py: F401 - python/grass/pygrass/modules/grid/*.py: F401 python/grass/pygrass/raster/category.py: E721 - python/grass/pygrass/rpc/__init__.py: F401, F403 + python/grass/pygrass/rpc/__init__.py: F403 python/grass/pygrass/utils.py: E402 python/grass/temporal/abstract_space_time_dataset.py: E722 python/grass/temporal/c_libraries_interface.py: E722 @@ -136,47 +75,35 @@ per-file-ignores = python/grass/temporal/temporal_granularity.py: E722 python/grass/temporal/temporal_raster_base_algebra.py: E722 python/grass/temporal/temporal_topology_dataset_connector.py: E722 - python/grass/temporal/univar_statistics.py: E231 # Current benchmarks/tests are changing sys.path before import. # Possibly, a different approach should be taken there anyway. - python/grass/pygrass/tests/benchmark.py: E402, F401, F821 + python/grass/pygrass/tests/benchmark.py: E402, F821 # Configuration file for Sphinx: # Ignoring import/code mix and line length. - python/grass/docs/conf.py: E402 # Files not managed by Black python/grass/imaging/images2gif.py: E226 # Unused imports in init files - # F401 imported but unused # F403 star import used; unable to detect undefined names python/grass/*/__init__.py: F401, F403 - python/grass/*/*/__init__.py: F401, F403 - python/grass/*/*/*/__init__.py: F401, F403 + python/grass/*/*/__init__.py: F403 + python/grass/*/*/*/__init__.py: F403 # E402 module level import not at top of file scripts/r.in.wms/wms_gdal_drv.py: E722 scripts/r.in.wms/wms_drv.py: E402, E722 scripts/r.in.wms/srs.py: E722 scripts/r.semantic.label/r.semantic.label.py: E501 - scripts/v.report/v.report.py: E721 scripts/db.out.ogr/db.out.ogr.py: F841 - scripts/g.extension/g.extension.py: F841, E722, E501 - scripts/v.unpack/v.unpack.py: E722, E501 - scripts/v.import/v.import.py: E722, E501 + scripts/g.extension/g.extension.py: E501 + scripts/v.unpack/v.unpack.py: E501n + scripts/v.import/v.import.py: E501 scripts/db.univar/db.univar.py: E501 - scripts/d.frame/d.frame.py: E722 - scripts/i.pansharpen/i.pansharpen.py: E722, E501 - scripts/r.in.srtm/r.in.srtm.py: E722 - scripts/r.fillnulls/r.fillnulls.py: E722 - scripts/d.rast.edit/d.rast.edit.py: E722 - scripts/v.what.strds/v.what.strds.py: E722, E501 + scripts/i.pansharpen/i.pansharpen.py: E501 + scripts/v.what.strds/v.what.strds.py: E501 # Line too long (esp. module interface definitions) scripts/*/*.py: E501 - # local variable 'column' is assigned to but never used temporal/t.rast.to.vect/t.rast.to.vect.py: E501 - # local variable 'stdstype' is assigned to but never used - temporal/t.vect.algebra/t.vect.algebra.py: F841, E501 - # ## used (##% key: r etc) - # local variable 'map_list' is assigned to but never used - temporal/t.rast.what/t.rast.what.py: E265, E266, F841, E501 + temporal/t.vect.algebra/t.vect.algebra.py: E501 + temporal/t.rast.what/t.rast.what.py: E501 # Line too long (esp. module interface definitions) temporal/*/*.py: E501 diff --git a/.github/actions/create-upload-suggestions/action.yml b/.github/actions/create-upload-suggestions/action.yml index 2493fba2573..b80c08c1b46 100644 --- a/.github/actions/create-upload-suggestions/action.yml +++ b/.github/actions/create-upload-suggestions/action.yml @@ -177,7 +177,7 @@ runs: echo "diff-file-name=${INPUT_DIFF_FILE_NAME}" >> "${GITHUB_OUTPUT}" env: INPUT_DIFF_FILE_NAME: ${{ steps.tool-name-safe.outputs.diff-file-name }} - - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 id: upload-diff if: >- ${{ (steps.files_changed.outputs.files_changed == 'true') && @@ -200,7 +200,7 @@ runs: echo 'Suggestions can only be added near to lines changed in this PR.' echo 'If any fixes can be added as code suggestions, they will be added shortly from another workflow.' } >> "${GITHUB_STEP_SUMMARY}" - - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 id: upload-changes if: >- ${{ always() && diff --git a/.github/labeler.yml b/.github/labeler.yml index d6caa447e2e..464ccdce2b8 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -123,9 +123,7 @@ docs: - '**/*.png' - '**.cff' - CITING - - CHANGES - AUTHORS - - NEWS - TODO - all-globs-to-all-files: - '!doc/development/rfc/**' diff --git a/.github/workflows/additional_checks.yml b/.github/workflows/additional_checks.yml index d25cbb49194..76554f24db3 100644 --- a/.github/workflows/additional_checks.yml +++ b/.github/workflows/additional_checks.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout repository contents - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 31 @@ -43,7 +43,7 @@ jobs: exclude: mswindows .*\.bat .*/testsuite/data/.* - name: Set up Python - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: '3.10' diff --git a/.github/workflows/apt.txt b/.github/workflows/apt.txt index a5a221c939c..4c14cb7b067 100644 --- a/.github/workflows/apt.txt +++ b/.github/workflows/apt.txt @@ -7,8 +7,8 @@ libfftw3-dev libgdal-dev libgl1-mesa-dev libglu1-mesa-dev +liblapacke-dev libnetcdf-dev -libopenblas-dev libpdal-dev libpng-dev libproj-dev diff --git a/.github/workflows/clang-format-check.yml b/.github/workflows/clang-format-check.yml index 12b0b070ec9..489d8197c09 100644 --- a/.github/workflows/clang-format-check.yml +++ b/.github/workflows/clang-format-check.yml @@ -16,7 +16,7 @@ jobs: name: Formatting Check runs-on: ubuntu-latest steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - uses: DoozyX/clang-format-lint-action@c71d0bf4e21876ebec3e5647491186f8797fde31 # v0.18.2 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 05d4581b689..d98950b0818 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -40,9 +40,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Python - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: '3.x' - name: Install non-Python dependencies @@ -52,11 +52,11 @@ jobs: sudo apt-get install -y wget git gawk findutils xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \ sudo apt-get install -y --no-install-recommends --no-install-suggests - - uses: rui314/setup-mold@0bf4f07ef9048ec62a45f9dbf2f098afa49695f0 # v1 + - uses: rui314/setup-mold@b015f7e3f2938ad3a5ed6e5111a8c6c7c1d6db6e # v1 if: ${{ matrix.language == 'c-cpp' }} - name: Initialize CodeQL - uses: github/codeql-action/init@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6 + uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 with: languages: ${{ matrix.language }} config-file: ./.github/codeql/codeql-config.yml @@ -81,6 +81,6 @@ jobs: run: .github/workflows/build_ubuntu-22.04.sh "${HOME}/install" - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6 + uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 9f1fc5d843c..51ab83015ca 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-22.04 if: github.repository == 'OSGeo/grass' steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get dependencies run: | diff --git a/.github/workflows/create_release_draft.yml b/.github/workflows/create_release_draft.yml index 09da8ad1317..fb71e35d2ff 100644 --- a/.github/workflows/create_release_draft.yml +++ b/.github/workflows/create_release_draft.yml @@ -30,12 +30,12 @@ jobs: contents: write steps: - name: Checks-out repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: ${{ github.ref }} fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: '3.11' - name: Create output directory @@ -73,7 +73,7 @@ jobs: sha256sum ${{ env.GRASS }}.tar.xz > ${{ env.GRASS }}.tar.xz.sha256 - name: Publish draft distribution to GitHub (for tags only) if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8 + uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9 with: name: GRASS GIS ${{ github.ref_name }} body: | diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1f60ed4c6d7..6b2ad83629e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -49,7 +49,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: fetch-depth: 0 - name: Docker meta @@ -68,7 +68,7 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 + uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1 - name: Login to DockerHub uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: @@ -76,7 +76,7 @@ jobs: password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push id: docker_build - uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 + uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0 with: push: true pull: true diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index e3e23f43c04..6b6286ef3f0 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -26,7 +26,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Get dependencies run: | sudo apt-get update -y diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index eb99b6ff7a7..cdc02ad1432 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -44,13 +44,20 @@ jobs: -mindepth 1 -maxdepth 1 -type f -print -delete # Rehash to forget about the deleted files hash -r - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Get current date cache key segment + id: date + # Year and week of year so cache key changes weekly + run: echo "date=$(date +%Y-%U)" >> "${GITHUB_OUTPUT}" - name: Setup Mamba - uses: mamba-org/setup-micromamba@f8b8a1e23a26f60a44c853292711bacfd3eac822 # v1.9.0 + uses: mamba-org/setup-micromamba@617811f69075e3fd3ae68ca64220ad065877f246 # v2.0.0 with: init-shell: bash environment-file: .github/workflows/macos_dependencies.txt environment-name: grass-env + # Persist on the same period (date). + cache-environment-key: environment-${{ steps.date.outputs.date }} + - name: Environment info shell: bash -el {0} run: | @@ -59,17 +66,17 @@ jobs: - name: Create installation directory run: mkdir $HOME/install - name: Build and install - shell: bash -l {0} + shell: micromamba-shell {0} run: source ./.github/workflows/macos_install.sh $HOME/install - name: Add the bin directory to PATH run: echo "$HOME/install/bin" >> $GITHUB_PATH - name: Check installed version if: ${{ !cancelled() }} - shell: bash -l {0} + shell: micromamba-shell {0} run: source ./.github/workflows/print_versions.sh - name: Run pytest with multiple workers in parallel - shell: bash -el {0} + shell: micromamba-shell {0} run: | export PYTHONPATH=$(grass --config python_path):$PYTHONPATH export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH @@ -78,7 +85,7 @@ jobs: -ra . \ -m 'not needs_solo_run' - name: Run pytest with a single worker (for tests marked with needs_solo_run) - shell: bash -el {0} + shell: micromamba-shell {0} run: | export PYTHONPATH=$(grass --config python_path):$PYTHONPATH export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH @@ -87,7 +94,7 @@ jobs: -m 'needs_solo_run' - name: Run gunittest tests - shell: bash -el {0} + shell: micromamba-shell {0} run: | grass --tmp-project XY --exec \ g.download.project url=${{ env.SampleData }} path=$HOME @@ -100,7 +107,7 @@ jobs: nc_spm_full_v2alpha2.tar.gz" - name: Make HTML test report available if: ${{ !cancelled() }} - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: testreport-macOS path: testreport diff --git a/.github/workflows/macos_dependencies.txt b/.github/workflows/macos_dependencies.txt index bc60609f7b5..8ef1d3460f6 100644 --- a/.github/workflows/macos_dependencies.txt +++ b/.github/workflows/macos_dependencies.txt @@ -1,4 +1,3 @@ -blas cairo clangxx_osx-arm64 clang_osx-arm64 @@ -13,7 +12,6 @@ giflib git ipython krb5 -lapack lastools libgdal-arrow-parquet libgdal-core @@ -32,6 +30,7 @@ libtiff llvm-openmp matplotlib numpy<2 +openblas pandoc pdal pillow diff --git a/.github/workflows/macos_gunittest.cfg b/.github/workflows/macos_gunittest.cfg index b6806ff5823..923ae2cbe5d 100644 --- a/.github/workflows/macos_gunittest.cfg +++ b/.github/workflows/macos_gunittest.cfg @@ -6,25 +6,18 @@ exclude = gui/wxpython/core/testsuite/test_gcmd.py gui/wxpython/core/testsuite/toolboxes.sh - lib/init/testsuite/test_grass_tmp_mapset.py - python/grass/gunittest/testsuite/test_assertions_rast3d.py python/grass/gunittest/testsuite/test_assertions_vect.py - python/grass/gunittest/testsuite/test_gmodules.py - python/grass/gunittest/testsuite/test_gunitest_doctests.py python/grass/pygrass/raster/testsuite/test_pygrass_raster_doctests.py python/grass/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py - python/grass/script/testsuite/test_script_doctests.py python/grass/temporal/testsuite/unittests_temporal_raster_algebra_equal_ts.py python/grass/temporal/testsuite/unittests_temporal_raster_conditionals_complement_else.py raster/r.in.lidar/testsuite/test_base_resolution.sh raster/r.in.pdal/testsuite/test_r_in_pdal_binning.py raster/r.in.pdal/testsuite/test_r_in_pdal_selection.py - raster/r.terraflow/testsuite/test_r_terraflow.py raster/r.sun/testsuite/test_rsun.py raster3d/r3.flow/testsuite/r3flow_test.py - scripts/g.search.modules/testsuite/test_g_search_modules.py - temporal/t.connect/testsuite/test_distr_tgis_db_raster3d.py temporal/t.connect/testsuite/test_distr_tgis_db_raster.py + temporal/t.connect/testsuite/test_distr_tgis_db_raster3d.py temporal/t.connect/testsuite/test_distr_tgis_db_vector.py temporal/t.info/testsuite/test.t.info.sh temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py diff --git a/.github/workflows/macos_install.sh b/.github/workflows/macos_install.sh index 79446f51867..8a94bc15c6a 100755 --- a/.github/workflows/macos_install.sh +++ b/.github/workflows/macos_install.sh @@ -47,12 +47,8 @@ CONFIGURE_FLAGS="\ --with-bzlib-libs=${CONDA_PREFIX}/lib \ --with-bzlib-includes=${CONDA_PREFIX}/include \ --with-netcdf=${CONDA_PREFIX}/bin/nc-config \ - --with-blas \ - --with-blas-libs=${CONDA_PREFIX}/lib \ - --with-blas-includes=${CONDA_PREFIX}/include \ - --with-lapack - --with-lapack-includes=${CONDA_PREFIX}/include \ - --with-lapack-libs=${CONDA_PREFIX}/lib \ + --with-blas=openblas \ + --with-lapack=openblas \ --with-netcdf=${CONDA_PREFIX}/bin/nc-config \ --with-nls \ --with-libs=${CONDA_PREFIX}/lib \ diff --git a/.github/workflows/milestones.yml b/.github/workflows/milestones.yml new file mode 100644 index 00000000000..e2ade4eb091 --- /dev/null +++ b/.github/workflows/milestones.yml @@ -0,0 +1,70 @@ +--- +name: Assign Milestone + +on: + pull_request_target: + types: [closed] + +jobs: + assign-milestone: + runs-on: ubuntu-latest + if: github.event.pull_request.merged + steps: + # Retreiving the current milestoone from API instead of github context, + # so up-to-date information is used when running after being queued or for reruns + # Otherwise, the information should be available using + # ${{ github.event.pull_request.milestone.title }} + - name: Get current milestone title + id: current-milestone + run: | + echo "milestone<> "${GITHUB_OUTPUT}" + gh pr view ${{ github.event.pull_request.html_url }} --json milestone \ + --jq .milestone.title >> "${GITHUB_OUTPUT}" + echo 'EOF' >> "${GITHUB_OUTPUT}" + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + - name: PR already has a milestone + run: echo "PR already has a milestone" + if: ${{ steps.current-milestone.outputs.milestone }} + - name: PR does not have a milestone + run: echo "PR does not have a milestone" + if: ${{ !steps.current-milestone.outputs.milestone }} + - name: Get VERSION file + if: ${{ !steps.current-milestone.outputs.milestone }} + id: version-file + run: | + echo "version<> "${GITHUB_OUTPUT}" + gh api \ + -H "Accept: application/vnd.github.raw" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "/repos/{owner}/{repo}/contents/include/VERSION?ref=${{ github.sha }}" >> "${GITHUB_OUTPUT}" + echo "EOF" >> "${GITHUB_OUTPUT}" + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + - name: Show version file + if: ${{ !steps.current-milestone.outputs.milestone }} + run: echo "${VERSIONFILE}" + env: + VERSIONFILE: ${{ steps.version-file.outputs.version }} + - name: Get milestone title from VERSION file + if: ${{ !steps.current-milestone.outputs.milestone }} + id: milestone + run: | + version=$(echo "$VERSIONFILE" | head -n 3 | xargs | sed 's/ /./g; s/\(RC[0-9]*\|dev\)//g') + echo "title=$version" >> "${GITHUB_OUTPUT}" + env: + VERSIONFILE: ${{ steps.version-file.outputs.version }} + - name: Show milestone title + if: ${{ !steps.current-milestone.outputs.milestone }} + run: echo "${MILESTONE}" + env: + MILESTONE: ${{ steps.milestone.outputs.title }} + - name: Set PR milestone + if: ${{ !steps.current-milestone.outputs.milestone }} + run: gh pr edit ${{ github.event.pull_request.html_url }} --milestone "${MILESTONE}" + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + MILESTONE: ${{ steps.milestone.outputs.title }} diff --git a/.github/workflows/osgeo4w.yml b/.github/workflows/osgeo4w.yml index 2f17427b05d..30add8dde09 100644 --- a/.github/workflows/osgeo4w.yml +++ b/.github/workflows/osgeo4w.yml @@ -31,7 +31,7 @@ jobs: run: | git config --global core.autocrlf false git config --global core.eol lf - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: msys2/setup-msys2@ddf331adaebd714795f1042345e6ca57bd66cea8 # v2.24.1 with: path-type: inherit @@ -39,25 +39,44 @@ jobs: update: true msystem: MINGW64 install: tar libintl make bison flex diffutils git dos2unix zip mingw-w64-x86_64-toolchain - mingw-w64-x86_64-fftw mingw-w64-x86_64-lapack mingw-w64-x86_64-pkgconf + mingw-w64-x86_64-fftw mingw-w64-x86_64-openblas mingw-w64-x86_64-pkgconf mingw-w64-x86_64-gcc mingw-w64-x86_64-ccache mingw-w64-x86_64-zlib mingw-w64-x86_64-libiconv mingw-w64-x86_64-bzip2 mingw-w64-x86_64-gettext mingw-w64-x86_64-libsystre mingw-w64-x86_64-libtre-git mingw-w64-x86_64-libwinpthread-git mingw-w64-x86_64-libpng mingw-w64-x86_64-pcre - - name: Install OSGeo4W - run: | - $exe = 'osgeo4w-setup.exe' - $url = 'http://download.osgeo.org/osgeo4w/v2/' + $exe - (New-Object System.Net.WebClient).DownloadFile($url, $exe) - Start-Process ('.\'+$exe) -ArgumentList '-A -g -k -q \ - -s http://download.osgeo.org/osgeo4w/v2/ -P ${{ env.Deps }}' -Wait - env: - Deps: "proj-devel,gdal-devel,geos-devel,libtiff-devel,libpng-devel,\ - pdal-devel,netcdf-devel,cairo-devel,fftw,freetype-devel,gdal-ecw,\ - gdal-mrsid,liblas-devel,libxdr,libpq-devel,pdcurses,\ - python3-matplotlib,python3-numpy,python3-ply,python3-pywin32,\ - python3-wxpython,regex-devel,zstd-devel" + - name: Setup OSGeo4W environment + uses: echoix/setup-OSGeo4W@17deecd39e077a80bf1081443998ea8edd6f15bf # v0.1.0 + with: + package-dir: "D:/OSGeo4W_pkg" + packages: | + cairo-devel + fftw + freetype-devel + gdal-devel + gdal-ecw + gdal-mrsid + geos-devel + liblas-devel + libpng-devel + libpq-devel + libtiff-devel + libxdr + netcdf-devel + pdal-devel + pdcurses + proj-devel + python3-core + python3-jupyter + python3-matplotlib + python3-numpy + python3-pip + python3-ply + python3-pytest + python3-pywin32 + python3-wxpython + regex-devel + zstd-devel - name: Set number of cores for compilation run: | @@ -66,7 +85,10 @@ jobs: - name: Compile GRASS GIS shell: msys2 {0} - run: .github/workflows/build_osgeo4w.sh + run: | + export CFLAGS="${CFLAGS} -pipe" + export CXXFLAGS="${CXXFLAGS} -pipe" + .github/workflows/build_osgeo4w.sh - name: Print installed versions if: always() @@ -80,12 +102,25 @@ jobs: shell: msys2 {0} run: .github/workflows/test_simple.sh + - name: Install pytest plugins + run: python -m pip install pytest-timeout + shell: cmd /D /E:ON /V:OFF /S /C "CALL C:/OSGeo4W/OSGeo4W.bat "{0}"" + - name: Run pytest with a single worker + run: | + call %OSGEO4W_ROOT%\opt\grass\etc\env.bat + set PYTHONPATH=%GISBASE%\etc\python;%PYTHONPATH% + path %GISBASE%\lib;%GISBASE%\bin;%PATH% + pytest --verbose --color=yes ^ + --durations=0 --durations-min=0.5 ^ + -ra . + shell: cmd /D /E:ON /V:OFF /S /C "CALL C:/OSGeo4W/OSGeo4W.bat "{0}"" + - name: Run tests run: .github/workflows/test_thorough.bat 'C:\OSGeo4W\opt\grass\grass85.bat' 'C:\OSGeo4W\bin\python3' - name: Make HTML test report available if: ${{ always() }} - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: testreport-${{ matrix.os }} path: testreport diff --git a/.github/workflows/osgeo4w_gunittest.cfg b/.github/workflows/osgeo4w_gunittest.cfg new file mode 100644 index 00000000000..b9252cf49ef --- /dev/null +++ b/.github/workflows/osgeo4w_gunittest.cfg @@ -0,0 +1,32 @@ +[gunittest] + +# Files (or wildcard patterns) to exclude from testing separated by newline or +# space. This would be ideally empty or it would include just special cases, +# but it includes mainly tests which can (and should) be fixed. +exclude = + gui/wxpython/core/testsuite/toolboxes.sh + lib/init/testsuite/test_grass_tmp_mapset.py + python/grass/gunittest/testsuite/test_gunitest_doctests.py + python/grass/pygrass/raster/testsuite/test_pygrass_raster_doctests.py + python/grass/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py + python/grass/script/testsuite/test_script_doctests.py + python/grass/temporal/testsuite/unittests_temporal_raster_conditionals_complement_else.py + temporal/t.info/testsuite/test.t.info.sh + temporal/t.rast.accdetect/testsuite/test.t.rast.accdetect.reverse.sh + temporal/t.rast.accdetect/testsuite/test.t.rast.accdetect.sh + temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py + vector/v.edit/testsuite/select_all_flag.sh + vector/v.in.lidar/testsuite/decimation_test.py + vector/v.in.lidar/testsuite/mask_test.py + vector/v.in.lidar/testsuite/test_v_in_lidar_basic.py + vector/v.in.lidar/testsuite/test_v_in_lidar_filter.py + vector/v.what.rast3/testsuite/test.v.what.rast3.sh + vector/v.what/testsuite/test_vwhat_layers.py + vector/v.what/testsuite/test_vwhat_ncspm.py + +# Maximum time for execution of one test file (not a test function) +# after which test is terminated (which may not terminate child processes +# from that test). +# Using 5 minutes as maximum (average test time should be much shorter, +# couple seconds per file, median should be around one second). +timeout = 300 diff --git a/.github/workflows/periodic_update.yml b/.github/workflows/periodic_update.yml index 346fd12e2d2..d27b8664c55 100644 --- a/.github/workflows/periodic_update.yml +++ b/.github/workflows/periodic_update.yml @@ -21,7 +21,7 @@ jobs: - name: Create URL to the run output id: vars run: echo "run-url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" >> $GITHUB_OUTPUT - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: "Check that autoconf scripts are up-to-date:" run: | rm -f config.guess config.sub @@ -33,7 +33,7 @@ jobs: run: git status --ignored - name: Create Pull Request id: cpr - uses: peter-evans/create-pull-request@8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20 # v7.0.1 + uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5 with: commit-message: "config.guess + config.sub: updated from http://git.savannah.gnu.org/cgit/config.git/plain/" branch: periodic/update-configure diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 8e3b2286b1c..3fea65773ce 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -32,10 +32,10 @@ jobs: PYTHONWARNINGS: always steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Python - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: ${{ matrix.python-version }} cache: pip @@ -48,7 +48,7 @@ jobs: xargs -a <(awk '! /^ *(#|$)/' ".github/workflows/apt.txt") -r -- \ sudo apt-get install -y --no-install-recommends --no-install-suggests - - uses: rui314/setup-mold@0bf4f07ef9048ec62a45f9dbf2f098afa49695f0 # v1 + - uses: rui314/setup-mold@b015f7e3f2938ad3a5ed6e5111a8c6c7c1d6db6e # v1 - name: Install Python dependencies run: | @@ -83,8 +83,13 @@ jobs: run: | export PYTHONPATH=`grass --config python_path`:$PYTHONPATH export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH + export INITIAL_GISBASE="$(grass --config path)" + export INITIAL_PWD="${PWD}" pytest --verbose --color=yes --durations=0 --durations-min=0.5 \ - --numprocesses auto -ra . \ + --numprocesses auto \ + --cov \ + --cov-context=test \ + -ra . \ -m 'not needs_solo_run' - name: Run pytest with a single worker (for tests marked with needs_solo_run) @@ -92,9 +97,11 @@ jobs: export PYTHONPATH=`grass --config python_path`:$PYTHONPATH export LD_LIBRARY_PATH=$(grass --config path)/lib:$LD_LIBRARY_PATH export INITIAL_GISBASE="$(grass --config path)" - INITIAL_PWD="${PWD}" pytest --verbose --color=yes --durations=0 --durations-min=0.5 \ + export INITIAL_PWD="${PWD}" + pytest --verbose --color=yes --durations=0 --durations-min=0.5 \ --cov \ --cov-context=test \ + --cov-append \ -ra . \ -m 'needs_solo_run' - name: Fix non-standard installed script paths in coverage data @@ -108,7 +115,7 @@ jobs: coverage html - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 + uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 with: verbose: true flags: pytest-python-${{ matrix.python-version }} @@ -116,7 +123,7 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} - name: Make python-only code coverage test report available if: ${{ !cancelled() }} - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: python-codecoverage-report-${{ matrix.os }}-${{ matrix.python-version }} path: coverage_html_report diff --git a/.github/workflows/python-code-quality.yml b/.github/workflows/python-code-quality.yml index 17cce1c09aa..aa6bd33724f 100644 --- a/.github/workflows/python-code-quality.yml +++ b/.github/workflows/python-code-quality.yml @@ -28,15 +28,15 @@ jobs: PYTHON_VERSION: "3.10" MIN_PYTHON_VERSION: "3.8" # renovate: datasource=pypi depName=black - BLACK_VERSION: "24.8.0" + BLACK_VERSION: "24.10.0" # renovate: datasource=pypi depName=flake8 FLAKE8_VERSION: "7.1.1" # renovate: datasource=pypi depName=pylint PYLINT_VERSION: "2.12.2" # renovate: datasource=pypi depName=bandit - BANDIT_VERSION: "1.7.9" + BANDIT_VERSION: "1.7.10" # renovate: datasource=pypi depName=ruff - RUFF_VERSION: "0.6.4" + RUFF_VERSION: "0.7.1" runs-on: ${{ matrix.os }} permissions: @@ -54,10 +54,10 @@ jobs: echo Bandit: ${{ env.BANDIT_VERSION }} echo Ruff: ${{ env.RUFF_VERSION }} - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Set up Python - uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 + uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0 with: python-version: ${{ env.PYTHON_VERSION }} cache: pip @@ -129,13 +129,13 @@ jobs: bandit -c pyproject.toml -iii -r . -f sarif -o bandit.sarif --exit-zero - name: Upload Bandit Scan Results - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: bandit.sarif path: bandit.sarif - name: Upload SARIF File into Security Tab - uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6 + uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 with: sarif_file: bandit.sarif @@ -147,7 +147,7 @@ jobs: run: | echo "MAKEFLAGS=-j$(nproc)" >> $GITHUB_ENV - - uses: rui314/setup-mold@0bf4f07ef9048ec62a45f9dbf2f098afa49695f0 # v1 + - uses: rui314/setup-mold@b015f7e3f2938ad3a5ed6e5111a8c6c7c1d6db6e # v1 - name: Build run: .github/workflows/build_${{ matrix.os }}.sh $HOME/install @@ -201,7 +201,7 @@ jobs: cp -rp dist.$ARCH/docs/html/libpython sphinx-grass - name: Make Sphinx documentation available - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: sphinx-grass path: sphinx-grass diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index 44da8d9acb7..ab2168cd1a3 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -25,7 +25,7 @@ jobs: statuses: write steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: # super-linter needs the full git history to get the # list of files that changed across commits diff --git a/.github/workflows/test-nix.yml b/.github/workflows/test-nix.yml index 22fa4f0061f..43a1b5d40ab 100644 --- a/.github/workflows/test-nix.yml +++ b/.github/workflows/test-nix.yml @@ -28,7 +28,7 @@ jobs: contents: read steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Install nix uses: DeterminateSystems/nix-installer-action@da36cb69b1c3247ad7a1f931ebfd954a1105ef14 # v14 diff --git a/.github/workflows/test_thorough.bat b/.github/workflows/test_thorough.bat index 963f24b9b43..843adb4c4f0 100644 --- a/.github/workflows/test_thorough.bat +++ b/.github/workflows/test_thorough.bat @@ -2,4 +2,4 @@ set grass=%1 set python=%2 call %grass% --tmp-project XY --exec g.download.project url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=%USERPROFILE% -call %grass% --tmp-project XY --exec %python% -m grass.gunittest.main --grassdata %USERPROFILE% --location nc_spm_full_v2alpha2 --location-type nc --min-success 80 +call %grass% --tmp-project XY --exec %python% -m grass.gunittest.main --grassdata %USERPROFILE% --location nc_spm_full_v2alpha2 --location-type nc --min-success 96 --config .github\workflows\osgeo4w_gunittest.cfg diff --git a/.github/workflows/titles.yml b/.github/workflows/titles.yml index b8e33c2fb37..9821a209a87 100644 --- a/.github/workflows/titles.yml +++ b/.github/workflows/titles.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout base repository (doesn't include the PR changes) - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Call PR title validation function run: python utils/generate_release_notes.py check "${PR_TITLE}" "" "" env: diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 57b0821eec4..9023df7d1b3 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -59,7 +59,7 @@ jobs: fail-fast: false steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Invert inclusion list to an exclusion list id: get-exclude @@ -149,7 +149,7 @@ jobs: - name: Make HTML test report available if: ${{ always() }} - uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 with: name: testreport-${{ matrix.os }}-${{ matrix.config }}-${{ matrix.extra-include }} path: testreport diff --git a/.gunittest.cfg b/.gunittest.cfg index 01b06c78913..2117fde9d7a 100644 --- a/.gunittest.cfg +++ b/.gunittest.cfg @@ -4,21 +4,14 @@ # space. This would be ideally empty or it would include just special cases, # but it includes mainly tests which can (and should) be fixed. exclude = - gui/wxpython/core/testsuite/test_gcmd.py gui/wxpython/core/testsuite/toolboxes.sh - lib/init/testsuite/test_grass_tmp_mapset.py - python/grass/gunittest/testsuite/test_assertions_rast3d.py python/grass/gunittest/testsuite/test_assertions_vect.py - python/grass/gunittest/testsuite/test_gmodules.py python/grass/gunittest/testsuite/test_gunitest_doctests.py python/grass/pygrass/raster/testsuite/test_pygrass_raster_doctests.py python/grass/pygrass/rpc/testsuite/test_pygrass_rpc_doctests.py - python/grass/script/testsuite/test_script_doctests.py python/grass/temporal/testsuite/unittests_temporal_raster_algebra_equal_ts.py python/grass/temporal/testsuite/unittests_temporal_raster_conditionals_complement_else.py raster/r.in.lidar/testsuite/test_base_resolution.sh - raster/r.in.lidar/testsuite/test_base_resolution.sh - scripts/g.search.modules/testsuite/test_g_search_modules.py temporal/t.connect/testsuite/test_distr_tgis_db_raster3d.py temporal/t.connect/testsuite/test_distr_tgis_db_raster.py temporal/t.connect/testsuite/test_distr_tgis_db_vector.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a5221f29efe..2f3216877de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ ci: skip: [flake8] repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace exclude: | @@ -37,18 +37,18 @@ repos: ) - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.6.4 + rev: v0.7.1 hooks: # Run the linter. - id: ruff args: [--fix, --preview] - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.41.0 + rev: v0.42.0 hooks: - id: markdownlint-fix # Using this mirror lets us use mypyc-compiled black, which is about 2x faster - repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black-jupyter exclude: | diff --git a/AUTHORS b/AUTHORS index a81f5a75e39..952b369702f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -206,7 +206,7 @@ MS-Windows/Cygwin: Huidae Cho Source code Quality assessment system - SOCCER Labs at Ecole Polytechnique de Montreal, Canada http://web.soccerlab.polymtl.ca/grass-evolution/grass-browsers/grass-index-en.html - http://lists.osgeo.org/mailman/listinfo/grass-qa + https://lists.osgeo.org/mailman/listinfo/grass-qa GRASS 5.7/6.0: Primary authors of new source code diff --git a/CHANGES b/CHANGES deleted file mode 100644 index d4c8280bc7b..00000000000 --- a/CHANGES +++ /dev/null @@ -1,10 +0,0 @@ -CHANGES in GRASS GIS 8.x - -https://trac.osgeo.org/grass/wiki/Grass8/NewFeatures80 -https://trac.osgeo.org/grass/wiki/Grass8/NewFeatures82 - -List of releases: - -- GitHub list: https://github.com/OSGeo/grass/releases -- Overview list: https://trac.osgeo.org/grass/wiki/Release -- History: https://grass.osgeo.org/home/history/releases/ (starting 1984!) diff --git a/Dockerfile b/Dockerfile index aba1df48a1d..6b928fb46c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -# syntax=docker/dockerfile:1.10@sha256:865e5dd094beca432e8c0a1d5e1c465db5f998dca4e439981029b3b81fb39ed5 +# syntax=docker/dockerfile:1.11@sha256:1f2be5a2aa052cbd9aedf893d17c63277c3d1c51b3fb0f3b029c6b34f658d057 # Note: This file must be kept in sync in ./Dockerfile and ./docker/ubuntu/Dockerfile. # Changes to this file must be copied over to the other file. ARG GUI=without -FROM ubuntu:22.04@sha256:adbb90115a21969d2fe6fa7f9af4253e16d45f8d4c1e930182610c4731962658 as common_start +FROM ubuntu:22.04@sha256:0e5e4a57c2499249aafc3b40fcd541e9a456aab7296681a3994d631587203f97 as common_start LABEL authors="Carmen Tawalika,Markus Neteler,Anika Weinmann,Stefan Blumentrath" LABEL maintainer="tawalika@mundialis.de,neteler@mundialis.de,weinmann@mundialis.de" @@ -19,8 +19,9 @@ WORKDIR /tmp ARG GUI # Todo: re-consider required dev packages for addons (~400MB in dev packages) -ARG GRASS_RUN_PACKAGES="build-essential \ +ARG GRASS_RUN_PACKAGES="\ bison \ + build-essential \ bzip2 \ curl \ flex \ @@ -28,8 +29,6 @@ ARG GRASS_RUN_PACKAGES="build-essential \ gcc \ gdal-bin \ geos-bin \ - proj-bin \ - netcdf-bin \ git \ language-pack-en-base \ libcairo2 \ @@ -38,28 +37,29 @@ ARG GRASS_RUN_PACKAGES="build-essential \ libfftw3-dev \ libfreetype6 \ libgdal-dev \ + libgeos-dev \ + libgsl-dev \ libgsl27 \ libjpeg-turbo8 \ libjsoncpp-dev \ - libmagic1 \ + liblapacke-dev \ libmagic-mgc \ + libmagic1 \ libncurses5 \ - libopenblas-dev \ + libomp-dev \ + libomp5 \ libopenblas-base \ + libopenblas-dev \ libopenjp2-7 \ - libomp5 \ - libomp-dev \ - libgeos-dev \ - libpdal-dev \ - libproj-dev \ - libpq-dev \ - libgsl-dev \ libpdal-base13 \ + libpdal-dev \ libpdal-plugin-hdf \ libpdal-plugins \ libpdal-util13 \ libpnglite0 \ + libpq-dev \ libpq5 \ + libproj-dev \ libpython3-all-dev \ libreadline8 \ libsqlite3-0 \ @@ -70,7 +70,9 @@ ARG GRASS_RUN_PACKAGES="build-essential \ mesa-utils \ moreutils \ ncurses-bin \ + netcdf-bin \ pdal \ + proj-bin \ proj-data \ python-is-python3 \ python3 \ @@ -86,56 +88,58 @@ ARG GRASS_RUN_PACKAGES="build-essential \ ENV GRASS_RUN_PACKAGES=${GRASS_RUN_PACKAGES} # Define build packages -ARG GRASS_BUILD_PACKAGES="cmake \ +ARG GRASS_BUILD_PACKAGES="\ + cmake \ libbz2-dev \ libcairo2-dev \ libfreetype6-dev \ - zlib1g-dev \ + libjpeg-dev \ + libncurses5-dev \ libnetcdf-dev \ libopenjp2-7-dev \ - libreadline-dev \ - libjpeg-dev \ libpnglite-dev \ + libreadline-dev \ libsqlite3-dev \ libtiff-dev \ libzstd-dev \ - libncurses5-dev \ mesa-common-dev \ zlib1g-dev \ " ENV GRASS_BUILD_PACKAGES=${GRASS_BUILD_PACKAGES} -ARG GRASS_CONFIG="--with-cxx \ +ARG GRASS_CONFIG="\ --enable-largefile \ - --with-proj-share=/usr/share/proj \ - --with-gdal=/usr/bin/gdal-config \ - --with-geos \ - --with-sqlite \ + --with-blas \ + --with-bzlib \ --with-cairo --with-cairo-ldflags=-lfontconfig \ - --with-freetype --with-freetype-includes=/usr/include/freetype2/ \ + --with-cxx \ --with-fftw \ - --with-postgres --with-postgres-includes=/usr/include/postgresql \ - --with-netcdf \ - --with-zstd \ - --with-bzlib \ - --with-pdal \ - --without-mysql \ - --with-blas \ + --with-freetype --with-freetype-includes=/usr/include/freetype2/ \ + --with-gdal=/usr/bin/gdal-config \ + --with-geos \ --with-lapack \ - --with-readline \ + --with-netcdf \ --with-odbc \ --with-openmp \ + --with-pdal \ + --with-postgres --with-postgres-includes=/usr/include/postgresql \ + --with-proj-share=/usr/share/proj \ + --with-readline \ + --with-sqlite \ + --with-zstd \ + --without-mysql \ " -ARG GRASS_PYTHON_PACKAGES="pip \ - setuptools \ - python-dateutil \ - python-magic \ - numpy \ +ARG GRASS_PYTHON_PACKAGES="\ Pillow \ - ply \ matplotlib \ + numpy \ + pip \ + ply \ psycopg2 \ + python-dateutil \ + python-magic \ + setuptools \ " ENV GRASS_PYTHON_PACKAGES=${GRASS_PYTHON_PACKAGES} @@ -147,31 +151,33 @@ ENV GRASS_CONFIG=${GRASS_CONFIG} FROM common_start as grass_with_gui -ARG GRASS_RUN_PACKAGES="${GRASS_RUN_PACKAGES} adwaita-icon-theme-full \ - libglu1-mesa \ - libgtk-3-0 \ - libnotify4 \ - libsdl2-2.0-0 \ - libxtst6 \ - librsvg2-common \ - gettext \ +ARG GRASS_RUN_PACKAGES="${GRASS_RUN_PACKAGES} \ + adwaita-icon-theme-full \ freeglut3 \ + gettext \ + libglu1-mesa \ libgstreamer-plugins-base1.0 \ + libgtk-3-0 \ libjpeg8 \ + libnotify4 \ libpng16-16 \ + librsvg2-common \ + libsdl2-2.0-0 \ libsm6 \ libtiff5 \ libwebkit2gtk-4.0 \ + libxtst6 \ " # librsvg2-common \ # (fix error (wxgui.py:7782): Gtk-WARNING **: 19:53:09.774: # Could not load a pixbuf from /org/gtk/libgtk/theme/Adwaita/assets/check-symbolic.svg. # This may indicate that pixbuf loaders or the mime database could not be found.) -ARG GRASS_BUILD_PACKAGES="${GRASS_BUILD_PACKAGES} adwaita-icon-theme-full \ +ARG GRASS_BUILD_PACKAGES="${GRASS_BUILD_PACKAGES} \ + adwaita-icon-theme-full \ + freeglut3-dev \ libgl1-mesa-dev \ libglu1-mesa-dev \ - freeglut3-dev \ libgstreamer-plugins-base1.0-dev \ libgtk-3-dev \ libjpeg-dev \ @@ -184,10 +190,11 @@ ARG GRASS_BUILD_PACKAGES="${GRASS_BUILD_PACKAGES} adwaita-icon-theme-full \ libxtst-dev \ " -ARG GRASS_CONFIG="${GRASS_CONFIG} --with-opengl \ - --with-x \ +ARG GRASS_CONFIG="${GRASS_CONFIG} \ --with-nls \ + --with-opengl \ --with-readline \ + --with-x \ " ARG GRASS_PYTHON_PACKAGES="${GRASS_PYTHON_PACKAGES} wxPython" # If you do not use any Gnome Accessibility features, to suppress warning diff --git a/INSTALL.md b/INSTALL.md index e6bd041fcf9..7687266d7c8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -29,8 +29,8 @@ directory. Installation order: 1. PROJ -2. GDAL-OGR (compiled without GRASS support) -3. optionally: databases such as PostgreSQL, MySQL, sqlite +2. GDAL/OGR (compiled without GRASS support) +3. optionally: databases such as PostgreSQL, MySQL, SQLite 4. GRASS GIS 5. optionally: GDAL-OGR-GRASS plugin @@ -41,7 +41,7 @@ GRASS source code is currently distributed in 2 forms: ### Officially released source code The full source code version contains all the GRASS source code -required for compilation. It is distributed as one file (*.tar.gz +required for compilation. It is distributed as one file (`*.tar.gz` package) and the version is composed of 3 numbers, e.g. 3.7.0, 3.7.1 etc. See . @@ -52,7 +52,7 @@ This version of the source code can be acquired either from the GitHub repository () or as a auto-generated snapshot (`*.tar.gz` package) of the GitHub repository. The snapshot name contains the date when the snapshot was created (checked out from -the GitHub repository), e.g. grass-3.7.git_src_snapshot_2022_04_27.tar.gz +the GitHub repository), e.g. `grass-3.7.git_src_snapshot_2022_04_27.tar.gz` from ## (B) COMPILATION @@ -72,7 +72,7 @@ Detailed Wiki notes for various operating systems (MS-Windows, GNU/Linux distributions, FreeBSD, AIX, etc) are available at: -First step of the compilation (-g for debugging, or -O2 for optimization): +First step of the compilation (`-g` for debugging, or `-O2` for optimization): ```bash CFLAGS="-g -Wall" ./configure @@ -108,7 +108,7 @@ make Note for Solaris users (see also Wiki page above): To configure GRASS correctly on a system which doesn't have a suitable -install program (AC_PROG_INSTALL ignores versions which are known to +install program (`AC_PROG_INSTALL` ignores versions which are known to have problems), you need to ensure that $srcdir is an absolute path, by using e.g.: @@ -136,7 +136,7 @@ CC=cc CPP=cpp ./configure ... ## (C) COMPILATION NOTES for 64bit platforms To successfully compile GRASS on 64bit platforms, the required -FFTW2 library has to be compiled with -fPIC flag: +FFTW library has to be compiled with `-fPIC` flag: ```bash #this applies to FFTW3, not to GRASS GIS: @@ -151,13 +151,13 @@ make install After compilation, the resulting code is stored in the directory ```bash -./dist.$ARCH +./dist.$ARCH/ ``` -and the scripts (grass, ...) in +and the script (`grass`) in ```bash -./bin.$ARCH +./bin.$ARCH/ ``` To run GRASS, simply start @@ -175,7 +175,7 @@ grass ## (E) INSTALLATION ON MACOSX -See the ReadMe.rtf in the ./macosx/ folder and the Wiki page above. +See the `ReadMe.rtf` in the `./macosx/` folder and the Wiki page above. ## (F) RUNNING GRASS GIS @@ -206,7 +206,7 @@ make make install ``` -For details, see +For details, see [Guide to contributing on GitHub](./doc/development/github_guide.md). ## (H) COMPILING INDIVIDUAL MODULES - OWN MODULES @@ -240,7 +240,7 @@ gmake Note: If you keep your module source code outside the standard GRASS source code directory structure, you will have to change the relative -path(s) in the Makefile to absolute path(s). +path(s) in the `Makefile` to absolute path(s). ## (I) CODE OPTIMIZATION @@ -258,8 +258,8 @@ setenv CFLAGS -O ./configure ``` -whichever works on your shell. Use -O2 instead of -O if your compiler -supports this (note: O is the letter, not zero). Using the "gcc" compiler, +whichever works on your shell. Use `-O2` instead of `-O` if your compiler +supports this (note: `O` is the letter, not zero). Using the "gcc" compiler, you can also specify processor specific flags (examples, please suggest better settings to us): @@ -272,11 +272,11 @@ CFLAGS="-O2 -msse -msse2 -mfpmath=sse \ CFLAGS="-mtune=nocona -m64 -minline-all-stringops" # Intel Pentium 64bit processor ``` -Note: As of version 4.3.0, GCC offers the -march=native switch that +Note: As of version 4.3.0, GCC offers the `-march=native` switch that enables CPU auto-detection and automatically selects optimizations supported -by the local machine at GCC runtime including -mtune. +by the local machine at GCC runtime including `-mtune`. -To find out optional CFLAGS for your platform, enter: +To find out optional `CFLAGS` for your platform, enter: ```bash gcc -dumpspecs @@ -285,7 +285,7 @@ gcc -dumpspecs See also: A real fast GRASS version (and small binaries) will be created with -LDFLAGS set to "stripping" (but this disables debugging): +`LDFLAGS` set to "stripping" (but this disables debugging): ```bash CFLAGS="-O2 -mcpu= -Wall" LDFLAGS="-s" ./configure @@ -296,7 +296,7 @@ CFLAGS="-O2 -mcpu= -Wall" LDFLAGS="-s" ./configure The `LDFLAGS=""` part must be undefined as `-s` will strip the debugging information. -Don't use `-O` for CFLAGS if you want to be able to step through function +Don't use `-O` for `CFLAGS` if you want to be able to step through function bodies. When optimisation is enabled, the compiler will re-order statements and re-arrange expressions, resulting in object code which barely resembles the source code. @@ -307,7 +307,7 @@ The `-g` and `-Wall` compiler flags are often useful for assisting debugging: CFLAGS="-g -Wall" ./configure ``` -See also the file ./doc/debugging.txt and the Wiki page +See also the file `./doc/debugging.txt` and the Wiki page ## (K) SUPPORT @@ -321,14 +321,42 @@ developers mailing list. See ## (L) GRASS PROGRAMMER'S MANUAL -The Programmer's manual is generated with doxygen from the source code. -Please see the README file and the files at: - +The Programmer's manual is +generated from the source code. This requires the installation of +`doxygen` () and optionally Graphviz `dot` +(). + +The main file is: `./grasslib.dox` where all sub-documents have +to be linked to. + +To locally generate the 'Programmer's Manual', run + +```sh +make htmldocs +``` + +To generate documentation as a single html file +(recommended for simple reading) + +```sh +make htmldocs-single +``` + +This process takes some time. The result will be found in +the file `lib/html/index.html`. + +To generate the 'Programmer's Manual' in PDF format, run + +```sh +make pdfdocs +``` ## (M) CONTRIBUTING CODE AND PATCHES -Please see ./SUBMITTING in this directory, or better, - +Please see + +- [GRASS Programming Style Guide](./doc/development/style_guide.md) +- [Guide to contributing on GitHub](./doc/development/github_guide.md) ## Authors diff --git a/Makefile b/Makefile index be8834ecf42..8b32a149a5a 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,7 @@ DIRS = \ SUBDIRS = $(DIRS) -FILES = AUTHORS CHANGES CITING COPYING GPL.TXT INSTALL.md REQUIREMENTS.md contributors.csv contributors_extra.csv translators.csv +FILES = AUTHORS CITING COPYING GPL.TXT INSTALL.md REQUIREMENTS.md contributors.csv contributors_extra.csv translators.csv FILES_DST = $(patsubst %,$(ARCH_DISTDIR)/%,$(FILES)) default: diff --git a/NEWS b/NEWS deleted file mode 100644 index 32b4cd52110..00000000000 --- a/NEWS +++ /dev/null @@ -1,18 +0,0 @@ -NEWS - -GRASS GIS 8 - o https://trac.osgeo.org/grass/wiki/Grass8/NewFeatures80 - o https://trac.osgeo.org/grass/wiki/Grass8/NewFeatures82 - -GRASS GIS 7 - o https://trac.osgeo.org/grass/wiki/Grass7/NewFeatures78 - o https://trac.osgeo.org/grass/wiki/Grass7/NewFeatures76 - o https://trac.osgeo.org/grass/wiki/Grass7/NewFeatures74 - o https://trac.osgeo.org/grass/wiki/Grass7/NewFeatures72 - o https://trac.osgeo.org/grass/wiki/Grass7/NewFeatures - - List of releases - o https://trac.osgeo.org/grass/wiki/Release - -GRASS GIS 1-6 - o List of older releases, starting in 1984 (!), see https://grass.osgeo.org/about/history/releases/ diff --git a/README.md b/README.md index b10bd51ec03..7dfdb49df82 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,6 @@ In general: you don't really need write access as you can simply open a [pull request](https://github.com/OSGeo/grass/pulls) to contribute to GRASS GIS. See [CONTRIBUTING file](CONTRIBUTING.md) for more details. -How to get write access here - -Want to become a core developer? See -[Procedure for gaining Git write access](https://trac.osgeo.org/grass/wiki/HowToContribute#WriteaccesstotheGRASScorerepository) - ## How to compile GRASS > See the INSTALL.md file. @@ -111,6 +106,11 @@ this issue, clean all the compiled files from the source code: make distclean ``` +## Further documents + +- [Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md) +- [Roadmap](https://grass.osgeo.org/about/roadmap/) + ## Thanks to all contributors ❤ [![GRASS contributors](https://contrib.rocks/image?repo=OSGeo/grass "GRASS contributors")](https://github.com/OSGeo/grass/graphs/contributors) diff --git a/REQUIREMENTS.md b/REQUIREMENTS.md index 7b2757d38f5..5d173133716 100644 --- a/REQUIREMENTS.md +++ b/REQUIREMENTS.md @@ -49,7 +49,7 @@ Note: also the respective development packages (commonly named `xxx-dev` or [https://facebook.github.io/zstd](https://facebook.github.io/zstd) - **FFTW 2.x or 3.x** (library for computing the Discrete Fourier Transform), required for `i.fft` and `i.ifft` and other modules - [http://www.fftw.org](http://www.fftw.org) + [https://fftw.org](https://fftw.org) - **GEOS** (Geometry Engine library), needed for `v.buffer` and adds extended options to the `v.select` module [https://libgeos.org/](https://libgeos.org/) @@ -81,7 +81,7 @@ Note: also the respective development packages (commonly named `xxx-dev` or - **SQLite libraries** (for the SQLite database interface) [https://www.sqlite.org](https://www.sqlite.org) - **unixODBC** (for the ODBC database interface) - [http://www.unixodbc.org](http://www.unixodbc.org) + [https://www.unixodbc.org](https://www.unixodbc.org) - **R Statistics** (for the R statistical language interface) [https://cran.r-project.org](https://cran.r-project.org) - **FreeType2** (for TrueType font support and `d.text.freetype`) diff --git a/SECURITY.md b/SECURITY.md index feef9649806..0b566dc899d 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -25,7 +25,7 @@ vulnerability, please follow these steps: ## Supported Versions -Please refer to our [Release Schedule](https://trac.osgeo.org/grass/wiki/Release/Schedule) +Please refer to our [download section](https://grass.osgeo.org/download/) for details on which versions are currently supported. ## Security Measures diff --git a/TODO b/TODO index 510d38dfa6b..5750175258e 100644 --- a/TODO +++ b/TODO @@ -39,6 +39,6 @@ Imagery ----------------- See also -http://trac.osgeo.org/grass/wiki/Grass7Planning +https://trac.osgeo.org/grass/wiki/Grass7Planning -http://trac.osgeo.org/grass/wiki/Grass8Planning +https://trac.osgeo.org/grass/wiki/Grass8Planning diff --git a/binaryInstall.src b/binaryInstall.src index 5ab008dd796..2bcb3165327 100755 --- a/binaryInstall.src +++ b/binaryInstall.src @@ -109,7 +109,7 @@ if [ $? -eq 0 ] ; then IFS="$IFSSAVE" if [ ! "$GUNZIP" ] ; then echo "No gunzip installed. Please get from:" - echo " http://www.gnu.org/software/gzip/gzip.html" + echo " https://www.gnu.org/software/gzip/gzip.html" exit fi else diff --git a/configure b/configure index 7d8b9b1e5e7..56b203e0c13 100755 --- a/configure +++ b/configure @@ -666,10 +666,6 @@ USE_PTHREAD PTHREADLIB PTHREADLIBPATH PTHREADINCPATH -USE_OPENDWG -OPENDWGLIB -OPENDWGLIBPATH -OPENDWGINCPATH HAVE_NLS INTLLIB FTLIB @@ -765,8 +761,9 @@ SOCKLIB ICONVLIB DLLIB MATHLIB -HAVE_ASPRINTF HAVE_STRLCPY +HAVE_STRLCAT +HAVE_ASPRINTF DBMIEXTRALIB USE_X11 XTLIB @@ -904,14 +901,11 @@ with_sqlite with_opengl with_odbc with_fftw -with_blas -with_lapack with_libsvm with_cairo with_freetype with_nls with_readline -with_opendwg with_regex with_pthread with_openmp @@ -919,6 +913,8 @@ with_opencl with_bzlib with_zstd with_pdal +with_blas +with_lapack with_libpng with_gdal with_liblas @@ -949,10 +945,6 @@ with_odbc_includes with_odbc_libs with_fftw_includes with_fftw_libs -with_blas_includes -with_blas_libs -with_lapack_includes -with_lapack_libs with_libsvm_includes with_libsvm_libs with_cairo_includes @@ -963,8 +955,6 @@ with_freetype_libs with_proj_includes with_proj_libs with_proj_share -with_opendwg_includes -with_opendwg_libs with_regex_includes with_regex_libs with_pthread_includes @@ -1639,14 +1629,11 @@ Optional Packages: --with-opengl support OpenGL functionality (default: yes) --with-odbc support ODBC functionality (default: no) --with-fftw support FFTW functionality (default: yes) - --with-blas support BLAS functionality (default: no) - --with-lapack support LAPACK functionality (default: no) --with-libsvm support LIBSVM functionality (default: no) --with-cairo support Cairo functionality (default: yes) --with-freetype support FreeType functionality (default: yes) --with-nls support NLS functionality (default: no) --with-readline support Readline functionality (default: no) - --with-opendwg support openDWG functionality (default: no) --with-regex support regex functionality (default: yes) --with-pthread support POSIX threads functionality (default: no) --with-openmp support OpenMP functionality (default: no) @@ -1654,6 +1641,14 @@ Optional Packages: --with-bzlib support BZIP2 functionality (default: no) --with-zstd support Zstandard functionality (default: yes) --with-pdal support PDAL functionality (default: yes) + --with-blas=pkg-config-package + enable BLAS support with by adding name of + pkg-config package name for CBLAS library, e.g. + '--with-lapack-package=openblas', default: cblas + --with-lapack=pkg-config-package + enable LAPACK support with by adding name of + pkg-config package name for LAPACKE library, e.g. + '--with-lapack-package=openblas', default: lapacke --with-libpng=path/libpng-config enable PNG support (libpng-config with path, e.g. '--with-libpng=/usr/local/bin/libpng-config') @@ -1711,12 +1706,6 @@ Optional Packages: --with-fftw-includes=DIRS FFTW include files are in DIRS --with-fftw-libs=DIRS FFTW library files are in DIRS - --with-blas-includes=DIRS - BLAS include files are in DIRS - --with-blas-libs=DIRS BLAS library files are in DIRS - --with-lapack-includes=DIRS - LAPACK include files are in DIRS - --with-lapack-libs=DIRS LAPACK library files are in DIRS --with-libsvm-includes=DIRS LIBSVM include files are in DIRS --with-libsvm-libs=DIRS LIBSVM library files are in DIRS @@ -1733,10 +1722,6 @@ Optional Packages: External PROJ.4 include files are in DIRS --with-proj-libs=DIRS External PROJ.4 library files are in DIRS --with-proj-share=DIR External PROJ.4 data files are in DIR - --with-opendwg-includes=DIRS - openDWG include files are in DIRS - --with-opendwg-libs=DIRS - openDWG library files are in DIRS --with-regex-includes=DIRS regex include files are in DIRS --with-regex-libs=DIRS regex library files are in DIRS @@ -5488,28 +5473,6 @@ fi -# Check whether --with-blas was given. -if test ${with_blas+y} -then : - withval=$with_blas; -else $as_nop - with_blas=no -fi - - - - -# Check whether --with-lapack was given. -if test ${with_lapack+y} -then : - withval=$with_lapack; -else $as_nop - with_lapack=no -fi - - - - # Check whether --with-libsvm was given. if test ${with_libsvm+y} then : @@ -5565,17 +5528,6 @@ fi -# Check whether --with-opendwg was given. -if test ${with_opendwg+y} -then : - withval=$with_opendwg; -else $as_nop - with_opendwg=no -fi - - - - # Check whether --with-regex was given. if test ${with_regex+y} then : @@ -5653,6 +5605,27 @@ fi + +# Check whether --with-blas was given. +if test ${with_blas+y} +then : + withval=$with_blas; +else $as_nop + with_blas=no +fi + + + +# Check whether --with-lapack was given. +if test ${with_lapack+y} +then : + withval=$with_lapack; +else $as_nop + with_lapack=no +fi + + + # Check whether --with-libpng was given. if test ${with_libpng+y} then : @@ -5936,44 +5909,6 @@ fi -# Check whether --with-blas-includes was given. -if test ${with_blas_includes+y} -then : - withval=$with_blas_includes; -fi - - - - -# Check whether --with-blas-libs was given. -if test ${with_blas_libs+y} -then : - withval=$with_blas_libs; -fi - - - - - -# Check whether --with-lapack-includes was given. -if test ${with_lapack_includes+y} -then : - withval=$with_lapack_includes; -fi - - - - -# Check whether --with-lapack-libs was given. -if test ${with_lapack_libs+y} -then : - withval=$with_lapack_libs; -fi - - - - - # Check whether --with-libsvm-includes was given. if test ${with_libsvm_includes+y} then : @@ -6068,25 +6003,6 @@ fi -# Check whether --with-opendwg-includes was given. -if test ${with_opendwg_includes+y} -then : - withval=$with_opendwg_includes; -fi - - - - -# Check whether --with-opendwg-libs was given. -if test ${with_opendwg_libs+y} -then : - withval=$with_opendwg_libs; -fi - - - - - # Check whether --with-regex-includes was given. if test ${with_regex_includes+y} then : @@ -6940,18 +6856,6 @@ if test "x$ac_cv_header_values_h" = xyes then : printf "%s\n" "#define HAVE_VALUES_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "f2c.h" "ac_cv_header_f2c_h" "$ac_includes_default" -if test "x$ac_cv_header_f2c_h" = xyes -then : - printf "%s\n" "#define HAVE_F2C_H 1" >>confdefs.h - -fi -ac_fn_c_check_header_compile "$LINENO" "g2c.h" "ac_cv_header_g2c_h" "$ac_includes_default" -if test "x$ac_cv_header_g2c_h" = xyes -then : - printf "%s\n" "#define HAVE_G2C_H 1" >>confdefs.h - fi ac_fn_c_check_header_compile "$LINENO" "sys/ioctl.h" "ac_cv_header_sys_ioctl_h" "$ac_includes_default" @@ -8312,6 +8216,19 @@ then : fi + + +ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" +if test "x$ac_cv_func_strlcat" = xyes +then : + printf "%s\n" "#define HAVE_STRLCAT 1" >>confdefs.h + +fi + + + +# Test if strlcpy exists +# This is a function part of *BSD libc (optionally available on Linux via libbsd) ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" if test "x$ac_cv_func_strlcpy" = xyes then : @@ -8320,6 +8237,7 @@ then : fi + # Test if mathlib needs -lm flag or is included with libc ac_fn_c_check_func "$LINENO" "atan" "ac_cv_func_atan" if test "x$ac_cv_func_atan" = xyes @@ -13786,827 +13704,220 @@ fi # $USE_FFTW # Enable BLAS option - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use BLAS" >&5 -printf %s "checking whether to use BLAS... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: \"$with_blas\"" >&5 -printf "%s\n" "\"$with_blas\"" >&6; } -case "$with_blas" in - "no") USE_BLAS= ;; - "yes") USE_BLAS="1" ;; - *) as_fn_error $? "*** You must answer yes or no." "$LINENO" 5 ;; -esac - - +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use (C)BLAS" >&5 +printf %s "checking whether to use (C)BLAS... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_blas" >&5 +printf "%s\n" "$with_blas" >&6; } BLASLIB= BLASINC= +USE_BLAS= +BLAS_PKGS="cblas blas-netlib openblas blas-atlas" +BLAS_PKG= -if test -n "$USE_BLAS"; then - -# With BLAS includes directory -# BLAS doesn't have includes (FORTRAN library) -# With BLAS library directory - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of BLAS includes" >&5 -printf %s "checking for location of BLAS includes... " >&6; } -case "$with_blas_includes" in -y | ye | yes | n | no) - as_fn_error $? "*** You must supply a directory to --with-blas-includes." "$LINENO" 5 - ;; +case "$with_blas" in + no) + ;; + yes) + USE_BLAS=1 + ;; + *) + USE_BLAS=1 + BLAS_PKGS="$with_blas" + ;; esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_blas_includes" >&5 -printf "%s\n" "$with_blas_includes" >&6; } -if test -n "$with_blas_includes" ; then - for dir in $with_blas_includes; do - if test -d "$dir"; then - BLASINC="$BLASINC -I$dir" - else - as_fn_error $? "*** BLAS includes directory $dir does not exist." "$LINENO" 5 - fi - done -fi +if test -n "$USE_BLAS"; then + blas_ok=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of BLAS library" >&5 -printf %s "checking for location of BLAS library... " >&6; } -case "$with_blas_libs" in -y | ye | yes | n | no) - as_fn_error $? "*** You must supply a directory to --with-blas-libs." "$LINENO" 5 - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_blas_libs" >&5 -printf "%s\n" "$with_blas_libs" >&6; } + for blas_chk in ${BLAS_PKGS} + do + if ! ${PKG_CONFIG} --exists ${blas_chk} ; then + continue + else + BLAS_PKG=${blas_chk} + break + fi + done -if test -n "$with_blas_libs"; then - for dir in $with_blas_libs; do - if test -d "$dir"; then - BLASLIB="$BLASLIB -L$dir" - else - as_fn_error $? "*** BLAS library directory $dir does not exist." "$LINENO" 5 - fi - done -fi + if test -z "$BLAS_PKG" ; then + as_fn_error $? "*** Unable to locate (C)BLAS pkg-conf package(s) + \"${BLAS_PKGS}\". Perhaps you need to set PKG_CONFIG_PATH." "$LINENO" 5 + fi + + BLASLIB=$(${PKG_CONFIG} --libs ${BLAS_PKG}) + BLASINC=$(${PKG_CONFIG} --cflags ${BLAS_PKG}) + save_CFLAGS="$CFLAGS"; CFLAGS="$BLASINC $CFLAGS" + save_LIBS="$LIBS"; LIBS="$BLASLIB" -# See if cblas.h exists (CBLAS,ATLAS,others) -save_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$BLASINC $CPPFLAGS" -ac_fn_c_check_header_compile "$LINENO" "cblas.h" "ac_cv_header_cblas_h" "$ac_includes_default" + for ac_header in cblas.h +do : + ac_fn_c_check_header_compile "$LINENO" "cblas.h" "ac_cv_header_cblas_h" "$ac_includes_default" if test "x$ac_cv_header_cblas_h" = xyes then : printf "%s\n" "#define HAVE_CBLAS_H 1" >>confdefs.h -fi - -CPPFLAGS="$save_CPPFLAGS" - - -ac_save_ldflags="$LDFLAGS" -LDFLAGS="$BLASLIB $LDFLAGS" - +else $as_nop + for ac_header in cblas-atlas.h +do : + ac_fn_c_check_header_compile "$LINENO" "cblas-atlas.h" "ac_cv_header_cblas_atlas_h" "$ac_includes_default" +if test "x$ac_cv_header_cblas_atlas_h" = xyes +then : + printf "%s\n" "#define HAVE_CBLAS_ATLAS_H 1" >>confdefs.h +else $as_nop + as_fn_error $? "*** Failed to find either \"cblas.h\" or \"cblas-atlas.h\" with \"$CFLAGS\"" "$LINENO" 5 +fi +done +fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dnrm2_ in -lblas" >&5 -printf %s "checking for dnrm2_ in -lblas... " >&6; } +done -ac_check_lib_save_LIBS=$LIBS -LIBS="-lblas $MATHLIB $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linking to (C)BLAS" >&5 +printf %s "checking for linking to (C)BLAS... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char dnrm2_ (); +char cblas_dgemm(); int main (void) { -return dnrm2_ (); +return cblas_dgemm(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_blas_dnrm2_=yes + blas_ok=yes else $as_nop - ac_cv_lib_blas_dnrm2_=no + + as_fn_error $? "*** Unable to link to (C)BLAS library with \"$LIBS\"." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_blas_dnrm2_" >&5 -printf "%s\n" "$ac_cv_lib_blas_dnrm2_" >&6; } -if test "x$ac_cv_lib_blas_dnrm2_" = xyes -then : - BLASLIB="$BLASLIB -lblas " -else $as_nop + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $BLAS_PKG" >&5 +printf "%s\n" "$BLAS_PKG" >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dnrm2_ in -lblas" >&5 -printf %s "checking for dnrm2_ in -lblas... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-lblas $MATHLIB -lg2c $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char dnrm2_ (); -int -main (void) -{ -return dnrm2_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_blas_dnrm2_=yes -else $as_nop - ac_cv_lib_blas_dnrm2_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_blas_dnrm2_" >&5 -printf "%s\n" "$ac_cv_lib_blas_dnrm2_" >&6; } -if test "x$ac_cv_lib_blas_dnrm2_" = xyes -then : - BLASLIB="$BLASLIB -lblas -lg2c" -else $as_nop -LDFLAGS=${ac_save_ldflags} +printf "%s\n" "#define HAVE_LIBBLAS 1" >>confdefs.h - as_fn_error $? "*** Unable to locate BLAS library." "$LINENO" 5 +fi # $USE_BLAS -fi +# Done checking BLAS -fi +# Enable LAPACK option +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use LAPACK(E)" >&5 +printf %s "checking whether to use LAPACK(E)... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_lapack" >&5 +printf "%s\n" "$with_lapack" >&6; } +LAPACKLIB= +LAPACKINC= +USE_LAPACK= +LAPACK_PKGS="lapacke openblas" +LAPACK_PKG= +case "$with_lapack" in + no) + ;; + yes) + USE_LAPACK=1 + ;; + *) + USE_LAPACK=1 + LAPACK_PKG="$with_lapack" + ;; +esac +# LAPACK is useless without BLAS +if test -z "$USE_BLAS" && test -n "$USE_LAPACK"; then + USE_LAPACK= + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: LAPACK is disabled, BLAS configuration is missing" >&5 +printf "%s\n" "$as_me: WARNING: LAPACK is disabled, BLAS configuration is missing" >&2;} +fi +if test -n "$USE_BLAS" && test -n "$USE_LAPACK"; then -LDFLAGS=${ac_save_ldflags} + lapack_ok=no + for lapack_chk in ${LAPACK_PKGS} + do + if ! ${PKG_CONFIG} --exists ${lapack_chk} ; then + continue + else + LAPACK_PKG=${lapack_chk} + break + fi + done -blas_ok=no + if test -z "$LAPACK_PKG" ; then + as_fn_error $? "*** Unable to locate LAPACK(E) pkg-conf package(s) + \"$LAPACK_PKGS\". Perhaps you need to set PKG_CONFIG_PATH." "$LINENO" 5 + fi -# Check for ATLAS -save_LDFLAGS="$LDFLAGS" -LDFLAGS="$BLASLIB $LDFLAGS" -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ATL_xerbla in -latlas" >&5 -printf %s "checking for ATL_xerbla in -latlas... " >&6; } + LAPACKLIB=`${PKG_CONFIG} --libs ${LAPACK_PKG}` + LAPACKINC=`${PKG_CONFIG} --cflags ${LAPACK_PKG}` -ac_check_lib_save_LIBS=$LIBS -LIBS="-latlas $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ + save_CFLAGS="$CFLAGS"; CFLAGS="$LAPACKINC $CFLAGS" + save_LIBS="$LIBS"; LIBS="$LAPACKLIB" -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char ATL_xerbla (); -int -main (void) -{ -return ATL_xerbla (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" + for ac_header in lapacke.h +do : + ac_fn_c_check_header_compile "$LINENO" "lapacke.h" "ac_cv_header_lapacke_h" "$ac_includes_default" +if test "x$ac_cv_header_lapacke_h" = xyes then : - ac_cv_lib_atlas_ATL_xerbla=yes + printf "%s\n" "#define HAVE_LAPACKE_H 1" >>confdefs.h + else $as_nop - ac_cv_lib_atlas_ATL_xerbla=no + as_fn_error $? "*** Unable to find \"lapacke.h\" with \"$CFLAGS\"." "$LINENO" 5 fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_atlas_ATL_xerbla" >&5 -printf "%s\n" "$ac_cv_lib_atlas_ATL_xerbla" >&6; } -if test "x$ac_cv_lib_atlas_ATL_xerbla" = xyes -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sgemm_ in -lf77blas" >&5 -printf %s "checking for sgemm_ in -lf77blas... " >&6; } -ac_check_lib_save_LIBS=$LIBS -LIBS="-lf77blas -latlas $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ +done -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char sgemm_ (); + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for linking to LAPACK(E)" >&5 +printf %s "checking for linking to LAPACK(E)... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +char LAPACKE_dgesv(); int main (void) { -return sgemm_ (); +return LAPACKE_dgesv(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_f77blas_sgemm_=yes + lapack_ok=yes else $as_nop - ac_cv_lib_f77blas_sgemm_=no + + as_fn_error $? "*** Unable to link to LAPACK(E) library with \"$LIBS\"." "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_f77blas_sgemm_" >&5 -printf "%s\n" "$ac_cv_lib_f77blas_sgemm_" >&6; } -if test "x$ac_cv_lib_f77blas_sgemm_" = xyes -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cblas_dgemm in -lcblas" >&5 -printf %s "checking for cblas_dgemm in -lcblas... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LAPACK_PKG" >&5 +printf "%s\n" "$LAPACK_PKG" >&6; } -ac_check_lib_save_LIBS=$LIBS -LIBS="-lcblas -lf77blas -latlas $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char cblas_dgemm (); -int -main (void) -{ -return cblas_dgemm (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_cblas_cblas_dgemm=yes -else $as_nop - ac_cv_lib_cblas_cblas_dgemm=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cblas_cblas_dgemm" >&5 -printf "%s\n" "$ac_cv_lib_cblas_cblas_dgemm" >&6; } -if test "x$ac_cv_lib_cblas_cblas_dgemm" = xyes -then : - blas_ok=yes; BLASLIB="-lcblas -lf77blas -latlas" -fi - -fi - - -fi - -LDFLAGS="$save_LDFLAGS" - -# Do we have ATLAS? -if test $blas_ok = yes; then - -printf "%s\n" "#define HAVE_LIBATLAS 1" >>confdefs.h - -fi - -# BLAS in Apple vecLib framework? (Mac OS-X) -# not dependent on APP build -#if test -n "$MACOSX_APP"; then -if test $blas_ok = no; then - vlib_flags="-framework vecLib" - save_LIBS="$LIBS" - LIBS="$vlib_flags $LIBS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sgemm in $vlib_flags" >&5 -printf %s "checking for sgemm in $vlib_flags... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ -sgemm - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - blas_ok=yes; BLASLIB="$vlib_flags" -else $as_nop - BLASLIB="" -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $blas_ok" >&5 -printf "%s\n" "$blas_ok" >&6; } - LIBS="$save_LIBS" -fi -#fi # $MACOSX_APP - -# BLAS in PhiPACK libraries? (requires generic BLAS, too) -if test $blas_ok = no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sgemm_ in -lblas" >&5 -printf %s "checking for sgemm_ in -lblas... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-lblas $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char sgemm_ (); -int -main (void) -{ -return sgemm_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_blas_sgemm_=yes -else $as_nop - ac_cv_lib_blas_sgemm_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_blas_sgemm_" >&5 -printf "%s\n" "$ac_cv_lib_blas_sgemm_" >&6; } -if test "x$ac_cv_lib_blas_sgemm_" = xyes -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dgemm_ in -ldgemm" >&5 -printf %s "checking for dgemm_ in -ldgemm... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-ldgemm -lblas $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char dgemm_ (); -int -main (void) -{ -return dgemm_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_dgemm_dgemm_=yes -else $as_nop - ac_cv_lib_dgemm_dgemm_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dgemm_dgemm_" >&5 -printf "%s\n" "$ac_cv_lib_dgemm_dgemm_" >&6; } -if test "x$ac_cv_lib_dgemm_dgemm_" = xyes -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sgemm_ in -lsgemm" >&5 -printf %s "checking for sgemm_ in -lsgemm... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-lsgemm -lblas $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char sgemm_ (); -int -main (void) -{ -return sgemm_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_sgemm_sgemm_=yes -else $as_nop - ac_cv_lib_sgemm_sgemm_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sgemm_sgemm_" >&5 -printf "%s\n" "$ac_cv_lib_sgemm_sgemm_" >&6; } -if test "x$ac_cv_lib_sgemm_sgemm_" = xyes -then : - blas_ok=yes; BLASLIB="-lsgemm -ldgemm -lblas" -fi - -fi - - -fi - -fi - -# BLAS in Sun Performance library? -if test $blas_ok = no; then - if test "x$GCC" != xyes; then # only works with Sun CC - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for acosp in -lsunmath" >&5 -printf %s "checking for acosp in -lsunmath... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-lsunmath $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char acosp (); -int -main (void) -{ -return acosp (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_sunmath_acosp=yes -else $as_nop - ac_cv_lib_sunmath_acosp=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sunmath_acosp" >&5 -printf "%s\n" "$ac_cv_lib_sunmath_acosp" >&6; } -if test "x$ac_cv_lib_sunmath_acosp" = xyes -then : - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sgemm_ in -lsunperf" >&5 -printf %s "checking for sgemm_ in -lsunperf... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-lsunperf -lsunmath $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char sgemm_ (); -int -main (void) -{ -return sgemm_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_sunperf_sgemm_=yes -else $as_nop - ac_cv_lib_sunperf_sgemm_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sunperf_sgemm_" >&5 -printf "%s\n" "$ac_cv_lib_sunperf_sgemm_" >&6; } -if test "x$ac_cv_lib_sunperf_sgemm_" = xyes -then : - blas_ok=yes; BLASLIB="-xlic_lib=sunperf -lsunmath" -fi - - -fi - - fi -fi - -# Generic BLAS library -if test $blas_ok = no; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sgemm_ in -lblas" >&5 -printf %s "checking for sgemm_ in -lblas... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-lblas $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char sgemm_ (); -int -main (void) -{ -return sgemm_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_blas_sgemm_=yes -else $as_nop - ac_cv_lib_blas_sgemm_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_blas_sgemm_" >&5 -printf "%s\n" "$ac_cv_lib_blas_sgemm_" >&6; } -if test "x$ac_cv_lib_blas_sgemm_" = xyes -then : - blas_ok=yes; BLASLIB="-lblas" -fi - -fi - -if test $blas_ok = yes; then - -printf "%s\n" "#define HAVE_LIBBLAS 1" >>confdefs.h - -fi - -fi # $USE_BLAS - - - - -# Done checking BLAS - -# Enable LAPACK option - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use LAPACK" >&5 -printf %s "checking whether to use LAPACK... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: \"$with_lapack\"" >&5 -printf "%s\n" "\"$with_lapack\"" >&6; } -case "$with_lapack" in - "no") USE_LAPACK= ;; - "yes") USE_LAPACK="1" ;; - *) as_fn_error $? "*** You must answer yes or no." "$LINENO" 5 ;; -esac - - - -LAPACKLIB= -LAPACKINC= - -# LAPACK is useless without BLAS -if test -n "$USE_BLAS"; then -if test -n "$USE_LAPACK"; then - -# With LAPACK includes directory -# LAPACK doesn't have includes (FORTRAN library) -# With LAPACK library directory - -lapack_ok=no - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of LAPACK includes" >&5 -printf %s "checking for location of LAPACK includes... " >&6; } -case "$with_lapack_includes" in -y | ye | yes | n | no) - as_fn_error $? "*** You must supply a directory to --with-lapack-includes." "$LINENO" 5 - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_lapack_includes" >&5 -printf "%s\n" "$with_lapack_includes" >&6; } - -if test -n "$with_lapack_includes" ; then - for dir in $with_lapack_includes; do - if test -d "$dir"; then - LAPACKINC="$LAPACKINC -I$dir" - else - as_fn_error $? "*** LAPACK includes directory $dir does not exist." "$LINENO" 5 - fi - done -fi - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of LAPACK library" >&5 -printf %s "checking for location of LAPACK library... " >&6; } -case "$with_lapack_libs" in -y | ye | yes | n | no) - as_fn_error $? "*** You must supply a directory to --with-lapack-libs." "$LINENO" 5 - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_lapack_libs" >&5 -printf "%s\n" "$with_lapack_libs" >&6; } - -if test -n "$with_lapack_libs"; then - for dir in $with_lapack_libs; do - if test -d "$dir"; then - LAPACKLIB="$LAPACKLIB -L$dir" - else - as_fn_error $? "*** LAPACK library directory $dir does not exist." "$LINENO" 5 - fi - done -fi - - -# See if clapack.h exists (ATLAS) -save_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$LAPACKINC $CPPFLAGS" -ac_fn_c_check_header_compile "$LINENO" "clapack.h" "ac_cv_header_clapack_h" "$ac_includes_default" -if test "x$ac_cv_header_clapack_h" = xyes -then : - printf "%s\n" "#define HAVE_CLAPACK_H 1" >>confdefs.h - -fi - -CPPFLAGS="$save_CPPFLAGS" - -# LAPACK linked to by default? -if test lapack_ok=no; then - save_LIBS="$LIBS"; LIBS="$LIBS $BLASLIB $MATHLIB $FLIBS" - save_LDFLAGS="$LDFLAGS"; LDFLAGS="$LAPACKLIB $LDFLAGS" - ac_fn_c_check_func "$LINENO" "dsegv_" "ac_cv_func_dsegv_" -if test "x$ac_cv_func_dsegv_" = xyes -then : - lapack_ok=yes -fi - - LIBS="$save_LIBS" - LDFLAGS="$save_LDFLAGS" -fi - -# Generic LAPACK library? -if test $lapack_ok = no; then - save_libs="$LIBS"; LIBS="$BLASLIB $MATHLIB $LIBS" - save_LDFLAGS="$LDFLAGS"; LDFLAGS="$LAPACKLIB $LDFLAGS" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for desgv_ in -llapack" >&5 -printf %s "checking for desgv_ in -llapack... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-llapack $FLIBS $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char desgv_ (); -int -main (void) -{ -return desgv_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_lapack_desgv_=yes -else $as_nop - ac_cv_lib_lapack_desgv_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lapack_desgv_" >&5 -printf "%s\n" "$ac_cv_lib_lapack_desgv_" >&6; } -if test "x$ac_cv_lib_lapack_desgv_" = xyes -then : - lapack_ok=yes; LAPACKLIB="-llapack" -fi - - LIBS="$save_LIBS" - LDFLAGS="$save_LDFLAGS" -fi - -if test $lapack_ok = no; then - -ac_save_ldflags="$LDFLAGS" -LDFLAGS="$LAPACKLIB $LDFLAGS" - - - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dgesv_ in -llapack" >&5 -printf %s "checking for dgesv_ in -llapack... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-llapack $BLASLIB $MATHLIB $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char dgesv_ (); -int -main (void) -{ -return dgesv_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_lapack_dgesv_=yes -else $as_nop - ac_cv_lib_lapack_dgesv_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lapack_dgesv_" >&5 -printf "%s\n" "$ac_cv_lib_lapack_dgesv_" >&6; } -if test "x$ac_cv_lib_lapack_dgesv_" = xyes -then : - LAPACKLIB="$LAPACKLIB -llapack " -else $as_nop - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dgesv_ in -llapack" >&5 -printf %s "checking for dgesv_ in -llapack... " >&6; } - -ac_check_lib_save_LIBS=$LIBS -LIBS="-llapack $BLASLIB $MATHLIB -lg2c $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -char dgesv_ (); -int -main (void) -{ -return dgesv_ (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - ac_cv_lib_lapack_dgesv_=yes -else $as_nop - ac_cv_lib_lapack_dgesv_=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lapack_dgesv_" >&5 -printf "%s\n" "$ac_cv_lib_lapack_dgesv_" >&6; } -if test "x$ac_cv_lib_lapack_dgesv_" = xyes -then : - LAPACKLIB="$LAPACKLIB -llapack -lg2c" -else $as_nop - -LDFLAGS=${ac_save_ldflags} - - as_fn_error $? "*** Unable to locate LAPACK library." "$LINENO" 5 - - -fi - - - - -fi - - - - - - -LDFLAGS=${ac_save_ldflags} - -fi + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" printf "%s\n" "#define HAVE_LIBLAPACK 1" >>confdefs.h -fi # $USE_LAPACK -fi # $USE_BLAS +fi # $USE_BLAS $USE_LAPACK @@ -15192,113 +14503,6 @@ fi -# Enable openDWG option - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use openDWG" >&5 -printf %s "checking whether to use openDWG... " >&6; } -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: \"$with_opendwg\"" >&5 -printf "%s\n" "\"$with_opendwg\"" >&6; } -case "$with_opendwg" in - "no") USE_OPENDWG= ;; - "yes") USE_OPENDWG="1" ;; - *) as_fn_error $? "*** You must answer yes or no." "$LINENO" 5 ;; -esac - - - -OPENDWGINCPATH= -OPENDWGLIBPATH= -OPENDWGLIB= - -if test -n "${USE_OPENDWG}"; then - -# With OPENDWG includes directory - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of openDGW includes" >&5 -printf %s "checking for location of openDGW includes... " >&6; } -case "$with_opendwg_includes" in -y | ye | yes | n | no) - as_fn_error $? "*** You must supply a directory to --with-opendwg-includes." "$LINENO" 5 - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_opendwg_includes" >&5 -printf "%s\n" "$with_opendwg_includes" >&6; } - -if test -n "$with_opendwg_includes" ; then - for dir in $with_opendwg_includes; do - if test -d "$dir"; then - OPENDWGINCPATH="$OPENDWGINCPATH -I$dir" - else - as_fn_error $? "*** openDGW includes directory $dir does not exist." "$LINENO" 5 - fi - done -fi - - - -ac_save_cppflags="$CPPFLAGS" -CPPFLAGS="$OPENDWGINCPATH $CPPFLAGS" - for ac_header in ad2.h -do : - ac_fn_c_check_header_compile "$LINENO" "ad2.h" "ac_cv_header_ad2_h" "$ac_includes_default" -if test "x$ac_cv_header_ad2_h" = xyes -then : - printf "%s\n" "#define HAVE_AD2_H 1" >>confdefs.h - -else $as_nop - - as_fn_error $? "*** Unable to locate openDWG includes." "$LINENO" 5 - -fi - -done -CPPFLAGS=$ac_save_cppflags - - -# With OPENDWG library directory - - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of openDWG library" >&5 -printf %s "checking for location of openDWG library... " >&6; } -case "$with_opendwg_libs" in -y | ye | yes | n | no) - as_fn_error $? "*** You must supply a directory to --with-opendwg-libs." "$LINENO" 5 - ;; -esac -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_opendwg_libs" >&5 -printf "%s\n" "$with_opendwg_libs" >&6; } - -if test -n "$with_opendwg_libs"; then - for dir in $with_opendwg_libs; do - if test -d "$dir"; then - OPENDWGLIBPATH="$OPENDWGLIBPATH -L$dir" - else - as_fn_error $? "*** openDWG library directory $dir does not exist." "$LINENO" 5 - fi - done -fi - - -#search for ad2.a, ad3.a ... in openDWG toolkit directory: -#FIX ME how to program this test?? -#LOC_CHECK_LIBS(ad?.a,adSeekLayer,openDWG,$OPENDWGLIBPATH,OPENDWGLIB,,) -# -#for now hack (but working): -TRUEOPENDWGLIBPATH=`echo "$OPENDWGLIBPATH" | cut -b3-` -adlib=`ls -1 "$TRUEOPENDWGLIBPATH"/ad?.a | tail -1` -OPENDWGLIB="$adlib" - -fi # $USE_OPENDWG - - - - - - -# Done checking OPENDWG - # Enable pthread option @@ -17673,8 +16877,6 @@ echo " C++ support: `if test -n "${USE_CXX}" ; then echo yes ; e echo " Cairo support: `if test -n "${USE_CAIRO}" ; then echo yes ; else echo no ; fi`" -echo " DWG support: `if test -n "${USE_OPENDWG}" ; then echo yes ; else echo no ; fi`" - echo " FFTW support: `if test -n "${USE_FFTW}" ; then echo yes ; else echo no ; fi`" echo " FreeType support: `if test -n "${USE_FREETYPE}" ; then echo yes ; else echo no ; fi`" diff --git a/configure.ac b/configure.ac index 8ef6e1b9f7c..fc3403163da 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ # Public License (>=v2). Read the file COPYING that # comes with GRASS for details. # -# MANUAL: http://www.gnu.org/software/autoconf/manual/autoconf.html +# MANUAL: https://www.gnu.org/software/autoconf/manual/autoconf.html # http://savannah.gnu.org/projects/autoconf/ # Website for config.guess, config.sub: # wget http://git.savannah.gnu.org/cgit/config.git/plain/config.guess @@ -305,14 +305,11 @@ LOC_ARG_WITH(sqlite, SQLite) LOC_ARG_WITH(opengl, OpenGL) LOC_ARG_WITH(odbc, ODBC, no) LOC_ARG_WITH(fftw, FFTW) -LOC_ARG_WITH(blas, BLAS, no) -LOC_ARG_WITH(lapack, LAPACK, no) LOC_ARG_WITH(libsvm, LIBSVM, no) LOC_ARG_WITH(cairo, Cairo) LOC_ARG_WITH(freetype, FreeType) LOC_ARG_WITH(nls, NLS, no) LOC_ARG_WITH(readline, Readline, no) -LOC_ARG_WITH(opendwg, openDWG, no) LOC_ARG_WITH(regex, regex) LOC_ARG_WITH(pthread, POSIX threads, no) LOC_ARG_WITH(openmp, OpenMP, no) @@ -321,6 +318,19 @@ LOC_ARG_WITH(bzlib, BZIP2, no) LOC_ARG_WITH(zstd, Zstandard) LOC_ARG_WITH(pdal, PDAL) + +AC_ARG_WITH([blas], + [AS_HELP_STRING([--with-blas=pkg-config-package], + [enable BLAS support with by adding name of pkg-config package name + for CBLAS library, e.g. '--with-lapack-package=openblas', + default: cblas])],, [with_blas=no]) + +AC_ARG_WITH([lapack], + [AS_HELP_STRING([--with-lapack=pkg-config-package], + [enable LAPACK support with by adding name of pkg-config package name + for LAPACKE library, e.g. '--with-lapack-package=openblas', + default: lapacke])],, [with_lapack=no]) + AC_ARG_WITH(libpng, [ --with-libpng[=path/libpng-config] enable PNG support (libpng-config with path, @@ -391,12 +401,6 @@ LOC_ARG_WITH_LIB(odbc, ODBC) LOC_ARG_WITH_INC(fftw, FFTW) LOC_ARG_WITH_LIB(fftw, FFTW) -LOC_ARG_WITH_INC(blas, BLAS) -LOC_ARG_WITH_LIB(blas, BLAS) - -LOC_ARG_WITH_INC(lapack, LAPACK) -LOC_ARG_WITH_LIB(lapack, LAPACK) - LOC_ARG_WITH_INC(libsvm, LIBSVM) LOC_ARG_WITH_LIB(libsvm, LIBSVM) @@ -411,9 +415,6 @@ LOC_ARG_WITH_INC(proj, External PROJ.4) LOC_ARG_WITH_LIB(proj, External PROJ.4) LOC_ARG_WITH_SHARE(proj, External PROJ.4) -LOC_ARG_WITH_INC(opendwg, openDWG) -LOC_ARG_WITH_LIB(opendwg, openDWG) - LOC_ARG_WITH_INC(regex, regex) LOC_ARG_WITH_LIB(regex, regex) @@ -505,7 +506,7 @@ AC_CHECK_PROGS(ENV, env) AC_PATH_PROG(PERL, perl, no) #AC_CHECK_HEADERS(curses.h limits.h termio.h termios.h unistd.h values.h) -AC_CHECK_HEADERS(limits.h termio.h termios.h unistd.h values.h f2c.h g2c.h) +AC_CHECK_HEADERS(limits.h termio.h termios.h unistd.h values.h) AC_CHECK_HEADERS(sys/ioctl.h sys/mtio.h sys/resource.h sys/time.h) AC_CHECK_HEADERS(sys/timeb.h sys/types.h sys/utsname.h) AC_CHECK_HEADERS(libintl.h iconv.h) @@ -595,6 +596,9 @@ AC_SUBST(DBMIEXTRALIB) AC_CHECK_FUNCS(asprintf) AC_SUBST(HAVE_ASPRINTF) +AC_CHECK_FUNCS(strlcat) +AC_SUBST(HAVE_STRLCAT) + # Test if strlcpy exists # This is a function part of *BSD libc (optionally available on Linux via libbsd) AC_CHECK_FUNCS(strlcpy) @@ -1577,91 +1581,67 @@ AC_SUBST(FFTWLIB) # Enable BLAS option -LOC_CHECK_USE(blas,BLAS,USE_BLAS) +AC_MSG_CHECKING([whether to use (C)BLAS]) +AC_MSG_RESULT([$with_blas]) BLASLIB= BLASINC= +USE_BLAS= +BLAS_PKGS="cblas blas-netlib openblas blas-atlas" +BLAS_PKG= + +case "$with_blas" in + no) + ;; + yes) + USE_BLAS=1 + ;; + *) + USE_BLAS=1 + BLAS_PKGS="$with_blas" + ;; +esac if test -n "$USE_BLAS"; then -# With BLAS includes directory -# BLAS doesn't have includes (FORTRAN library) -# With BLAS library directory - -LOC_CHECK_INC_PATH(blas, BLAS, BLASINC) -LOC_CHECK_LIB_PATH(blas, BLAS, BLASLIB) - -# See if cblas.h exists (CBLAS,ATLAS,others) -save_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$BLASINC $CPPFLAGS" -AC_CHECK_HEADERS(cblas.h) -CPPFLAGS="$save_CPPFLAGS" - -LOC_CHECK_LIBS(blas,dnrm2_,BLAS,$BLASLIB,BLASLIB,$MATHLIB,,,-lg2c) - -blas_ok=no - -# Check for ATLAS -save_LDFLAGS="$LDFLAGS" -LDFLAGS="$BLASLIB $LDFLAGS" -AC_CHECK_LIB(atlas, ATL_xerbla, - [AC_CHECK_LIB(f77blas, sgemm_, - [AC_CHECK_LIB(cblas, cblas_dgemm, - [blas_ok=yes; BLASLIB="-lcblas -lf77blas -latlas"], - [],[-lf77blas -latlas])], - [],[-latlas])] -) -LDFLAGS="$save_LDFLAGS" - -# Do we have ATLAS? -if test $blas_ok = yes; then - AC_DEFINE(HAVE_LIBATLAS, 1, [Define to 1 if ATLAS exists.]) -fi + blas_ok=no -# BLAS in Apple vecLib framework? (Mac OS-X) -# not dependent on APP build -#if test -n "$MACOSX_APP"; then -if test $blas_ok = no; then - vlib_flags="-framework vecLib" - save_LIBS="$LIBS" - LIBS="$vlib_flags $LIBS" - AC_MSG_CHECKING([for sgemm in $vlib_flags]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[sgemm]])],[blas_ok=yes; BLASLIB="$vlib_flags"],[BLASLIB=""]) - AC_MSG_RESULT($blas_ok) - LIBS="$save_LIBS" -fi -#fi # $MACOSX_APP - -# BLAS in PhiPACK libraries? (requires generic BLAS, too) -if test $blas_ok = no; then - AC_CHECK_LIB(blas, sgemm_, - [AC_CHECK_LIB(dgemm, dgemm_, - [AC_CHECK_LIB(sgemm, sgemm_, - [blas_ok=yes; BLASLIB="-lsgemm -ldgemm -lblas"], - [], [-lblas])], - [], [-lblas])] - ) -fi + for blas_chk in ${BLAS_PKGS} + do + if ! ${PKG_CONFIG} --exists ${blas_chk} ; then + continue + else + BLAS_PKG=${blas_chk} + break + fi + done -# BLAS in Sun Performance library? -if test $blas_ok = no; then - if test "x$GCC" != xyes; then # only works with Sun CC - AC_CHECK_LIB(sunmath, acosp, - [AC_CHECK_LIB(sunperf, sgemm_, - [blas_ok=yes; BLASLIB="-xlic_lib=sunperf -lsunmath"], - [], [-lsunmath])] - ) - fi -fi + if test -z "$BLAS_PKG" ; then + AC_MSG_ERROR([*** Unable to locate (C)BLAS pkg-conf package(s) + "${BLAS_PKGS}". Perhaps you need to set PKG_CONFIG_PATH.]) + fi -# Generic BLAS library -if test $blas_ok = no; then - AC_CHECK_LIB(blas, sgemm_, [blas_ok=yes; BLASLIB="-lblas"]) -fi + BLASLIB=$(${PKG_CONFIG} --libs ${BLAS_PKG}) + BLASINC=$(${PKG_CONFIG} --cflags ${BLAS_PKG}) -if test $blas_ok = yes; then -AC_DEFINE(HAVE_LIBBLAS, 1, [Define to 1 if BLAS exists.]) -fi + save_CFLAGS="$CFLAGS"; CFLAGS="$BLASINC $CFLAGS" + save_LIBS="$LIBS"; LIBS="$BLASLIB" + + AC_CHECK_HEADERS([cblas.h],, + AC_CHECK_HEADERS([cblas-atlas.h],, + AC_MSG_ERROR([*** Failed to find either "cblas.h" or "cblas-atlas.h" with "$CFLAGS"]))) + + AC_MSG_CHECKING([for linking to (C)BLAS]) + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[char cblas_dgemm();]], [[return cblas_dgemm();]])], + [blas_ok=yes] , [ + AC_MSG_ERROR([*** Unable to link to (C)BLAS library with "$LIBS".])]) + AC_MSG_RESULT([$BLAS_PKG]) + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + + AC_DEFINE(HAVE_LIBBLAS, 1, [Define to 1 if BLAS exists.]) fi # $USE_BLAS @@ -1672,57 +1652,74 @@ AC_SUBST(BLASINC) # Enable LAPACK option -LOC_CHECK_USE(lapack,LAPACK,USE_LAPACK) +AC_MSG_CHECKING([whether to use LAPACK(E)]) +AC_MSG_RESULT([$with_lapack]) LAPACKLIB= LAPACKINC= +USE_LAPACK= +LAPACK_PKGS="lapacke openblas" +LAPACK_PKG= + +case "$with_lapack" in + no) + ;; + yes) + USE_LAPACK=1 + ;; + *) + USE_LAPACK=1 + LAPACK_PKG="$with_lapack" + ;; +esac # LAPACK is useless without BLAS -if test -n "$USE_BLAS"; then -if test -n "$USE_LAPACK"; then - -# With LAPACK includes directory -# LAPACK doesn't have includes (FORTRAN library) -# With LAPACK library directory - -lapack_ok=no - -LOC_CHECK_INC_PATH(lapack, LAPACK, LAPACKINC) -LOC_CHECK_LIB_PATH(lapack, LAPACK, LAPACKLIB) - -# See if clapack.h exists (ATLAS) -save_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$LAPACKINC $CPPFLAGS" -AC_CHECK_HEADERS(clapack.h) -CPPFLAGS="$save_CPPFLAGS" - -# LAPACK linked to by default? -if test lapack_ok=no; then - save_LIBS="$LIBS"; LIBS="$LIBS $BLASLIB $MATHLIB $FLIBS" - save_LDFLAGS="$LDFLAGS"; LDFLAGS="$LAPACKLIB $LDFLAGS" - AC_CHECK_FUNC(dsegv_, [lapack_ok=yes]) - LIBS="$save_LIBS" - LDFLAGS="$save_LDFLAGS" +if test -z "$USE_BLAS" && test -n "$USE_LAPACK"; then + USE_LAPACK= + AC_MSG_WARN([LAPACK is disabled, BLAS configuration is missing]) fi -# Generic LAPACK library? -if test $lapack_ok = no; then - save_libs="$LIBS"; LIBS="$BLASLIB $MATHLIB $LIBS" - save_LDFLAGS="$LDFLAGS"; LDFLAGS="$LAPACKLIB $LDFLAGS" - AC_CHECK_LIB(lapack, desgv_, - [lapack_ok=yes; LAPACKLIB="-llapack"], [], [$FLIBS]) - LIBS="$save_LIBS" - LDFLAGS="$save_LDFLAGS" -fi +if test -n "$USE_BLAS" && test -n "$USE_LAPACK"; then -if test $lapack_ok = no; then - LOC_CHECK_LIBS(lapack,dgesv_,LAPACK,$LAPACKLIB,LAPACKLIB,$BLASLIB $MATHLIB,,,-lg2c) -fi + lapack_ok=no -AC_DEFINE(HAVE_LIBLAPACK, 1, [Define to 1 if LAPACK exists.]) + for lapack_chk in ${LAPACK_PKGS} + do + if ! ${PKG_CONFIG} --exists ${lapack_chk} ; then + continue + else + LAPACK_PKG=${lapack_chk} + break + fi + done -fi # $USE_LAPACK -fi # $USE_BLAS + if test -z "$LAPACK_PKG" ; then + AC_MSG_ERROR([*** Unable to locate LAPACK(E) pkg-conf package(s) + "$LAPACK_PKGS". Perhaps you need to set PKG_CONFIG_PATH.]) + fi + + LAPACKLIB=`${PKG_CONFIG} --libs ${LAPACK_PKG}` + LAPACKINC=`${PKG_CONFIG} --cflags ${LAPACK_PKG}` + + save_CFLAGS="$CFLAGS"; CFLAGS="$LAPACKINC $CFLAGS" + save_LIBS="$LIBS"; LIBS="$LAPACKLIB" + + AC_CHECK_HEADERS([lapacke.h], [], + AC_MSG_ERROR([*** Unable to find "lapacke.h" with "$CFLAGS".])) + + AC_MSG_CHECKING([for linking to LAPACK(E)]) + AC_LINK_IFELSE([AC_LANG_PROGRAM( + [[char LAPACKE_dgesv();]], [[return LAPACKE_dgesv(); ]])], + [lapack_ok=yes] , [ + AC_MSG_ERROR([*** Unable to link to LAPACK(E) library with "$LIBS".])]) + AC_MSG_RESULT([$LAPACK_PKG]) + + CFLAGS="$save_CFLAGS" + LIBS="$save_LIBS" + + AC_DEFINE(HAVE_LIBLAPACK, 1, [Define to 1 if LAPACK exists.]) + +fi # $USE_BLAS $USE_LAPACK AC_SUBST(LAPACKLIB) AC_SUBST(LAPACKINC) @@ -1857,44 +1854,6 @@ fi AC_SUBST(INTLLIB) AC_SUBST(HAVE_NLS) -# Enable openDWG option - -LOC_CHECK_USE(opendwg,openDWG,USE_OPENDWG) - -OPENDWGINCPATH= -OPENDWGLIBPATH= -OPENDWGLIB= - -if test -n "${USE_OPENDWG}"; then - -# With OPENDWG includes directory - -LOC_CHECK_INC_PATH(opendwg,openDGW,OPENDWGINCPATH) - -LOC_CHECK_INCLUDES(ad2.h,openDWG,$OPENDWGINCPATH) - -# With OPENDWG library directory - -LOC_CHECK_LIB_PATH(opendwg,openDWG,OPENDWGLIBPATH) - -#search for ad2.a, ad3.a ... in openDWG toolkit directory: -#FIX ME how to program this test?? -#LOC_CHECK_LIBS(ad?.a,adSeekLayer,openDWG,$OPENDWGLIBPATH,OPENDWGLIB,,) -# -#for now hack (but working): -TRUEOPENDWGLIBPATH=`echo "$OPENDWGLIBPATH" | cut -b3-` -adlib=`ls -1 "$TRUEOPENDWGLIBPATH"/ad?.a | tail -1` -OPENDWGLIB="$adlib" - -fi # $USE_OPENDWG - -AC_SUBST(OPENDWGINCPATH) -AC_SUBST(OPENDWGLIBPATH) -AC_SUBST(OPENDWGLIB) -AC_SUBST(USE_OPENDWG) - -# Done checking OPENDWG - # Enable pthread option LOC_CHECK_USE(pthread,POSIX threads,USE_PTHREAD) @@ -2069,7 +2028,6 @@ LOC_MSG_USE(BLAS support,USE_BLAS) LOC_MSG_USE(BZIP2 support,USE_BZIP2) LOC_MSG_USE(C++ support,USE_CXX) LOC_MSG_USE(Cairo support,USE_CAIRO) -LOC_MSG_USE(DWG support,USE_OPENDWG) LOC_MSG_USE(FFTW support,USE_FFTW) LOC_MSG_USE(FreeType support,USE_FREETYPE) LOC_MSG_USE(GDAL support,USE_GDAL) diff --git a/db/db.login/main.c b/db/db.login/main.c index 9147c0e7f1f..f073b654665 100644 --- a/db/db.login/main.c +++ b/db/db.login/main.c @@ -98,9 +98,9 @@ int main(int argc, char *argv[]) exit(EXIT_SUCCESS); } - if (db_set_login2(driver->answer, database->answer, user->answer, - password->answer, host->answer, port->answer, - G_get_overwrite()) == DB_FAILED) { + if (db_set_login(driver->answer, database->answer, user->answer, + password->answer, host->answer, port->answer, + G_get_overwrite()) == DB_FAILED) { G_fatal_error(_("Unable to set user/password")); } diff --git a/db/drivers/mysql/db.c b/db/drivers/mysql/db.c index 5c98c652e95..b83d3d7064d 100644 --- a/db/drivers/mysql/db.c +++ b/db/drivers/mysql/db.c @@ -51,7 +51,7 @@ int db__driver_open_database(dbHandle *handle) connpar.host, connpar.port, connpar.dbname, connpar.user, connpar.password); - db_get_login2("mysql", name, &user, &password, &host, &port); + db_get_login("mysql", name, &user, &password, &host, &port); connection = mysql_init(NULL); res = diff --git a/db/drivers/mysql/grass-mesql.html b/db/drivers/mysql/grass-mesql.html index 8e2aca2155c..e04b30a2a8f 100644 --- a/db/drivers/mysql/grass-mesql.html +++ b/db/drivers/mysql/grass-mesql.html @@ -83,7 +83,7 @@

AUTHOR

Credits: Development of the driver was sponsored by -Faunalia (Italy) +Faunalia (Italy) as part of a project for ATAC. diff --git a/db/drivers/mysql/grass-mysql.html b/db/drivers/mysql/grass-mysql.html index 60c7fbe4f78..af8c0273d98 100644 --- a/db/drivers/mysql/grass-mysql.html +++ b/db/drivers/mysql/grass-mysql.html @@ -116,7 +116,7 @@

SEE ALSO

Credits

Development of the driver was sponsored by -Faunalia (Italy) +Faunalia (Italy) as part of a project for ATAC.

AUTHOR

diff --git a/db/drivers/odbc/INSTALL b/db/drivers/odbc/INSTALL index 74928ff55a6..3f485ee3f20 100644 --- a/db/drivers/odbc/INSTALL +++ b/db/drivers/odbc/INSTALL @@ -1,4 +1,4 @@ -1. Download, compile, install and configure ODBC (http://www.unixodbc.org/) +1. Download, compile, install and configure ODBC (https://www.unixodbc.org/) 2. Copy ODBC include files to /usr/include/odbc 3. Compile src/libes/dbmi/drivers/odbc 4. Add row for ODBC driver to dbmscap file diff --git a/db/drivers/odbc/grass-odbc.html b/db/drivers/odbc/grass-odbc.html index 7692893ca92..75a5ca578d7 100644 --- a/db/drivers/odbc/grass-odbc.html +++ b/db/drivers/odbc/grass-odbc.html @@ -95,10 +95,10 @@

Linux

 ConnSettings            = Configuration of an DSN without GUI is described on -http://www.unixodbc.org/odbcinst.html, +https://www.unixodbc.org/odbcinst.html, but odbc.ini and .odbc.ini may be created by the 'ODBCConfig' tool. You can easily view your DSN structure by 'DataManager'. Configuration with -GUI is described on http://www.unixodbc.org/doc/UserManual/ +GUI is described on https://www.unixodbc.org/doc/UserManual/

To find out about your PostgreSQL protocol, run:

@@ -159,6 +159,6 @@ 

SEE ALSO

db.connect, v.db.connect, -unixODBC web site, +unixODBC web site, SQL support in GRASS GIS diff --git a/db/drivers/postgres/README b/db/drivers/postgres/README index 254a0fd28c9..a2959739f6e 100644 --- a/db/drivers/postgres/README +++ b/db/drivers/postgres/README @@ -19,7 +19,7 @@ Check also for PostgreSQL data types for defining them in GRASS: Supported types in ./globals.h: -(See http://www.postgresql.org/docs/9.4/interactive/datatype.html) +(See https://www.postgresql.org/docs/9.4/interactive/datatype.html) DB_C_TYPE_INT: bit, int2, smallint, int4, int, integer, int8, bigint, serial, oid diff --git a/db/drivers/postgres/db.c b/db/drivers/postgres/db.c index 5343acf03d8..aa27d370419 100644 --- a/db/drivers/postgres/db.c +++ b/db/drivers/postgres/db.c @@ -54,7 +54,7 @@ int db__driver_open_database(dbHandle *handle) return DB_FAILED; } - db_get_login2("pg", name, &user, &password, &host, &port); + db_get_login("pg", name, &user, &password, &host, &port); pg_conn = PQsetdbLogin(host, port, pgconn.options, pgconn.tty, pgconn.dbname, user, password); @@ -241,7 +241,7 @@ int create_delete_db(dbHandle *handle, int create) pgconn.host, pgconn.port, pgconn.options, pgconn.tty, pgconn.dbname, pgconn.user, pgconn.password, pgconn.host, pgconn.port, pgconn.schema); - db_get_login2("pg", template_db, &user, &password, &host, &port); + db_get_login("pg", template_db, &user, &password, &host, &port); pg_conn = PQsetdbLogin(host, port, pgconn.options, pgconn.tty, pgconn.dbname, user, password); diff --git a/db/drivers/postgres/grass-pg.html b/db/drivers/postgres/grass-pg.html index 72c292aade4..cb707fa9314 100644 --- a/db/drivers/postgres/grass-pg.html +++ b/db/drivers/postgres/grass-pg.html @@ -6,7 +6,7 @@

Creating a PostgreSQL database

A new database is created with createdb, see -the PostgreSQL +the PostgreSQL manual for details.

Connecting GRASS to PostgreSQL

@@ -120,7 +120,7 @@

Geometry Converters

  • e00pg: E00 to PostGIS filter, see also v.in.e00.
  • -
  • GDAL/OGR ogrinfo and ogr2ogr: +
  • GDAL/OGR ogrinfo and ogr2ogr: GIS vector format converter and library, e.g. ArcInfo or SHAPE to PostGIS.
    ogr2ogr -f "PostgreSQL" shapefile ??
  • @@ -141,8 +141,8 @@

    SEE ALSO

    REFERENCES

    diff --git a/db/drivers/postgres/listdb.c b/db/drivers/postgres/listdb.c index 0efa0328c0f..974141f1e36 100644 --- a/db/drivers/postgres/listdb.c +++ b/db/drivers/postgres/listdb.c @@ -48,7 +48,7 @@ int db__driver_list_databases(dbString *dbpath, int npaths, dbHandle **dblist, pgconn.dbname, pgconn.user, pgconn.password, pgconn.host, pgconn.port, pgconn.options, pgconn.tty); - db_get_login2("pg", NULL, &user, &passwd, &host, &port); + db_get_login("pg", NULL, &user, &passwd, &host, &port); G_debug(1, "user = %s, passwd = %s", user, passwd ? "xxx" : ""); if (user || passwd) { diff --git a/db/drivers/sqlite/README b/db/drivers/sqlite/README index b0c59be7d64..955cbede58a 100644 --- a/db/drivers/sqlite/README +++ b/db/drivers/sqlite/README @@ -14,7 +14,7 @@ db.connect driver=sqlite \ The database is created automatically when used first time. That is SQLite feature followed also in the driver. -SQLite uses "type affinity", (http://www.sqlite.org/datatype3.html) +SQLite uses "type affinity", (https://www.sqlite.org/datatype3.html) that means column types are recommended, but not required. If the driver in GRASS has to determine column type, it first reads diff --git a/db/drivers/sqlite/db.c b/db/drivers/sqlite/db.c index 518ba6c978c..cd86e4648f6 100644 --- a/db/drivers/sqlite/db.c +++ b/db/drivers/sqlite/db.c @@ -78,7 +78,11 @@ int db__driver_open_database(dbHandle *handle) G_free_tokens(tokens); } else { - strcpy(name2, name); + if (G_strlcpy(name2, name, sizeof(name2)) >= sizeof(name2)) { + db_d_append_error(_("Database name <%s> is too long"), name); + db_d_report_error(); + return DB_FAILED; + } } G_debug(2, "name2 = '%s'", name2); @@ -114,11 +118,20 @@ int db__driver_open_database(dbHandle *handle) else { G_warning(_("The sqlite config option '%s' is not supported"), "SQLITE_CONFIG_URI"); - strcpy(name3, name2); + if (G_strlcpy(name3, name2, sizeof(name3)) >= sizeof(name3)) { + db_d_append_error(_("Database name <%s> is too long"), name2); + db_d_report_error(); + return DB_FAILED; + } + } + } + else { + if (G_strlcpy(name3, name2, sizeof(name3)) >= sizeof(name3)) { + db_d_append_error(_("Database name <%s> is too long"), name2); + db_d_report_error(); + return DB_FAILED; } } - else - strcpy(name3, name2); if (sqlite3_open(name3, &sqlite) != SQLITE_OK) { db_d_append_error("%s %s\n%s", _("Unable to open database:"), name3, (char *)sqlite3_errmsg(sqlite)); @@ -184,11 +197,20 @@ int db__driver_create_database(dbHandle *handle) else { G_warning(_("The sqlite config option '%s' is not supported"), "SQLITE_CONFIG_URI"); - strcpy(name2, name); + if (G_strlcpy(name2, name, sizeof(name2)) >= sizeof(name2)) { + db_d_append_error(_("Database name <%s> is too long"), name); + db_d_report_error(); + return DB_FAILED; + } + } + } + else { + if (G_strlcpy(name2, name, sizeof(name2)) >= sizeof(name2)) { + db_d_append_error(_("Database name <%s> is too long"), name); + db_d_report_error(); + return DB_FAILED; } } - else - strcpy(name2, name); if (sqlite3_open(name2, &sqlite) != SQLITE_OK) { db_d_append_error("%s %s\n%s", _("Unable to create database:"), name, (char *)sqlite3_errmsg(sqlite)); diff --git a/db/drivers/sqlite/fetch.c b/db/drivers/sqlite/fetch.c index 8e020753293..44a62b4bb4d 100644 --- a/db/drivers/sqlite/fetch.c +++ b/db/drivers/sqlite/fetch.c @@ -130,7 +130,7 @@ int db__driver_fetch(dbCursor *cn, int position, int *more) G_debug(3, "col %d, litetype %d, sqltype %d: val = '%s'", col, litetype, sqltype, text); - /* http://www.sqlite.org/capi3ref.html#sqlite3_column_type + /* https://www.sqlite.org/capi3ref.html#sqlite3_column_type SQLITE_INTEGER 1 SQLITE_FLOAT 2 SQLITE_TEXT 3 diff --git a/db/drivers/sqlite/grass-sqlite.html b/db/drivers/sqlite/grass-sqlite.html index e746f5820c0..ae59def1e52 100644 --- a/db/drivers/sqlite/grass-sqlite.html +++ b/db/drivers/sqlite/grass-sqlite.html @@ -25,8 +25,8 @@

    Supported SQL commands

    All SQL commands supported by SQLite (for limitations, see SQLite help page: -SQL As Understood By SQLite and -Unsupported SQL). +SQL As Understood By SQLite and +Unsupported SQL).

    Operators available in conditions

    @@ -46,7 +46,7 @@

    Browsing table data in DB

    The algorithm uses input parameters set by the user on the diff --git a/imagery/i.eb.eta/i.eb.eta.html b/imagery/i.eb.eta/i.eb.eta.html index ff947cb1b43..7915c7eba1a 100644 --- a/imagery/i.eb.eta/i.eb.eta.html +++ b/imagery/i.eb.eta/i.eb.eta.html @@ -24,7 +24,7 @@

    REFERENCES

    [1] Bastiaanssen, W.G.M., 1995. Estimation of Land surface parameters by remote sensing under clear-sky conditions. PhD thesis, Wageningen University, Wageningen, The Netherlands. -(PDF) +(PDF)

    [2] Chemin Y., Alexandridis T.A., 2001. Improving spatial resolution of ET seasonal for irrigated rice in Zhanghe, China. Asian Journal of Geoinformatics. @@ -33,12 +33,12 @@

    REFERENCES

    [3] Alexandridis T.K., Cherif I., Chemin Y., Silleos N.G., Stavrinos E., Zalidis G.C. Integrated methodology for estimating water use in Mediterranean agricultural areas. Remote Sensing. 2009, 1, 445-465. -(PDF) +(PDF)

    [4] Chemin, Y., 2012. A Distributed Benchmarking Framework for Actual ET Models, in: Irmak, A. (Ed.), Evapotranspiration - Remote Sensing and Modeling. InTech. -(PDF) +(PDF)

    SEE ALSO

    diff --git a/imagery/i.eb.evapfr/i.eb.evapfr.html b/imagery/i.eb.evapfr/i.eb.evapfr.html index 8d6354f36f9..9e745534728 100644 --- a/imagery/i.eb.evapfr/i.eb.evapfr.html +++ b/imagery/i.eb.evapfr/i.eb.evapfr.html @@ -18,7 +18,7 @@

    REFERENCES

    Bastiaanssen, W.G.M., 1995. Estimation of Land surface parameters by remote sensing under clear-sky conditions. PhD thesis, Wageningen University, Wageningen, The Netherlands. -(PDF) +(PDF)

    Bastiaanssen, W.G.M., Molden, D.J., Makin, I.W., 2000. Remote sensing for irrigated agriculture: examples from research and @@ -32,12 +32,12 @@

    REFERENCES

    Zalidis G.C., 2009. Integrated methodology for estimating water use in Mediterranean agricultural areas. Remote Sensing. 1, 445-465. -(PDF) +(PDF)

    Chemin, Y., 2012. A Distributed Benchmarking Framework for Actual ET Models, in: Irmak, A. (Ed.), Evapotranspiration - Remote Sensing and Modeling. InTech. -(PDF) +(PDF)

    SEE ALSO

    diff --git a/imagery/i.eb.hsebal01/i.eb.hsebal01.html b/imagery/i.eb.hsebal01/i.eb.hsebal01.html index 4b6d3953e53..4501af13c3c 100644 --- a/imagery/i.eb.hsebal01/i.eb.hsebal01.html +++ b/imagery/i.eb.hsebal01/i.eb.hsebal01.html @@ -37,7 +37,7 @@

    REFERENCES

    [1] Bastiaanssen, W.G.M., 1995. Estimation of Land surface parameters by remote sensing under clear-sky conditions. PhD thesis, Wageningen University, Wageningen, The Netherlands. -(PDF) +(PDF)

    [2] Chemin Y., Alexandridis T.A., 2001. Improving spatial resolution of ET seasonal for irrigated rice in Zhanghe, China. Asian Journal of @@ -46,12 +46,12 @@

    REFERENCES

    [3] Alexandridis T.K., Cherif I., Chemin Y., Silleos N.G., Stavrinos E., Zalidis G.C. Integrated methodology for estimating water use in Mediterranean agricultural areas. Remote Sensing. 2009, 1, 445-465. -(PDF) +(PDF)

    [4] Chemin, Y., 2012. A Distributed Benchmarking Framework for Actual ET Models, in: Irmak, A. (Ed.), Evapotranspiration - Remote Sensing and Modeling. InTech. -(PDF) +(PDF)

    SEE ALSO

    diff --git a/imagery/i.eb.netrad/i.eb.netrad.html b/imagery/i.eb.netrad/i.eb.netrad.html index 306bb39c90d..c6cba3ad484 100644 --- a/imagery/i.eb.netrad/i.eb.netrad.html +++ b/imagery/i.eb.netrad/i.eb.netrad.html @@ -28,12 +28,12 @@

    REFERENCES

    densities and moisture indicators in composite terrain; a remote sensing approach under clear skies in mediterranean climates. PhD thesis, Wageningen Agricultural Univ., The Netherland, 271 pp. -(PDF) +(PDF)
  • Chemin, Y., 2012. A Distributed Benchmarking Framework for Actual ET Models, in: Irmak, A. (Ed.), Evapotranspiration - Remote Sensing and Modeling. InTech. -(PDF)
  • +(PDF)

    SEE ALSO

    diff --git a/imagery/i.eb.soilheatflux/i.eb.soilheatflux.html b/imagery/i.eb.soilheatflux/i.eb.soilheatflux.html index b948d827da2..ecf62af78e9 100644 --- a/imagery/i.eb.soilheatflux/i.eb.soilheatflux.html +++ b/imagery/i.eb.soilheatflux/i.eb.soilheatflux.html @@ -41,7 +41,7 @@

    REFERENCES

    Bastiaanssen, W.G.M., 1995. Estimation of Land surface parameters by remote sensing under clear-sky conditions. PhD thesis, Wageningen University, Wageningen, The Netherlands. - (PDF) + (PDF)

    Chemin Y., Alexandridis T.A., 2001. Improving spatial resolution of ET seasonal for irrigated rice in Zhanghe, China. Asian Journal of Geoinformatics. 5(1):3-11,2004. @@ -49,12 +49,12 @@

    REFERENCES

    Alexandridis T.K., Cherif I., Chemin Y., Silleos N.G., Stavrinos E., Zalidis G.C. Integrated methodology for estimating water use in Mediterranean agricultural areas. Remote Sensing. 2009, 1, 445-465. -(PDF) +(PDF)

    Chemin, Y., 2012. A Distributed Benchmarking Framework for Actual ET Models, in: Irmak, A. (Ed.), Evapotranspiration - Remote Sensing and Modeling. InTech. -(PDF) +(PDF)

    SEE ALSO

    diff --git a/imagery/i.emissivity/i.emissivity.html b/imagery/i.emissivity/i.emissivity.html index 872ca4fddae..e6419e8f776 100644 --- a/imagery/i.emissivity/i.emissivity.html +++ b/imagery/i.emissivity/i.emissivity.html @@ -21,7 +21,7 @@

    REFERENCES

  • Bastiaanssen, W.G.M., 1995. Estimation of Land surface parameters by remote sensing under clear-sky conditions. PhD thesis, Wageningen University, Wageningen, The Netherlands. - (PDF)
  • + (PDF)
  • Caselles, V., C. Coll, and E. Valor, 1997. Land surface emissivity and temperature determination in the whole HAPEX-Sahel area from AVHRR data. International Journal of Remote diff --git a/imagery/i.fft/i.fft.html b/imagery/i.fft/i.fft.html index abb7453af82..8eb63a9c8ae 100644 --- a/imagery/i.fft/i.fft.html +++ b/imagery/i.fft/i.fft.html @@ -40,12 +40,12 @@

    REFERENCES

    • M. Frigo and S. G. Johnson (1998): "FFTW: An Adaptive Software Architecture -for the FFT". See www.FFTW.org: FFTW is a C subroutine library +for the FFT". See www.FFTW.org: FFTW is a C subroutine library for computing the Discrete Fourier Transform (DFT) in one or more dimensions, of both real and complex data, and of arbitrary input size.
    • John A. Richards, 1986. Remote Sensing Digital Image Analysis, Springer-Verlag.
    • Personal communication, between program author and Ali R. Vali, -Space Research Center, University of Texas, Austin, 1990. +Space Research Center, University of Texas, Austin, 1990.

    SEE ALSO

    diff --git a/imagery/i.fft/main.c b/imagery/i.fft/main.c index ad9a87a7890..051428b77ef 100644 --- a/imagery/i.fft/main.c +++ b/imagery/i.fft/main.c @@ -105,8 +105,9 @@ int main(int argc, char *argv[]) inputfd = Rast_open_old(Cellmap_orig, ""); if (Rast_maskfd() >= 0) - G_warning(_("Raster MASK found, consider to remove " - "(see man-page). Will continue...")); + G_warning(_("Raster mask active, consider removing it" + " and running again without it (see documentation for" + " details). This current process will now continue...")); G_get_set_window(&window); /* get the current window for later */ diff --git a/imagery/i.gensig/testsuite/test_i_gensig.py b/imagery/i.gensig/testsuite/test_i_gensig.py index 0498cabaf79..836550fd1e6 100644 --- a/imagery/i.gensig/testsuite/test_i_gensig.py +++ b/imagery/i.gensig/testsuite/test_i_gensig.py @@ -13,6 +13,7 @@ import stat import ctypes import shutil +from pathlib import Path from grass.pygrass import utils from grass.pygrass.gis import Mapset @@ -91,9 +92,13 @@ def tearDownClass(cls): """Remove the temporary region and generated data""" cls.del_temp_region() shutil.rmtree(cls.sig_dir1, ignore_errors=True) - cls.runModule("g.remove", flags="f", type="raster", name=cls.b1, quiet=True) - cls.runModule("g.remove", flags="f", type="raster", name=cls.b2, quiet=True) - cls.runModule("g.remove", flags="f", type="raster", name=cls.train, quiet=True) + cls.runModule( + "g.remove", + flags="f", + type="raster", + name=(cls.b1, cls.b2, cls.train), + quiet=True, + ) def test_creation(self): """Test creating a signature""" @@ -107,7 +112,7 @@ def test_creation(self): ) # File must be present - sig_stat = os.stat(f"{self.sig_dir1}/sig") + sig_stat = Path(self.sig_dir1, "sig").stat() self.assertTrue(stat.S_ISREG(sig_stat.st_mode)) # Compare values within sig file diff --git a/imagery/i.ifft/i.ifft.html b/imagery/i.ifft/i.ifft.html index 028f81f5895..eee7bc54e06 100644 --- a/imagery/i.ifft/i.ifft.html +++ b/imagery/i.ifft/i.ifft.html @@ -23,7 +23,7 @@

    REFERENCES

    • M. Frigo and S. G. Johnson (1998): "FFTW: An Adaptive Software -Architecture for the FFT". See www.fftw.org: +Architecture for the FFT". See www.fftw.org: FFTW is a C subroutine library for computing the Discrete Fourier Transform (DFT) in one or more dimensions, of both real and complex data, and of arbitrary input size.
    • diff --git a/imagery/i.landsat.toar/i.landsat.toar.html b/imagery/i.landsat.toar/i.landsat.toar.html index 821f7cb4cfe..4a792c26274 100644 --- a/imagery/i.landsat.toar/i.landsat.toar.html +++ b/imagery/i.landsat.toar/i.landsat.toar.html @@ -235,7 +235,7 @@

      DOS1 example

      Calculation of reflectance values from DN using DOS1 (metadata obtained -from p016r035_7x20020524.met.gz): +from p016r035_7x20020524.met.gz):
       i.landsat.toar input=lsat7_2002. output=lsat7_2002_toar. sensor=tm7 \
      diff --git a/imagery/i.maxlik/testsuite/test_i_maxlik.py b/imagery/i.maxlik/testsuite/test_i_maxlik.py
      index 1f6829e92b4..2245d0d6d58 100644
      --- a/imagery/i.maxlik/testsuite/test_i_maxlik.py
      +++ b/imagery/i.maxlik/testsuite/test_i_maxlik.py
      @@ -19,6 +19,7 @@
       
       from grass.gunittest.case import TestCase
       from grass.gunittest.main import test
      +from grass.gunittest.utils import xfail_windows
       
       from grass.lib.gis import G_mapset_path
       from grass.lib.raster import Rast_write_semantic_label
      @@ -162,16 +163,16 @@ def tearDownClass(cls):
               cls.del_temp_region()
               shutil.rmtree(cls.sig_dir1, ignore_errors=True)
               shutil.rmtree(cls.sig_dir2, ignore_errors=True)
      -        cls.runModule("g.remove", flags="f", type="raster", name=cls.b1, quiet=True)
      -        cls.runModule("g.remove", flags="f", type="raster", name=cls.b2, quiet=True)
               cls.runModule(
      -            "g.remove", flags="f", type="raster", name=cls.v1_class, quiet=True
      -        )
      -        cls.runModule(
      -            "g.remove", flags="f", type="raster", name=cls.v2_class, quiet=True
      +            "g.remove",
      +            flags="f",
      +            type="raster",
      +            name=(cls.b1, cls.b2, cls.v1_class, cls.v2_class),
      +            quiet=True,
               )
               cls.runModule("g.remove", flags="f", type="group", name=cls.group, quiet=True)
       
      +    @xfail_windows
           def test_v1(self):
               """Test v1 signature"""
               self.assertModule(
      @@ -193,6 +194,7 @@ def test_v1(self):
               self.assertEqual(res.get_cat(0)[1], 1)
               res.close()
       
      +    @xfail_windows
           def test_v2(self):
               """Test v2 signature"""
               self.assertModule(
      diff --git a/imagery/i.ortho.photo/README b/imagery/i.ortho.photo/README
      index bc8313ce304..51260299d5b 100644
      --- a/imagery/i.ortho.photo/README
      +++ b/imagery/i.ortho.photo/README
      @@ -49,7 +49,7 @@ Workflow description:
       Open Source GIS: A GRASS GIS Approach, Second Edition, 2004
       by Markus Neteler and Helena Mitasova,
       Chapter 10 – PROCESSING OF AERIAL PHOTOS
      -http://grassbook.org/extra/sample-chapter/
      +https://grassbook.org/extra/sample-chapter/
       --> PDF
       
       ######################################################################
      diff --git a/imagery/i.ortho.photo/lib/TODO b/imagery/i.ortho.photo/lib/TODO
      index 792cb581378..df02ac3cf5d 100644
      --- a/imagery/i.ortho.photo/lib/TODO
      +++ b/imagery/i.ortho.photo/lib/TODO
      @@ -30,4 +30,4 @@ Possibly a lot is already done in lib/image3/ ?
       -----------------
       See also
       
      -http://trac.osgeo.org/grass/wiki/Grass7Planning
      +https://trac.osgeo.org/grass/wiki/Grass7Planning
      diff --git a/imagery/i.ortho.photo/lib/find_init.c b/imagery/i.ortho.photo/lib/find_init.c
      index 906203a7f90..f8cea9b9387 100644
      --- a/imagery/i.ortho.photo/lib/find_init.c
      +++ b/imagery/i.ortho.photo/lib/find_init.c
      @@ -4,15 +4,19 @@
        * Find the a camera initial file in the current group (if it exists)
        **************************************************************/
       #include 
      +#include 
       
       int I_find_initial(char *group)
       {
      -    char *element;
      -
      -    element = (char *)G_malloc(80 * sizeof(char));
      +    char element[GNAME_MAX + 6];
       
           if (group == NULL || *group == 0)
               return 0;
      -    sprintf(element, "group/%s", group);
      +
      +    if (snprintf(element, GNAME_MAX, "group/%s", group) >= GNAME_MAX) {
      +        G_warning(_("Group name <%s> is too long"), group);
      +        return 0;
      +    }
      +
           return G_find_file(element, "INIT_EXP", G_mapset()) != NULL;
       }
      diff --git a/imagery/i.pca/i.pca.html b/imagery/i.pca/i.pca.html
      index 17b3f5ed163..6fee184c618 100644
      --- a/imagery/i.pca/i.pca.html
      +++ b/imagery/i.pca/i.pca.html
      @@ -11,7 +11,7 @@ 

      DESCRIPTION

      principal component with the highest importance.

      -The current geographic region definition and MASK settings are +The current geographic region definition and raster mask settings are respected when reading the input raster map layers. When the rescale option is used, the output files are rescaled to fit the min,max range. diff --git a/imagery/i.pca/testsuite/test_pca.py b/imagery/i.pca/testsuite/test_pca.py index 8e9df84f2eb..f42fc6ddcc0 100644 --- a/imagery/i.pca/testsuite/test_pca.py +++ b/imagery/i.pca/testsuite/test_pca.py @@ -48,7 +48,7 @@ def test_pca_sample(self): cells=250325 datatype=CELL ncats=0 - comments=\"Eigen values, (vectors), and [percent importance]:PC1 4334.35 ( 0.2824, 0.3342, 0.5092,-0.0087, 0.5264, 0.5217) [83.04%]PC2 588.31 ( 0.2541, 0.1885, 0.2923,-0.7428,-0.5110,-0.0403) [11.27%]PC3 239.22 ( 0.3801, 0.3819, 0.2681, 0.6238,-0.4000,-0.2980) [ 4.58%]PC4 32.85 ( 0.1752,-0.0191,-0.4053, 0.1593,-0.4435, 0.7632) [ 0.63%]PC5 20.73 (-0.6170,-0.2514, 0.6059, 0.1734,-0.3235, 0.2330) [ 0.40%]PC6 4.08 (-0.5475, 0.8021,-0.2282,-0.0607,-0.0208, 0.0252) [ 0.08%]i.pca input=\"lsat7_2002_10,lsat7_2002_20,lsat7_2002_30,lsat7_2002_40\,lsat7_2002_50,lsat7_2002_70\" output=\"lsat7_2002_pca\" rescale=0,255 \percent=99" """ + comments=\"Eigen values, (vectors), and [percent importance]:PC1 4334.35 ( 0.2824, 0.3342, 0.5092,-0.0087, 0.5264, 0.5217) [83.04%]PC2 588.31 ( 0.2541, 0.1885, 0.2923,-0.7428,-0.5110,-0.0403) [11.27%]PC3 239.22 ( 0.3801, 0.3819, 0.2681, 0.6238,-0.4000,-0.2980) [ 4.58%]PC4 32.85 ( 0.1752,-0.0191,-0.4053, 0.1593,-0.4435, 0.7632) [ 0.63%]PC5 20.73 (-0.6170,-0.2514, 0.6059, 0.1734,-0.3235, 0.2330) [ 0.40%]PC6 4.08 (-0.5475, 0.8021,-0.2282,-0.0607,-0.0208, 0.0252) [ 0.08%]i.pca input=\"lsat7_2002_10,lsat7_2002_20,lsat7_2002_30,lsat7_2002_40\\,lsat7_2002_50,lsat7_2002_70\" output=\"lsat7_2002_pca\" rescale=0,255 \\percent=99" """ lsat7_2002_pca_univar_out = [ """n=250325 diff --git a/imagery/i.rectify/i.rectify.html b/imagery/i.rectify/i.rectify.html index 6451c8c9be9..7ef374b948e 100644 --- a/imagery/i.rectify/i.rectify.html +++ b/imagery/i.rectify/i.rectify.html @@ -11,8 +11,8 @@

      DESCRIPTION

      are first, second, and third order polynomial and thin plate spline. Thin plate spline is recommended for ungeoreferenced satellite imagery where ground control points (GCPs) are included. Examples are -NOAA/AVHRR -and ENVISAT +NOAA/AVHRR +and ENVISAT imagery which include throusands of GCPs.

      diff --git a/imagery/i.rectify/main.c b/imagery/i.rectify/main.c index 3bbe830e3cd..a740a07a0ae 100644 --- a/imagery/i.rectify/main.c +++ b/imagery/i.rectify/main.c @@ -26,6 +26,8 @@ #include #include "global.h" +#include + int seg_mb_img; func interpolate; @@ -151,8 +153,14 @@ int main(int argc, char *argv[]) interpolate = menu[method].method; G_strip(grp->answer); - strcpy(group.name, grp->answer); - strcpy(extension, ext->answer); + if (G_strlcpy(group.name, grp->answer, sizeof(group.name)) >= + sizeof(group.name)) { + G_fatal_error(_("Group name <%s> is too long"), grp->answer); + } + if (G_strlcpy(extension, ext->answer, sizeof(extension)) >= + sizeof(extension)) { + G_fatal_error(_("Extension <%s> is too long"), ext->answer); + } order = atoi(val->answer); seg_mb = NULL; diff --git a/imagery/i.segment/i.segment.html b/imagery/i.segment/i.segment.html index 1e2596c1d7e..43d5e5fde68 100644 --- a/imagery/i.segment/i.segment.html +++ b/imagery/i.segment/i.segment.html @@ -100,11 +100,11 @@

      Goodness of Fit

      Mean shift

      Mean shift image segmentation consists of 2 steps: anisotrophic filtering and 2. clustering. For anisotrophic filtering new cell values -are calculated from all pixels not farther than hs pixels away +are calculated from all pixels not farther than radius pixels away from the current pixel and with a spectral difference not larger than hr. That means that pixels that are too different from the current pixel are not considered in the calculation of new pixel values. -hs and hr are the spatial and spectral (range) bandwidths +radius and hr are the spatial and spectral (range) bandwidths for anisotrophic filtering. Cell values are iteratively recalculated (shifted to the segment's mean) until the maximum number of iterations is reached or until the largest shift is smaller than threshold. @@ -118,7 +118,7 @@

      Mean shift

      Boundary Constraints

      Boundary constraints limit the adjacency of pixels and segments. Each unique value present in the bounds raster are -considered as a MASK. Thus no segments in the final segmentated map +considered as a mask. Thus, no segments in the final segmented map will cross a boundary, even if their spectral data is very similar.

      Minimum Segment Size

      @@ -251,8 +251,6 @@

      Functionality

    Use of Segmentation Results

      -
    • Improve the optional output from this module, or better yet, add a -module for i.segment.metrics.
    • Providing updates to i.maxlik to ensure the segmentation output can be used as input for the existing classification functionality.
    • @@ -277,6 +275,9 @@

      REFERENCES

      SEE ALSO

      +i.segment.stats (addon), +i.segment.uspo (addon), +i.segment.hierarchical (addon) g.gui.iclass, i.group, i.maxlik, diff --git a/imagery/i.segment/iseg.h b/imagery/i.segment/iseg.h index 1e301d2cefa..a8dfb5542c3 100644 --- a/imagery/i.segment/iseg.h +++ b/imagery/i.segment/iseg.h @@ -118,7 +118,7 @@ struct globals { /* processing flags */ FLAG *candidate_flag, - *null_flag; /*TODO, need some way to remember MASK/NULL values. Was + *null_flag; /*TODO, need some way to remember mask/NULL values. Was using -1, 0, 1 in int array. Better to use 2 FLAG structures, better readability? */ diff --git a/imagery/i.segment/mean_shift.c b/imagery/i.segment/mean_shift.c index 833ff5ca8a8..1d838335352 100644 --- a/imagery/i.segment/mean_shift.c +++ b/imagery/i.segment/mean_shift.c @@ -179,8 +179,9 @@ int mean_shift(struct globals *globals) hspec = globals->hr; if (hspec < 0 || hspec >= 1) { - hspec = sqrt(avgdiffavg / 10.0); - hspec = avgdiffavg; + // Other ideas how to compute this are: + // sqrt(avgdiffavg / 10.0) + // avgdiffavg (as is) hspec = mindiffzeroavg; if (do_progressive) diff --git a/imagery/i.vi/evi2.c b/imagery/i.vi/evi2.c index c56ad2f62e0..502fba957ab 100644 --- a/imagery/i.vi/evi2.c +++ b/imagery/i.vi/evi2.c @@ -7,7 +7,7 @@ * 2-band enhanced vegetation index without a blue band and its application to * AVHRR data Proc. SPIE 6679, Remote Sensing and Modeling of Ecosystems for * Sustainability IV, 667905 (October 09, 2007) doi:10.1117/12.734933 - * http://dx.doi.org/10.1117/12.734933 + * https://doi.org/10.1117/12.734933 */ double e_vi2(double redchan, double nirchan) { diff --git a/imagery/i.vi/i.vi.html b/imagery/i.vi/i.vi.html index 7e600600678..3597dc5f500 100644 --- a/imagery/i.vi/i.vi.html +++ b/imagery/i.vi/i.vi.html @@ -134,7 +134,7 @@

      Vegetation Indices

      vegetation index without a blue band and its application to AVHRR data. Proc. SPIE 6679, Remote Sensing and Modeling of Ecosystems for Sustainability IV, 667905 (october 09, 2007) -doi:10.1117/12.734933). +doi:10.1117/12.734933).
       evi2( redchan, nirchan )
      @@ -150,7 +150,7 @@ 

      Vegetation Indices

      Gitelson, Anatoly A.; Kaufman, Yoram J.; Merzlyak, Mark N. (1996) Use of a green channel in remote sensing of global vegetation from EOS- MODIS, Remote Sensing of Environment 58 (3), 289-298. -doi:10.1016/s0034-4257(96)00072-7 +doi:10.1016/s0034-4257(96)00072-7
       gari( redchan, nirchan, bluechan, greenchan )
      @@ -508,7 +508,7 @@ 

      Preparation: DN to reflectance

      Calculation of reflectance values from DN using DOS1 (metadata obtained -from p016r035_7x20020524.met.gz): +from p016r035_7x20020524.met.gz):

      @@ -596,8 +596,8 @@ 

      REFERENCES

      densities and moisture indicators in composite terrain; a remote sensing approach under clear skies in mediterranean climates. PhD thesis, Wageningen Agricultural Univ., The Netherland, 271 pp. -(PDF) -
    • Index DataBase: List of available Indices
    • +(PDF) +
    • Index DataBase: List of available Indices

    SEE ALSO

    diff --git a/imagery/i.vi/testsuite/test_vi.py b/imagery/i.vi/testsuite/test_vi.py index 0c383417257..b2160f924ed 100644 --- a/imagery/i.vi/testsuite/test_vi.py +++ b/imagery/i.vi/testsuite/test_vi.py @@ -26,14 +26,12 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): - cls.runModule("g.remove", flags="f", type="raster", name="ipvi") - cls.runModule("g.remove", flags="f", type="raster", name="ndwi") - cls.runModule("g.remove", flags="f", type="raster", name="dvi") - cls.runModule("g.remove", flags="f", type="raster", name="sr") - cls.runModule("g.remove", flags="f", type="raster", name="evi") - cls.runModule("g.remove", flags="f", type="raster", name="evi2") - cls.runModule("g.remove", flags="f", type="raster", name="gari") - cls.runModule("g.remove", flags="f", type="raster", name="gemi") + cls.runModule( + "g.remove", + flags="f", + type="raster", + name="ipvi,ndwi,dvi,sr,evi,evi2,gari,gemi", + ) cls.del_temp_region() def test_vinameipvi(self): diff --git a/imagery/imageryintro.html b/imagery/imageryintro.html index 4b80951af9e..c0ef2a48616 100644 --- a/imagery/imageryintro.html +++ b/imagery/imageryintro.html @@ -2,6 +2,21 @@

    Image processing in general

    +GRASS GIS provides a powerful suite of tools for the processing and +analysis of geospatial raster data, including satellite imagery and +aerial photography. Its image processing capabilities encompass a broad +range of preprocessing operations, such as data import, georeferencing, +radiometric calibration, and atmospheric correction. It is particularly +suited for handling Earth observation data, enabling the analysis of +multispectral and temporal datasets. GRASS GIS supports advanced +functionalities such as image classification, sensor fusion, and point +cloud statistics. The calculation of vegetation indices further enables +analyses of environmental, agricultural, and land cover dynamics. An +extensive collection of +addons +further enhances its image processing capabilities, particularly in the +context of Earth observation and remote sensing applications. + Digital numbers and physical values (reflection/radiance-at-sensor):

    Satellite imagery is commonly stored in Digital Numbers (DN) for @@ -44,7 +59,7 @@

    Image processing in general

    using the DOS correction method. The more accurate way is using i.atcorr (which supports many satellite sensors). The atmospherically corrected sensor data represent -surface reflectance, +surface reflectance, which ranges theoretically from 0% to 100%. Note that this level of data correction is the proper level of correction to calculate vegetation indices. diff --git a/include/Make/Doxyfile_arch_html.in b/include/Make/Doxyfile_arch_html.in index 3f1e828494c..4c60088412a 100644 --- a/include/Make/Doxyfile_arch_html.in +++ b/include/Make/Doxyfile_arch_html.in @@ -18,7 +18,7 @@ # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. +# https://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 @@ -573,7 +573,7 @@ LAYOUT_FILE = # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# https://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. @@ -644,7 +644,7 @@ INPUT = . # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# into libc) for the transcoding. See https://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 @@ -851,7 +851,7 @@ REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# tagging system (see https://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO @@ -946,7 +946,7 @@ HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. +# see https://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. @@ -1337,7 +1337,7 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. +# https://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain diff --git a/include/Make/Doxyfile_arch_latex.in b/include/Make/Doxyfile_arch_latex.in index 1962073feec..25f6ac1592f 100644 --- a/include/Make/Doxyfile_arch_latex.in +++ b/include/Make/Doxyfile_arch_latex.in @@ -18,7 +18,7 @@ # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See -# http://www.gnu.org/software/libiconv for the list of possible encodings. +# https://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 @@ -573,7 +573,7 @@ LAYOUT_FILE = # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also -# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# https://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. @@ -644,7 +644,7 @@ INPUT = . # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built -# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# into libc) for the transcoding. See https://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 @@ -851,7 +851,7 @@ REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You +# tagging system (see https://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO @@ -946,7 +946,7 @@ HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, -# see http://en.wikipedia.org/wiki/Hue for more information. +# see https://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. @@ -1337,7 +1337,7 @@ LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See -# http://en.wikipedia.org/wiki/BibTeX for more info. +# https://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain diff --git a/include/Make/Platform.make.in b/include/Make/Platform.make.in index c65ed28c686..a66ddf801d3 100644 --- a/include/Make/Platform.make.in +++ b/include/Make/Platform.make.in @@ -203,12 +203,6 @@ PROJINC = @PROJINC@ PROJLIB = @PROJLIB@ PROJSHARE = @PROJSHARE@ -#OPENDWG: -OPENDWGINCPATH = @OPENDWGINCPATH@ -OPENDWGLIBPATH = @OPENDWGLIBPATH@ -OPENDWGLIB = @OPENDWGLIB@ -USE_OPENDWG = @USE_OPENDWG@ - #cairo CAIROINC = @CAIROINC@ CAIROLIB = @CAIROLIB@ diff --git a/include/grass/blas.h b/include/grass/blas.h deleted file mode 100644 index 2e7fe0a31f2..00000000000 --- a/include/grass/blas.h +++ /dev/null @@ -1,412 +0,0 @@ -#ifndef BLAS_WRAP_H -#define BLAS_WRAP_H - -extern int caxpy_(integer *n, complex *ca, complex *cx, integer *incx, - complex *cy, integer *incy); -extern int ccopy_(integer *n, complex *cx, integer *incx, complex *cy, - integer *incy); -extern C_f cdotc_(complex *ret_val, integer *n, complex *cx, integer *incx, - complex *cy, integer *incy); -extern C_f cdotu_(complex *ret_val, integer *n, complex *cx, integer *incx, - complex *cy, integer *incy); -extern int cgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, - complex *alpha, complex *a, integer *lda, complex *x, - integer *incx, complex *beta, complex *y, integer *incy, - ftnlen trans_len); -extern int cgemm_(char *transa, char *transb, integer *m, integer *n, - integer *k, complex *alpha, complex *a, integer *lda, - complex *b, integer *ldb, complex *beta, complex *c__, - integer *ldc, ftnlen transa_len, ftnlen transb_len); -extern int cgemv_(char *trans, integer *m, integer *n, complex *alpha, - complex *a, integer *lda, complex *x, integer *incx, - complex *beta, complex *y, integer *incy, ftnlen trans_len); -extern int cgerc_(integer *m, integer *n, complex *alpha, complex *x, - integer *incx, complex *y, integer *incy, complex *a, - integer *lda); -extern int cgeru_(integer *m, integer *n, complex *alpha, complex *x, - integer *incx, complex *y, integer *incy, complex *a, - integer *lda); -extern int chbmv_(char *uplo, integer *n, integer *k, complex *alpha, - complex *a, integer *lda, complex *x, integer *incx, - complex *beta, complex *y, integer *incy, ftnlen uplo_len); -extern int chemm_(char *side, char *uplo, integer *m, integer *n, - complex *alpha, complex *a, integer *lda, complex *b, - integer *ldb, complex *beta, complex *c__, integer *ldc, - ftnlen side_len, ftnlen uplo_len); -extern int chemv_(char *uplo, integer *n, complex *alpha, complex *a, - integer *lda, complex *x, integer *incx, complex *beta, - complex *y, integer *incy, ftnlen uplo_len); -extern int cher_(char *uplo, integer *n, real *alpha, complex *x, integer *incx, - complex *a, integer *lda, ftnlen uplo_len); -extern int cher2_(char *uplo, integer *n, complex *alpha, complex *x, - integer *incx, complex *y, integer *incy, complex *a, - integer *lda, ftnlen uplo_len); -extern int cher2k_(char *uplo, char *trans, integer *n, integer *k, - complex *alpha, complex *a, integer *lda, complex *b, - integer *ldb, real *beta, complex *c__, integer *ldc, - ftnlen uplo_len, ftnlen trans_len); -extern int cherk_(char *uplo, char *trans, integer *n, integer *k, real *alpha, - complex *a, integer *lda, real *beta, complex *c__, - integer *ldc, ftnlen uplo_len, ftnlen trans_len); -extern int chpmv_(char *uplo, integer *n, complex *alpha, complex *ap, - complex *x, integer *incx, complex *beta, complex *y, - integer *incy, ftnlen uplo_len); -extern int chpr_(char *uplo, integer *n, real *alpha, complex *x, integer *incx, - complex *ap, ftnlen uplo_len); -extern int chpr2_(char *uplo, integer *n, complex *alpha, complex *x, - integer *incx, complex *y, integer *incy, complex *ap, - ftnlen uplo_len); -extern int crotg_(complex *ca, complex *cb, real *c__, complex *s); -extern int cscal_(integer *n, complex *ca, complex *cx, integer *incx); -extern int csrot_(integer *n, complex *cx, integer *incx, complex *cy, - integer *incy, real *c__, real *s); -extern int csscal_(integer *n, real *sa, complex *cx, integer *incx); -extern int cswap_(integer *n, complex *cx, integer *incx, complex *cy, - integer *incy); -extern int csymm_(char *side, char *uplo, integer *m, integer *n, - complex *alpha, complex *a, integer *lda, complex *b, - integer *ldb, complex *beta, complex *c__, integer *ldc, - ftnlen side_len, ftnlen uplo_len); -extern int csyr2k_(char *uplo, char *trans, integer *n, integer *k, - complex *alpha, complex *a, integer *lda, complex *b, - integer *ldb, complex *beta, complex *c__, integer *ldc, - ftnlen uplo_len, ftnlen trans_len); -extern int csyrk_(char *uplo, char *trans, integer *n, integer *k, - complex *alpha, complex *a, integer *lda, complex *beta, - complex *c__, integer *ldc, ftnlen uplo_len, - ftnlen trans_len); -extern int ctbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - complex *a, integer *lda, complex *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ctbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - complex *a, integer *lda, complex *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ctpmv_(char *uplo, char *trans, char *diag, integer *n, complex *ap, - complex *x, integer *incx, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int ctpsv_(char *uplo, char *trans, char *diag, integer *n, complex *ap, - complex *x, integer *incx, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int ctrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, complex *alpha, complex *a, integer *lda, - complex *b, integer *ldb, ftnlen side_len, ftnlen uplo_len, - ftnlen transa_len, ftnlen diag_len); -extern int ctrmv_(char *uplo, char *trans, char *diag, integer *n, complex *a, - integer *lda, complex *x, integer *incx, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int ctrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, complex *alpha, complex *a, integer *lda, - complex *b, integer *ldb, ftnlen side_len, ftnlen uplo_len, - ftnlen transa_len, ftnlen diag_len); -extern int ctrsv_(char *uplo, char *trans, char *diag, integer *n, complex *a, - integer *lda, complex *x, integer *incx, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern doublereal dasum_(integer *n, doublereal *dx, integer *incx); -extern int daxpy_(integer *n, doublereal *da, doublereal *dx, integer *incx, - doublereal *dy, integer *incy); -extern doublereal dcabs1_(doublecomplex *z__); -extern int dcopy_(integer *n, doublereal *dx, integer *incx, doublereal *dy, - integer *incy); -extern doublereal ddot_(integer *n, doublereal *dx, integer *incx, - doublereal *dy, integer *incy); -extern int dgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, - doublereal *alpha, doublereal *a, integer *lda, doublereal *x, - integer *incx, doublereal *beta, doublereal *y, integer *incy, - ftnlen trans_len); -extern int dgemm_(char *transa, char *transb, integer *m, integer *n, - integer *k, doublereal *alpha, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *beta, - doublereal *c__, integer *ldc); -extern int dgemv_(char *trans, integer *m, integer *n, doublereal *alpha, - doublereal *a, integer *lda, doublereal *x, integer *incx, - doublereal *beta, doublereal *y, integer *incy, - ftnlen trans_len); -extern int dger_(integer *m, integer *n, doublereal *alpha, doublereal *x, - integer *incx, doublereal *y, integer *incy, doublereal *a, - integer *lda); -extern doublereal dnrm2_(integer *n, doublereal *x, integer *incx); -extern int drot_(integer *n, doublereal *dx, integer *incx, doublereal *dy, - integer *incy, doublereal *c__, doublereal *s); -extern int drotg_(doublereal *da, doublereal *db, doublereal *c__, - doublereal *s); -extern int drotm_(integer *n, doublereal *dx, integer *incx, doublereal *dy, - integer *incy, doublereal *dparam); -extern int drotmg_(doublereal *dd1, doublereal *dd2, doublereal *dx1, - doublereal *dy1, doublereal *dparam); -extern int dsbmv_(char *uplo, integer *n, integer *k, doublereal *alpha, - doublereal *a, integer *lda, doublereal *x, integer *incx, - doublereal *beta, doublereal *y, integer *incy, - ftnlen uplo_len); -extern int dscal_(integer *n, doublereal *da, doublereal *dx, integer *incx); -extern doublereal dsdot_(integer *n, real *sx, integer *incx, real *sy, - integer *incy); -extern int dspmv_(char *uplo, integer *n, doublereal *alpha, doublereal *ap, - doublereal *x, integer *incx, doublereal *beta, doublereal *y, - integer *incy, ftnlen uplo_len); -extern int dspr_(char *uplo, integer *n, doublereal *alpha, doublereal *x, - integer *incx, doublereal *ap, ftnlen uplo_len); -extern int dspr2_(char *uplo, integer *n, doublereal *alpha, doublereal *x, - integer *incx, doublereal *y, integer *incy, doublereal *ap, - ftnlen uplo_len); -extern int dswap_(integer *n, doublereal *dx, integer *incx, doublereal *dy, - integer *incy); -extern int dsymm_(char *side, char *uplo, integer *m, integer *n, - doublereal *alpha, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *beta, doublereal *c__, integer *ldc, - ftnlen side_len, ftnlen uplo_len); -extern int dsymv_(char *uplo, integer *n, doublereal *alpha, doublereal *a, - integer *lda, doublereal *x, integer *incx, doublereal *beta, - doublereal *y, integer *incy, ftnlen uplo_len); -extern int dsyr_(char *uplo, integer *n, doublereal *alpha, doublereal *x, - integer *incx, doublereal *a, integer *lda, ftnlen uplo_len); -extern int dsyr2_(char *uplo, integer *n, doublereal *alpha, doublereal *x, - integer *incx, doublereal *y, integer *incy, doublereal *a, - integer *lda, ftnlen uplo_len); -extern int dsyr2k_(char *uplo, char *trans, integer *n, integer *k, - doublereal *alpha, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *beta, - doublereal *c__, integer *ldc, ftnlen uplo_len, - ftnlen trans_len); -extern int dsyrk_(char *uplo, char *trans, integer *n, integer *k, - doublereal *alpha, doublereal *a, integer *lda, - doublereal *beta, doublereal *c__, integer *ldc, - ftnlen uplo_len, ftnlen trans_len); -extern int dtbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int dtbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int dtpmv_(char *uplo, char *trans, char *diag, integer *n, - doublereal *ap, doublereal *x, integer *incx, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int dtpsv_(char *uplo, char *trans, char *diag, integer *n, - doublereal *ap, doublereal *x, integer *incx, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int dtrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, doublereal *alpha, doublereal *a, integer *lda, - doublereal *b, integer *ldb, ftnlen side_len, ftnlen uplo_len, - ftnlen transa_len, ftnlen diag_len); -extern int dtrmv_(char *uplo, char *trans, char *diag, integer *n, - doublereal *a, integer *lda, doublereal *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int dtrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, doublereal *alpha, doublereal *a, integer *lda, - doublereal *b, integer *ldb, ftnlen side_len, ftnlen uplo_len, - ftnlen transa_len, ftnlen diag_len); -extern int dtrsv_(char *uplo, char *trans, char *diag, integer *n, - doublereal *a, integer *lda, doublereal *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern doublereal dzasum_(integer *n, doublecomplex *zx, integer *incx); -extern doublereal dznrm2_(integer *n, doublecomplex *x, integer *incx); -extern integer icamax_(integer *n, complex *cx, integer *incx); -extern integer idamax_(integer *n, doublereal *dx, integer *incx); -extern integer isamax_(integer *n, real *sx, integer *incx); -extern integer izamax_(integer *n, doublecomplex *zx, integer *incx); -extern logical lsame_(char *ca, char *cb, ftnlen ca_len, ftnlen cb_len); -extern E_f sasum_(integer *n, real *sx, integer *incx); -extern int saxpy_(integer *n, real *sa, real *sx, integer *incx, real *sy, - integer *incy); -extern E_f scasum_(integer *n, complex *cx, integer *incx); -extern E_f scnrm2_(integer *n, complex *x, integer *incx); -extern int scopy_(integer *n, real *sx, integer *incx, real *sy, integer *incy); -extern E_f sdot_(integer *n, real *sx, integer *incx, real *sy, integer *incy); -extern E_f sdsdot_(integer *n, real *sb, real *sx, integer *incx, real *sy, - integer *incy); -extern int sgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, - real *alpha, real *a, integer *lda, real *x, integer *incx, - real *beta, real *y, integer *incy, ftnlen trans_len); -extern int sgemm_(char *transa, char *transb, integer *m, integer *n, - integer *k, real *alpha, real *a, integer *lda, real *b, - integer *ldb, real *beta, real *c__, integer *ldc, - ftnlen transa_len, ftnlen transb_len); -extern int sgemv_(char *trans, integer *m, integer *n, real *alpha, real *a, - integer *lda, real *x, integer *incx, real *beta, real *y, - integer *incy, ftnlen trans_len); -extern int sger_(integer *m, integer *n, real *alpha, real *x, integer *incx, - real *y, integer *incy, real *a, integer *lda); -extern E_f snrm2_(integer *n, real *x, integer *incx); -extern int srot_(integer *n, real *sx, integer *incx, real *sy, integer *incy, - real *c__, real *s); -extern int srotg_(real *sa, real *sb, real *c__, real *s); -extern int srotm_(integer *n, real *sx, integer *incx, real *sy, integer *incy, - real *sparam); -extern int srotmg_(real *sd1, real *sd2, real *sx1, real *sy1, real *sparam); -extern int ssbmv_(char *uplo, integer *n, integer *k, real *alpha, real *a, - integer *lda, real *x, integer *incx, real *beta, real *y, - integer *incy, ftnlen uplo_len); -extern int sscal_(integer *n, real *sa, real *sx, integer *incx); -extern int sspmv_(char *uplo, integer *n, real *alpha, real *ap, real *x, - integer *incx, real *beta, real *y, integer *incy, - ftnlen uplo_len); -extern int sspr_(char *uplo, integer *n, real *alpha, real *x, integer *incx, - real *ap, ftnlen uplo_len); -extern int sspr2_(char *uplo, integer *n, real *alpha, real *x, integer *incx, - real *y, integer *incy, real *ap, ftnlen uplo_len); -extern int sswap_(integer *n, real *sx, integer *incx, real *sy, integer *incy); -extern int ssymm_(char *side, char *uplo, integer *m, integer *n, real *alpha, - real *a, integer *lda, real *b, integer *ldb, real *beta, - real *c__, integer *ldc, ftnlen side_len, ftnlen uplo_len); -extern int ssymv_(char *uplo, integer *n, real *alpha, real *a, integer *lda, - real *x, integer *incx, real *beta, real *y, integer *incy, - ftnlen uplo_len); -extern int ssyr_(char *uplo, integer *n, real *alpha, real *x, integer *incx, - real *a, integer *lda, ftnlen uplo_len); -extern int ssyr2_(char *uplo, integer *n, real *alpha, real *x, integer *incx, - real *y, integer *incy, real *a, integer *lda, - ftnlen uplo_len); -extern int ssyr2k_(char *uplo, char *trans, integer *n, integer *k, real *alpha, - real *a, integer *lda, real *b, integer *ldb, real *beta, - real *c__, integer *ldc, ftnlen uplo_len, ftnlen trans_len); -extern int ssyrk_(char *uplo, char *trans, integer *n, integer *k, real *alpha, - real *a, integer *lda, real *beta, real *c__, integer *ldc, - ftnlen uplo_len, ftnlen trans_len); -extern int stbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - real *a, integer *lda, real *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int stbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - real *a, integer *lda, real *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int stpmv_(char *uplo, char *trans, char *diag, integer *n, real *ap, - real *x, integer *incx, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int stpsv_(char *uplo, char *trans, char *diag, integer *n, real *ap, - real *x, integer *incx, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int strmm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, real *alpha, real *a, integer *lda, real *b, - integer *ldb, ftnlen side_len, ftnlen uplo_len, - ftnlen transa_len, ftnlen diag_len); -extern int strmv_(char *uplo, char *trans, char *diag, integer *n, real *a, - integer *lda, real *x, integer *incx, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int strsm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, real *alpha, real *a, integer *lda, real *b, - integer *ldb, ftnlen side_len, ftnlen uplo_len, - ftnlen transa_len, ftnlen diag_len); -extern int strsv_(char *uplo, char *trans, char *diag, integer *n, real *a, - integer *lda, real *x, integer *incx, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int xerbla_(char *srname, integer *info, ftnlen srname_len); -extern int zaxpy_(integer *n, doublecomplex *za, doublecomplex *zx, - integer *incx, doublecomplex *zy, integer *incy); -extern int zcopy_(integer *n, doublecomplex *zx, integer *incx, - doublecomplex *zy, integer *incy); -extern Z_f zdotc_(doublecomplex *ret_val, integer *n, doublecomplex *zx, - integer *incx, doublecomplex *zy, integer *incy); -extern Z_f zdotu_(doublecomplex *ret_val, integer *n, doublecomplex *zx, - integer *incx, doublecomplex *zy, integer *incy); -extern int zdrot_(integer *n, doublecomplex *zx, integer *incx, - doublecomplex *zy, integer *incy, doublereal *c__, - doublereal *s); -extern int zdscal_(integer *n, doublereal *da, doublecomplex *zx, - integer *incx); -extern int zgbmv_(char *trans, integer *m, integer *n, integer *kl, integer *ku, - doublecomplex *alpha, doublecomplex *a, integer *lda, - doublecomplex *x, integer *incx, doublecomplex *beta, - doublecomplex *y, integer *incy, ftnlen trans_len); -extern int zgemm_(char *transa, char *transb, integer *m, integer *n, - integer *k, doublecomplex *alpha, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *beta, doublecomplex *c__, integer *ldc, - ftnlen transa_len, ftnlen transb_len); -extern int zgemv_(char *trans, integer *m, integer *n, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, doublecomplex *beta, doublecomplex *y, - integer *incy, ftnlen trans_len); -extern int zgerc_(integer *m, integer *n, doublecomplex *alpha, - doublecomplex *x, integer *incx, doublecomplex *y, - integer *incy, doublecomplex *a, integer *lda); -extern int zgeru_(integer *m, integer *n, doublecomplex *alpha, - doublecomplex *x, integer *incx, doublecomplex *y, - integer *incy, doublecomplex *a, integer *lda); -extern int zhbmv_(char *uplo, integer *n, integer *k, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, doublecomplex *beta, doublecomplex *y, - integer *incy, ftnlen uplo_len); -extern int zhemm_(char *side, char *uplo, integer *m, integer *n, - doublecomplex *alpha, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *beta, - doublecomplex *c__, integer *ldc, ftnlen side_len, - ftnlen uplo_len); -extern int zhemv_(char *uplo, integer *n, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, doublecomplex *beta, doublecomplex *y, - integer *incy, ftnlen uplo_len); -extern int zher_(char *uplo, integer *n, doublereal *alpha, doublecomplex *x, - integer *incx, doublecomplex *a, integer *lda, - ftnlen uplo_len); -extern int zher2_(char *uplo, integer *n, doublecomplex *alpha, - doublecomplex *x, integer *incx, doublecomplex *y, - integer *incy, doublecomplex *a, integer *lda, - ftnlen uplo_len); -extern int zher2k_(char *uplo, char *trans, integer *n, integer *k, - doublecomplex *alpha, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublereal *beta, - doublecomplex *c__, integer *ldc, ftnlen uplo_len, - ftnlen trans_len); -extern int zherk_(char *uplo, char *trans, integer *n, integer *k, - doublereal *alpha, doublecomplex *a, integer *lda, - doublereal *beta, doublecomplex *c__, integer *ldc, - ftnlen uplo_len, ftnlen trans_len); -extern int zhpmv_(char *uplo, integer *n, doublecomplex *alpha, - doublecomplex *ap, doublecomplex *x, integer *incx, - doublecomplex *beta, doublecomplex *y, integer *incy, - ftnlen uplo_len); -extern int zhpr_(char *uplo, integer *n, doublereal *alpha, doublecomplex *x, - integer *incx, doublecomplex *ap, ftnlen uplo_len); -extern int zhpr2_(char *uplo, integer *n, doublecomplex *alpha, - doublecomplex *x, integer *incx, doublecomplex *y, - integer *incy, doublecomplex *ap, ftnlen uplo_len); -extern int zrotg_(doublecomplex *ca, doublecomplex *cb, doublereal *c__, - doublecomplex *s); -extern int zscal_(integer *n, doublecomplex *za, doublecomplex *zx, - integer *incx); -extern int zswap_(integer *n, doublecomplex *zx, integer *incx, - doublecomplex *zy, integer *incy); -extern int zsymm_(char *side, char *uplo, integer *m, integer *n, - doublecomplex *alpha, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *beta, - doublecomplex *c__, integer *ldc, ftnlen side_len, - ftnlen uplo_len); -extern int zsyr2k_(char *uplo, char *trans, integer *n, integer *k, - doublecomplex *alpha, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *beta, - doublecomplex *c__, integer *ldc, ftnlen uplo_len, - ftnlen trans_len); -extern int zsyrk_(char *uplo, char *trans, integer *n, integer *k, - doublecomplex *alpha, doublecomplex *a, integer *lda, - doublecomplex *beta, doublecomplex *c__, integer *ldc, - ftnlen uplo_len, ftnlen trans_len); -extern int ztbmv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int ztbsv_(char *uplo, char *trans, char *diag, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int ztpmv_(char *uplo, char *trans, char *diag, integer *n, - doublecomplex *ap, doublecomplex *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ztpsv_(char *uplo, char *trans, char *diag, integer *n, - doublecomplex *ap, doublecomplex *x, integer *incx, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ztrmm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, doublecomplex *alpha, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, ftnlen side_len, - ftnlen uplo_len, ftnlen transa_len, ftnlen diag_len); -extern int ztrmv_(char *uplo, char *trans, char *diag, integer *n, - doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int ztrsm_(char *side, char *uplo, char *transa, char *diag, integer *m, - integer *n, doublecomplex *alpha, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, ftnlen side_len, - ftnlen uplo_len, ftnlen transa_len, ftnlen diag_len); -extern int ztrsv_(char *uplo, char *trans, char *diag, integer *n, - doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); - -#endif diff --git a/include/grass/config.h.in b/include/grass/config.h.in index f070b4ccc0d..2451d8cc2b8 100644 --- a/include/grass/config.h.in +++ b/include/grass/config.h.in @@ -14,21 +14,18 @@ /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF -/* Define to 1 if you have the `strlcpy' function. */ -#undef HAVE_STRLCPY - /* Define to 1 if you have the header file. */ #undef HAVE_BZLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_CAIRO_H +/* Define to 1 if you have the header file. */ +#undef HAVE_CBLAS_ATLAS_H + /* Define to 1 if you have the header file. */ #undef HAVE_CBLAS_H -/* Define to 1 if you have the header file. */ -#undef HAVE_CLAPACK_H - /* Define to 1 if you have the header file. */ #undef HAVE_CL_CL_H @@ -38,9 +35,6 @@ /* Define to 1 if you have the `drand48' function. */ #undef HAVE_DRAND48 -/* Define to 1 if you have the header file. */ -#undef HAVE_F2C_H - /* Define to 1 if you have the header file. */ #undef HAVE_FFTW3_H @@ -56,9 +50,6 @@ /* Define to 1 if you have the `ftime' function. */ #undef HAVE_FTIME -/* Define to 1 if you have the header file. */ -#undef HAVE_G2C_H - /* Define to 1 if GDAL is to be used. */ #undef HAVE_GDAL @@ -92,8 +83,8 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LANGINFO_H -/* Define to 1 if ATLAS exists. */ -#undef HAVE_LIBATLAS +/* Define to 1 if you have the header file. */ +#undef HAVE_LAPACKE_H /* Define to 1 if BLAS exists. */ #undef HAVE_LIBBLAS @@ -239,6 +230,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if you have the `strlcat' function. */ +#undef HAVE_STRLCAT + +/* Define to 1 if you have the `strlcpy' function. */ +#undef HAVE_STRLCPY + /* Define to 1 if you have the header file. */ #undef HAVE_SVM_H diff --git a/include/grass/defs/dbmi.h b/include/grass/defs/dbmi.h index c5bf648414f..5af0476849d 100644 --- a/include/grass/defs/dbmi.h +++ b/include/grass/defs/dbmi.h @@ -386,10 +386,12 @@ const char *db_whoami(void); void db_zero(void *, int); void db_zero_string(dbString *); unsigned int db_sizeof_string(const dbString *); -int db_set_login(const char *, const char *, const char *, const char *); +int db_set_login(const char *, const char *, const char *, const char *, + const char *, const char *, int); int db_set_login2(const char *, const char *, const char *, const char *, const char *, const char *, int); -int db_get_login(const char *, const char *, const char **, const char **); +int db_get_login(const char *, const char *, const char **, const char **, + const char **, const char **); int db_get_login2(const char *, const char *, const char **, const char **, const char **, const char **); int db_get_login_dump(FILE *); diff --git a/include/grass/defs/gis.h b/include/grass/defs/gis.h index 4125a3aeed3..dc5ad2499f0 100644 --- a/include/grass/defs/gis.h +++ b/include/grass/defs/gis.h @@ -152,6 +152,9 @@ int G_vfaprintf(FILE *, const char *, va_list); int G_vsaprintf(char *, const char *, va_list); int G_vsnaprintf(char *, size_t, const char *, va_list); +/* strlcat.c */ +size_t G_strlcat(char *, const char *, size_t); + /* strlcpy.c */ size_t G_strlcpy(char *, const char *, size_t); diff --git a/include/grass/defs/gprojects.h b/include/grass/defs/gprojects.h index 7ab5e47ddd6..e96200c1480 100644 --- a/include/grass/defs/gprojects.h +++ b/include/grass/defs/gprojects.h @@ -65,7 +65,7 @@ void GPJ_free_ellps(struct gpj_ellps *); #ifndef HAVE_PROJ_H /* PROJ.4's private datastructures copied from projects.h as removed from upstream; pending better solution. see: - http://trac.osgeo.org/proj/ticket/98 */ + https://trac.osgeo.org/proj/ticket/98 */ int pj_factors(LP, void *, double, struct FACTORS *); diff --git a/include/grass/defs/raster.h b/include/grass/defs/raster.h index 7244da2a354..bbdc8bfeaa1 100644 --- a/include/grass/defs/raster.h +++ b/include/grass/defs/raster.h @@ -392,7 +392,10 @@ int Rast_option_to_interp_type(const struct Option *); /* mask_info.c */ char *Rast_mask_info(void); +char *Rast_mask_name(void); +bool Rast_mask_status(char *, char *, bool *, char *, char *); int Rast__mask_info(char *, char *); +bool Rast_mask_is_present(void); /* maskfd.c */ int Rast_maskfd(void); diff --git a/include/grass/gprojects.h b/include/grass/gprojects.h index 7872d6cb4b6..35f795d87ad 100644 --- a/include/grass/gprojects.h +++ b/include/grass/gprojects.h @@ -112,7 +112,7 @@ struct gpj_ellps { #ifndef HAVE_PROJ_H /* PROJ.4's private datastructures copied from projects.h as removed from upstream; pending better solution. see: - http://trac.osgeo.org/proj/ticket/98 */ + https://trac.osgeo.org/proj/ticket/98 */ /* In PROJ 5, the 'struct FACTORS' is back in as 'struct P5_FACTORS', * and old 'struct LP' is now back in as 'PJ_UV' */ diff --git a/include/grass/iostream/replacementHeap.h b/include/grass/iostream/replacementHeap.h index 485d4cef99b..30c309cdda2 100644 --- a/include/grass/iostream/replacementHeap.h +++ b/include/grass/iostream/replacementHeap.h @@ -101,10 +101,10 @@ class ReplacementHeap { public: // allocate array mergeHeap and the runs in runList - ReplacementHeap(size_t arity, queue *runList); + ReplacementHeap(size_t arity, queue *runList); // delete array mergeHeap - ~ReplacementHeap(); + ~ReplacementHeap(); // is heap empty? int empty() const { return (size == 0); } @@ -159,7 +159,7 @@ ReplacementHeap::ReplacementHeap(size_t g_arity, /*****************************************************************/ template -ReplacementHeap::~ReplacementHeap() +ReplacementHeap::~ReplacementHeap() { if (!empty()) { diff --git a/include/grass/iostream/replacementHeapBlock.h b/include/grass/iostream/replacementHeapBlock.h index c1596d67585..f4614eb838b 100644 --- a/include/grass/iostream/replacementHeapBlock.h +++ b/include/grass/iostream/replacementHeapBlock.h @@ -102,10 +102,10 @@ class ReplacementHeapBlock { public: // allocate array mergeHeap, where the streams are stored in runList - ReplacementHeapBlock(queue *> *runList); + ReplacementHeapBlock(queue *> *runList); // delete array mergeHeap - ~ReplacementHeapBlock(); + ~ReplacementHeapBlock(); // is heap empty? int empty() const { return (size == 0); } @@ -161,7 +161,7 @@ ReplacementHeapBlock::ReplacementHeapBlock( /*****************************************************************/ template -ReplacementHeapBlock::~ReplacementHeapBlock() +ReplacementHeapBlock::~ReplacementHeapBlock() { if (!empty()) { diff --git a/include/grass/la.h b/include/grass/la.h index 2981dc3401e..edec847c8e1 100644 --- a/include/grass/la.h +++ b/include/grass/la.h @@ -23,93 +23,9 @@ #ifndef GRASS_LA_H #define GRASS_LA_H -/* QUESTION: On some systems there appears to be no default link - to this. Do we create a symlink to - /usr/lib/gcc-lib///include/g2c.h - - or link to any old f2c.h that happens to hanging around? - - A job for autoconf - - [Also a consideration for -lg2c] - */ - #include #include -#ifdef HAVE_G2C_H -typedef int __g77_integer; -typedef unsigned int __g77_uinteger; -typedef long int __g77_longint; -typedef unsigned long int __g77_ulongint; - -#include -#else /* for gcc4+ */ -typedef int integer; -typedef unsigned int uinteger; -typedef char *address; -typedef short shortint; -typedef float real; -typedef double doublereal; -typedef struct { - real r, i; -} complex; -typedef struct { - doublereal r, i; -} doublecomplex; -typedef int logical; -typedef short shortlogical; -typedef char logical1; -typedef char integer1; -typedef long longint; -typedef unsigned long ulongint; - -/* IO stuff */ -typedef int ftnlen; - -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wstrict-prototypes" -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstrict-prototypes" -#endif - -/* procedure parameter types for -A */ -typedef int (*U_fp)(); -typedef shortint (*J_fp)(); -typedef integer (*I_fp)(); -typedef real (*R_fp)(); -typedef doublereal (*D_fp)(), (*E_fp)(); -typedef void (*C_fp)(); -typedef void (*Z_fp)(); -typedef logical (*L_fp)(); -typedef shortlogical (*K_fp)(); -typedef void (*H_fp)(); -typedef int (*S_fp)(); - -#if defined(__clang__) -#pragma clang diagnostic pop -#elif defined(__GNUC__) -#pragma GCC diagnostic pop -#endif - -/* E_fp is for real functions when -R is not specified */ -typedef void C_f; /* complex function */ -typedef void H_f; /* character function */ -typedef void Z_f; /* double complex function */ -typedef doublereal E_f; /* real function with -R not specified */ -#endif /* HAVE_G2C_H */ - -/* The following may have to be selectively installed according - to platform, at least partly - */ - -#if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) -#include -#include -#endif - /* Useful defines */ #define MAX_POS 1 /* Indicates maximum value */ @@ -117,17 +33,7 @@ typedef doublereal E_f; /* real function with -R not specified */ #define MAX_ABS 0 /* Indicates absolute value */ #define DO_COMPACT 0 /* Eliminate unnecessary rows (cols) in matrix */ -#define NO_COMPACT 1 /* ... or not */ - -/* define macros for fortran symbols (called directly). Needed because - of platform invariance on fortran->C symbol translations - */ - -#if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) -#define f77_dgesv dgesv_ -#define f77_dgemm dgemm_ -#define f77_dnrm2 dnrm2_ -#endif +#define NO_COMPACT 1 /* ... or not */ /* Operations should know type of coefficient matrix, so that they can call the right driver @@ -146,16 +52,16 @@ typedef enum { RVEC, CVEC } vtype; typedef struct matrix_ { - mat_spec type; /* matrix, row vector or column vector? */ - int v_indx; /* If a vector, which row(column) is active? - * If a matrix this is ignored. If value is < 0, - * the first row(column) is assumed, ie. index 0. */ - int rows, cols; /* Rows and columns of matrix */ - int ldim; /* Lead dimension of matrix. How many `rows' are - * alloc'ed? May exceed real number of rows `rows' */ - doublereal *vals; /* The values (should be dimensioned to lda * cols */ - int is_init; /* Is matrix initialised: values array - * is allocated and parameters set ? */ + mat_spec type; /* matrix, row vector or column vector? */ + int v_indx; /* If a vector, which row(column) is active? + * If a matrix this is ignored. If value is < 0, + * the first row(column) is assumed, ie. index 0. */ + int rows, cols; /* Rows and columns of matrix */ + int ldim; /* Lead dimension of matrix. How many `rows' are + * alloc'ed? May exceed real number of rows `rows' */ + double *vals; /* The values (should be dimensioned to lda * cols */ + int is_init; /* Is matrix initialised: values array + * is allocated and parameters set ? */ } mat_struct; typedef mat_struct vec_struct; diff --git a/include/grass/lapack.h b/include/grass/lapack.h deleted file mode 100644 index 2763404ae8c..00000000000 --- a/include/grass/lapack.h +++ /dev/null @@ -1,4748 +0,0 @@ -#ifndef LAPACK_WRAP_ -#define LAPACK_WRAP_ - -extern int cbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, - integer *ncc, real *d__, real *e, complex *vt, integer *ldvt, - complex *u, integer *ldu, complex *c__, integer *ldc, - real *rwork, integer *info, ftnlen uplo_len); -extern int cgbbrd_(char *vect, integer *m, integer *n, integer *ncc, - integer *kl, integer *ku, complex *ab, integer *ldab, - real *d__, real *e, complex *q, integer *ldq, complex *pt, - integer *ldpt, complex *c__, integer *ldc, complex *work, - real *rwork, integer *info, ftnlen vect_len); -extern int cgbcon_(char *norm, integer *n, integer *kl, integer *ku, - complex *ab, integer *ldab, integer *ipiv, real *anorm, - real *rcond, complex *work, real *rwork, integer *info, - ftnlen norm_len); -extern int cgbequ_(integer *m, integer *n, integer *kl, integer *ku, - complex *ab, integer *ldab, real *r__, real *c__, - real *rowcnd, real *colcnd, real *amax, integer *info); -extern int cgbrfs_(char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, complex *ab, integer *ldab, complex *afb, - integer *ldafb, integer *ipiv, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, - complex *work, real *rwork, integer *info, ftnlen trans_len); -extern int cgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, - complex *ab, integer *ldab, integer *ipiv, complex *b, - integer *ldb, integer *info); -extern int cgbsvx_(char *fact, char *trans, integer *n, integer *kl, - integer *ku, integer *nrhs, complex *ab, integer *ldab, - complex *afb, integer *ldafb, integer *ipiv, char *equed, - real *r__, real *c__, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, - complex *work, real *rwork, integer *info, ftnlen fact_len, - ftnlen trans_len, ftnlen equed_len); -extern int cgbtf2_(integer *m, integer *n, integer *kl, integer *ku, - complex *ab, integer *ldab, integer *ipiv, integer *info); -extern int cgbtrf_(integer *m, integer *n, integer *kl, integer *ku, - complex *ab, integer *ldab, integer *ipiv, integer *info); -extern int cgbtrs_(char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, complex *ab, integer *ldab, integer *ipiv, - complex *b, integer *ldb, integer *info, ftnlen trans_len); -extern int cgebak_(char *job, char *side, integer *n, integer *ilo, - integer *ihi, real *scale, integer *m, complex *v, - integer *ldv, integer *info, ftnlen job_len, - ftnlen side_len); -extern int cgebal_(char *job, integer *n, complex *a, integer *lda, - integer *ilo, integer *ihi, real *scale, integer *info, - ftnlen job_len); -extern int cgebd2_(integer *m, integer *n, complex *a, integer *lda, real *d__, - real *e, complex *tauq, complex *taup, complex *work, - integer *info); -extern int cgebrd_(integer *m, integer *n, complex *a, integer *lda, real *d__, - real *e, complex *tauq, complex *taup, complex *work, - integer *lwork, integer *info); -extern int cgecon_(char *norm, integer *n, complex *a, integer *lda, - real *anorm, real *rcond, complex *work, real *rwork, - integer *info, ftnlen norm_len); -extern int cgeequ_(integer *m, integer *n, complex *a, integer *lda, real *r__, - real *c__, real *rowcnd, real *colcnd, real *amax, - integer *info); -extern int cgees_(char *jobvs, char *sort, L_fp select, integer *n, complex *a, - integer *lda, integer *sdim, complex *w, complex *vs, - integer *ldvs, complex *work, integer *lwork, real *rwork, - logical *bwork, integer *info, ftnlen jobvs_len, - ftnlen sort_len); -extern int cgeesx_(char *jobvs, char *sort, L_fp select, char *sense, - integer *n, complex *a, integer *lda, integer *sdim, - complex *w, complex *vs, integer *ldvs, real *rconde, - real *rcondv, complex *work, integer *lwork, real *rwork, - logical *bwork, integer *info, ftnlen jobvs_len, - ftnlen sort_len, ftnlen sense_len); -extern int cgeev_(char *jobvl, char *jobvr, integer *n, complex *a, - integer *lda, complex *w, complex *vl, integer *ldvl, - complex *vr, integer *ldvr, complex *work, integer *lwork, - real *rwork, integer *info, ftnlen jobvl_len, - ftnlen jobvr_len); -extern int cgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, - integer *n, complex *a, integer *lda, complex *w, - complex *vl, integer *ldvl, complex *vr, integer *ldvr, - integer *ilo, integer *ihi, real *scale, real *abnrm, - real *rconde, real *rcondv, complex *work, integer *lwork, - real *rwork, integer *info, ftnlen balanc_len, - ftnlen jobvl_len, ftnlen jobvr_len, ftnlen sense_len); -extern int cgegs_(char *jobvsl, char *jobvsr, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, complex *alpha, - complex *beta, complex *vsl, integer *ldvsl, complex *vsr, - integer *ldvsr, complex *work, integer *lwork, real *rwork, - integer *info, ftnlen jobvsl_len, ftnlen jobvsr_len); -extern int cgegv_(char *jobvl, char *jobvr, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, complex *alpha, - complex *beta, complex *vl, integer *ldvl, complex *vr, - integer *ldvr, complex *work, integer *lwork, real *rwork, - integer *info, ftnlen jobvl_len, ftnlen jobvr_len); -extern int cgehd2_(integer *n, integer *ilo, integer *ihi, complex *a, - integer *lda, complex *tau, complex *work, integer *info); -extern int cgehrd_(integer *n, integer *ilo, integer *ihi, complex *a, - integer *lda, complex *tau, complex *work, integer *lwork, - integer *info); -extern int cgelq2_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *info); -extern int cgelqf_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cgels_(char *trans, integer *m, integer *n, integer *nrhs, - complex *a, integer *lda, complex *b, integer *ldb, - complex *work, integer *lwork, integer *info, - ftnlen trans_len); -extern int cgelsd_(integer *m, integer *n, integer *nrhs, complex *a, - integer *lda, complex *b, integer *ldb, real *s, real *rcond, - integer *rank, complex *work, integer *lwork, real *rwork, - integer *iwork, integer *info); -extern int cgelss_(integer *m, integer *n, integer *nrhs, complex *a, - integer *lda, complex *b, integer *ldb, real *s, real *rcond, - integer *rank, complex *work, integer *lwork, real *rwork, - integer *info); -extern int cgelsx_(integer *m, integer *n, integer *nrhs, complex *a, - integer *lda, complex *b, integer *ldb, integer *jpvt, - real *rcond, integer *rank, complex *work, real *rwork, - integer *info); -extern int cgelsy_(integer *m, integer *n, integer *nrhs, complex *a, - integer *lda, complex *b, integer *ldb, integer *jpvt, - real *rcond, integer *rank, complex *work, integer *lwork, - real *rwork, integer *info); -extern int cgeql2_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *info); -extern int cgeqlf_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cgeqp3_(integer *m, integer *n, complex *a, integer *lda, - integer *jpvt, complex *tau, complex *work, integer *lwork, - real *rwork, integer *info); -extern int cgeqpf_(integer *m, integer *n, complex *a, integer *lda, - integer *jpvt, complex *tau, complex *work, real *rwork, - integer *info); -extern int cgeqr2_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *info); -extern int cgeqrf_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cgerfs_(char *trans, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, - complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen trans_len); -extern int cgerq2_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *info); -extern int cgerqf_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cgesc2_(integer *n, complex *a, integer *lda, complex *rhs, - integer *ipiv, integer *jpiv, real *scale); -extern int cgesdd_(char *jobz, integer *m, integer *n, complex *a, integer *lda, - real *s, complex *u, integer *ldu, complex *vt, - integer *ldvt, complex *work, integer *lwork, real *rwork, - integer *iwork, integer *info, ftnlen jobz_len); -extern int cgesv_(integer *n, integer *nrhs, complex *a, integer *lda, - integer *ipiv, complex *b, integer *ldb, integer *info); -extern int cgesvd_(char *jobu, char *jobvt, integer *m, integer *n, complex *a, - integer *lda, real *s, complex *u, integer *ldu, complex *vt, - integer *ldvt, complex *work, integer *lwork, real *rwork, - integer *info, ftnlen jobu_len, ftnlen jobvt_len); -extern int cgesvx_(char *fact, char *trans, integer *n, integer *nrhs, - complex *a, integer *lda, complex *af, integer *ldaf, - integer *ipiv, char *equed, real *r__, real *c__, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen fact_len, ftnlen trans_len, - ftnlen equed_len); -extern int cgetc2_(integer *n, complex *a, integer *lda, integer *ipiv, - integer *jpiv, integer *info); -extern int cgetf2_(integer *m, integer *n, complex *a, integer *lda, - integer *ipiv, integer *info); -extern int cgetrf_(integer *m, integer *n, complex *a, integer *lda, - integer *ipiv, integer *info); -extern int cgetri_(integer *n, complex *a, integer *lda, integer *ipiv, - complex *work, integer *lwork, integer *info); -extern int cgetrs_(char *trans, integer *n, integer *nrhs, complex *a, - integer *lda, integer *ipiv, complex *b, integer *ldb, - integer *info, ftnlen trans_len); -extern int cggbak_(char *job, char *side, integer *n, integer *ilo, - integer *ihi, real *lscale, real *rscale, integer *m, - complex *v, integer *ldv, integer *info, ftnlen job_len, - ftnlen side_len); -extern int cggbal_(char *job, integer *n, complex *a, integer *lda, complex *b, - integer *ldb, integer *ilo, integer *ihi, real *lscale, - real *rscale, real *work, integer *info, ftnlen job_len); -extern int cgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, - integer *n, complex *a, integer *lda, complex *b, - integer *ldb, integer *sdim, complex *alpha, complex *beta, - complex *vsl, integer *ldvsl, complex *vsr, integer *ldvsr, - complex *work, integer *lwork, real *rwork, logical *bwork, - integer *info, ftnlen jobvsl_len, ftnlen jobvsr_len, - ftnlen sort_len); -extern int cggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, - char *sense, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, integer *sdim, complex *alpha, - complex *beta, complex *vsl, integer *ldvsl, complex *vsr, - integer *ldvsr, real *rconde, real *rcondv, complex *work, - integer *lwork, real *rwork, integer *iwork, integer *liwork, - logical *bwork, integer *info, ftnlen jobvsl_len, - ftnlen jobvsr_len, ftnlen sort_len, ftnlen sense_len); -extern int cggev_(char *jobvl, char *jobvr, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, complex *alpha, - complex *beta, complex *vl, integer *ldvl, complex *vr, - integer *ldvr, complex *work, integer *lwork, real *rwork, - integer *info, ftnlen jobvl_len, ftnlen jobvr_len); -extern int cggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, - integer *n, complex *a, integer *lda, complex *b, - integer *ldb, complex *alpha, complex *beta, complex *vl, - integer *ldvl, complex *vr, integer *ldvr, integer *ilo, - integer *ihi, real *lscale, real *rscale, real *abnrm, - real *bbnrm, real *rconde, real *rcondv, complex *work, - integer *lwork, real *rwork, integer *iwork, logical *bwork, - integer *info, ftnlen balanc_len, ftnlen jobvl_len, - ftnlen jobvr_len, ftnlen sense_len); -extern int cggglm_(integer *n, integer *m, integer *p, complex *a, integer *lda, - complex *b, integer *ldb, complex *d__, complex *x, - complex *y, complex *work, integer *lwork, integer *info); -extern int cgghrd_(char *compq, char *compz, integer *n, integer *ilo, - integer *ihi, complex *a, integer *lda, complex *b, - integer *ldb, complex *q, integer *ldq, complex *z__, - integer *ldz, integer *info, ftnlen compq_len, - ftnlen compz_len); -extern int cgglse_(integer *m, integer *n, integer *p, complex *a, integer *lda, - complex *b, integer *ldb, complex *c__, complex *d__, - complex *x, complex *work, integer *lwork, integer *info); -extern int cggqrf_(integer *n, integer *m, integer *p, complex *a, integer *lda, - complex *taua, complex *b, integer *ldb, complex *taub, - complex *work, integer *lwork, integer *info); -extern int cggrqf_(integer *m, integer *p, integer *n, complex *a, integer *lda, - complex *taua, complex *b, integer *ldb, complex *taub, - complex *work, integer *lwork, integer *info); -extern int cggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, - integer *p, integer *k, integer *l, complex *a, integer *lda, - complex *b, integer *ldb, real *alpha, real *beta, - complex *u, integer *ldu, complex *v, integer *ldv, - complex *q, integer *ldq, complex *work, real *rwork, - integer *iwork, integer *info, ftnlen jobu_len, - ftnlen jobv_len, ftnlen jobq_len); -extern int cggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, - integer *n, complex *a, integer *lda, complex *b, - integer *ldb, real *tola, real *tolb, integer *k, integer *l, - complex *u, integer *ldu, complex *v, integer *ldv, - complex *q, integer *ldq, integer *iwork, real *rwork, - complex *tau, complex *work, integer *info, ftnlen jobu_len, - ftnlen jobv_len, ftnlen jobq_len); -extern int cgtcon_(char *norm, integer *n, complex *dl, complex *d__, - complex *du, complex *du2, integer *ipiv, real *anorm, - real *rcond, complex *work, integer *info, ftnlen norm_len); -extern int cgtrfs_(char *trans, integer *n, integer *nrhs, complex *dl, - complex *d__, complex *du, complex *dlf, complex *df, - complex *duf, complex *du2, integer *ipiv, complex *b, - integer *ldb, complex *x, integer *ldx, real *ferr, - real *berr, complex *work, real *rwork, integer *info, - ftnlen trans_len); -extern int cgtsv_(integer *n, integer *nrhs, complex *dl, complex *d__, - complex *du, complex *b, integer *ldb, integer *info); -extern int cgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, - complex *dl, complex *d__, complex *du, complex *dlf, - complex *df, complex *duf, complex *du2, integer *ipiv, - complex *b, integer *ldb, complex *x, integer *ldx, - real *rcond, real *ferr, real *berr, complex *work, - real *rwork, integer *info, ftnlen fact_len, - ftnlen trans_len); -extern int cgttrf_(integer *n, complex *dl, complex *d__, complex *du, - complex *du2, integer *ipiv, integer *info); -extern int cgttrs_(char *trans, integer *n, integer *nrhs, complex *dl, - complex *d__, complex *du, complex *du2, integer *ipiv, - complex *b, integer *ldb, integer *info, ftnlen trans_len); -extern int cgtts2_(integer *itrans, integer *n, integer *nrhs, complex *dl, - complex *d__, complex *du, complex *du2, integer *ipiv, - complex *b, integer *ldb); -extern int chbev_(char *jobz, char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *w, complex *z__, integer *ldz, - complex *work, real *rwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int chbevd_(char *jobz, char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *w, complex *z__, integer *ldz, - complex *work, integer *lwork, real *rwork, integer *lrwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int chbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, - complex *ab, integer *ldab, complex *q, integer *ldq, - real *vl, real *vu, integer *il, integer *iu, real *abstol, - integer *m, real *w, complex *z__, integer *ldz, - complex *work, real *rwork, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int chbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, - complex *ab, integer *ldab, complex *bb, integer *ldbb, - complex *x, integer *ldx, complex *work, real *rwork, - integer *info, ftnlen vect_len, ftnlen uplo_len); -extern int chbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - complex *ab, integer *ldab, complex *bb, integer *ldbb, - real *w, complex *z__, integer *ldz, complex *work, - real *rwork, integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int chbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - complex *ab, integer *ldab, complex *bb, integer *ldbb, - real *w, complex *z__, integer *ldz, complex *work, - integer *lwork, real *rwork, integer *lrwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int chbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, - integer *kb, complex *ab, integer *ldab, complex *bb, - integer *ldbb, complex *q, integer *ldq, real *vl, real *vu, - integer *il, integer *iu, real *abstol, integer *m, real *w, - complex *z__, integer *ldz, complex *work, real *rwork, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int chbtrd_(char *vect, char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *d__, real *e, complex *q, integer *ldq, - complex *work, integer *info, ftnlen vect_len, - ftnlen uplo_len); -extern int checon_(char *uplo, integer *n, complex *a, integer *lda, - integer *ipiv, real *anorm, real *rcond, complex *work, - integer *info, ftnlen uplo_len); -extern int cheev_(char *jobz, char *uplo, integer *n, complex *a, integer *lda, - real *w, complex *work, integer *lwork, real *rwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int cheevd_(char *jobz, char *uplo, integer *n, complex *a, integer *lda, - real *w, complex *work, integer *lwork, real *rwork, - integer *lrwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int cheevr_(char *jobz, char *range, char *uplo, integer *n, complex *a, - integer *lda, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, complex *z__, - integer *ldz, integer *isuppz, complex *work, integer *lwork, - real *rwork, integer *lrwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int cheevx_(char *jobz, char *range, char *uplo, integer *n, complex *a, - integer *lda, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, complex *z__, - integer *ldz, complex *work, integer *lwork, real *rwork, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int chegs2_(integer *itype, char *uplo, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int chegst_(integer *itype, char *uplo, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int chegv_(integer *itype, char *jobz, char *uplo, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, real *w, - complex *work, integer *lwork, real *rwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int chegvd_(integer *itype, char *jobz, char *uplo, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, real *w, - complex *work, integer *lwork, real *rwork, integer *lrwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int chegvx_(integer *itype, char *jobz, char *range, char *uplo, - integer *n, complex *a, integer *lda, complex *b, - integer *ldb, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, complex *z__, - integer *ldz, complex *work, integer *lwork, real *rwork, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int cherfs_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, - complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen uplo_len); -extern int chesv_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, integer *ipiv, complex *b, integer *ldb, - complex *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int chesvx_(char *fact, char *uplo, integer *n, integer *nrhs, - complex *a, integer *lda, complex *af, integer *ldaf, - integer *ipiv, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, - complex *work, integer *lwork, real *rwork, integer *info, - ftnlen fact_len, ftnlen uplo_len); -extern int chetd2_(char *uplo, integer *n, complex *a, integer *lda, real *d__, - real *e, complex *tau, integer *info, ftnlen uplo_len); -extern int chetf2_(char *uplo, integer *n, complex *a, integer *lda, - integer *ipiv, integer *info, ftnlen uplo_len); -extern int chetrd_(char *uplo, integer *n, complex *a, integer *lda, real *d__, - real *e, complex *tau, complex *work, integer *lwork, - integer *info, ftnlen uplo_len); -extern int chetrf_(char *uplo, integer *n, complex *a, integer *lda, - integer *ipiv, complex *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int chetri_(char *uplo, integer *n, complex *a, integer *lda, - integer *ipiv, complex *work, integer *info, - ftnlen uplo_len); -extern int chetrs_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, integer *ipiv, complex *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int chgeqz_(char *job, char *compq, char *compz, integer *n, - integer *ilo, integer *ihi, complex *a, integer *lda, - complex *b, integer *ldb, complex *alpha, complex *beta, - complex *q, integer *ldq, complex *z__, integer *ldz, - complex *work, integer *lwork, real *rwork, integer *info, - ftnlen job_len, ftnlen compq_len, ftnlen compz_len); -extern int chpcon_(char *uplo, integer *n, complex *ap, integer *ipiv, - real *anorm, real *rcond, complex *work, integer *info, - ftnlen uplo_len); -extern int chpev_(char *jobz, char *uplo, integer *n, complex *ap, real *w, - complex *z__, integer *ldz, complex *work, real *rwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int chpevd_(char *jobz, char *uplo, integer *n, complex *ap, real *w, - complex *z__, integer *ldz, complex *work, integer *lwork, - real *rwork, integer *lrwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int chpevx_(char *jobz, char *range, char *uplo, integer *n, complex *ap, - real *vl, real *vu, integer *il, integer *iu, real *abstol, - integer *m, real *w, complex *z__, integer *ldz, - complex *work, real *rwork, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int chpgst_(integer *itype, char *uplo, integer *n, complex *ap, - complex *bp, integer *info, ftnlen uplo_len); -extern int chpgv_(integer *itype, char *jobz, char *uplo, integer *n, - complex *ap, complex *bp, real *w, complex *z__, integer *ldz, - complex *work, real *rwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int chpgvd_(integer *itype, char *jobz, char *uplo, integer *n, - complex *ap, complex *bp, real *w, complex *z__, - integer *ldz, complex *work, integer *lwork, real *rwork, - integer *lrwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int chpgvx_(integer *itype, char *jobz, char *range, char *uplo, - integer *n, complex *ap, complex *bp, real *vl, real *vu, - integer *il, integer *iu, real *abstol, integer *m, real *w, - complex *z__, integer *ldz, complex *work, real *rwork, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int chprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, - complex *afp, integer *ipiv, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, - complex *work, real *rwork, integer *info, ftnlen uplo_len); -extern int chpsv_(char *uplo, integer *n, integer *nrhs, complex *ap, - integer *ipiv, complex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int chpsvx_(char *fact, char *uplo, integer *n, integer *nrhs, - complex *ap, complex *afp, integer *ipiv, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen fact_len, ftnlen uplo_len); -extern int chptrd_(char *uplo, integer *n, complex *ap, real *d__, real *e, - complex *tau, integer *info, ftnlen uplo_len); -extern int chptrf_(char *uplo, integer *n, complex *ap, integer *ipiv, - integer *info, ftnlen uplo_len); -extern int chptri_(char *uplo, integer *n, complex *ap, integer *ipiv, - complex *work, integer *info, ftnlen uplo_len); -extern int chptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, - integer *ipiv, complex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int chsein_(char *side, char *eigsrc, char *initv, logical *select, - integer *n, complex *h__, integer *ldh, complex *w, - complex *vl, integer *ldvl, complex *vr, integer *ldvr, - integer *mm, integer *m, complex *work, real *rwork, - integer *ifaill, integer *ifailr, integer *info, - ftnlen side_len, ftnlen eigsrc_len, ftnlen initv_len); -extern int chseqr_(char *job, char *compz, integer *n, integer *ilo, - integer *ihi, complex *h__, integer *ldh, complex *w, - complex *z__, integer *ldz, complex *work, integer *lwork, - integer *info, ftnlen job_len, ftnlen compz_len); -extern int clabrd_(integer *m, integer *n, integer *nb, complex *a, - integer *lda, real *d__, real *e, complex *tauq, - complex *taup, complex *x, integer *ldx, complex *y, - integer *ldy); -extern int clacgv_(integer *n, complex *x, integer *incx); -extern int clacon_(integer *n, complex *v, complex *x, real *est, - integer *kase); -extern int clacp2_(char *uplo, integer *m, integer *n, real *a, integer *lda, - complex *b, integer *ldb, ftnlen uplo_len); -extern int clacpy_(char *uplo, integer *m, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, ftnlen uplo_len); -extern int clacrm_(integer *m, integer *n, complex *a, integer *lda, real *b, - integer *ldb, complex *c__, integer *ldc, real *rwork); -extern int clacrt_(integer *n, complex *cx, integer *incx, complex *cy, - integer *incy, complex *c__, complex *s); -extern C_f cladiv_(complex *ret_val, complex *x, complex *y); -extern int claed0_(integer *qsiz, integer *n, real *d__, real *e, complex *q, - integer *ldq, complex *qstore, integer *ldqs, real *rwork, - integer *iwork, integer *info); -extern int claed7_(integer *n, integer *cutpnt, integer *qsiz, integer *tlvls, - integer *curlvl, integer *curpbm, real *d__, complex *q, - integer *ldq, real *rho, integer *indxq, real *qstore, - integer *qptr, integer *prmptr, integer *perm, - integer *givptr, integer *givcol, real *givnum, - complex *work, real *rwork, integer *iwork, integer *info); -extern int claed8_(integer *k, integer *n, integer *qsiz, complex *q, - integer *ldq, real *d__, real *rho, integer *cutpnt, - real *z__, real *dlamda, complex *q2, integer *ldq2, real *w, - integer *indxp, integer *indx, integer *indxq, integer *perm, - integer *givptr, integer *givcol, real *givnum, - integer *info); -extern int claein_(logical *rightv, logical *noinit, integer *n, complex *h__, - integer *ldh, complex *w, complex *v, complex *b, - integer *ldb, real *rwork, real *eps3, real *smlnum, - integer *info); -extern int claesy_(complex *a, complex *b, complex *c__, complex *rt1, - complex *rt2, complex *evscal, complex *cs1, complex *sn1); -extern int claev2_(complex *a, complex *b, complex *c__, real *rt1, real *rt2, - real *cs1, complex *sn1); -extern int clags2_(logical *upper, real *a1, complex *a2, real *a3, real *b1, - complex *b2, real *b3, real *csu, complex *snu, real *csv, - complex *snv, real *csq, complex *snq); -extern int clagtm_(char *trans, integer *n, integer *nrhs, real *alpha, - complex *dl, complex *d__, complex *du, complex *x, - integer *ldx, real *beta, complex *b, integer *ldb, - ftnlen trans_len); -extern int clahef_(char *uplo, integer *n, integer *nb, integer *kb, complex *a, - integer *lda, integer *ipiv, complex *w, integer *ldw, - integer *info, ftnlen uplo_len); -extern int clahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, - integer *ihi, complex *h__, integer *ldh, complex *w, - integer *iloz, integer *ihiz, complex *z__, integer *ldz, - integer *info); -extern int clahrd_(integer *n, integer *k, integer *nb, complex *a, - integer *lda, complex *tau, complex *t, integer *ldt, - complex *y, integer *ldy); -extern int claic1_(integer *job, integer *j, complex *x, real *sest, complex *w, - complex *gamma, real *sestpr, complex *s, complex *c__); -extern int clals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *nrhs, complex *b, integer *ldb, complex *bx, - integer *ldbx, integer *perm, integer *givptr, - integer *givcol, integer *ldgcol, real *givnum, - integer *ldgnum, real *poles, real *difl, real *difr, - real *z__, integer *k, real *c__, real *s, real *rwork, - integer *info); -extern int clalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, - complex *b, integer *ldb, complex *bx, integer *ldbx, - real *u, integer *ldu, real *vt, integer *k, real *difl, - real *difr, real *z__, real *poles, integer *givptr, - integer *givcol, integer *ldgcol, integer *perm, - real *givnum, real *c__, real *s, real *rwork, - integer *iwork, integer *info); -extern int clalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, - real *d__, real *e, complex *b, integer *ldb, real *rcond, - integer *rank, complex *work, real *rwork, integer *iwork, - integer *info, ftnlen uplo_len); -extern E_f clangb_(char *norm, integer *n, integer *kl, integer *ku, - complex *ab, integer *ldab, real *work, ftnlen norm_len); -extern E_f clange_(char *norm, integer *m, integer *n, complex *a, integer *lda, - real *work, ftnlen norm_len); -extern E_f clangt_(char *norm, integer *n, complex *dl, complex *d__, - complex *du, ftnlen norm_len); -extern E_f clanhb_(char *norm, char *uplo, integer *n, integer *k, complex *ab, - integer *ldab, real *work, ftnlen norm_len, ftnlen uplo_len); -extern E_f clanhe_(char *norm, char *uplo, integer *n, complex *a, integer *lda, - real *work, ftnlen norm_len, ftnlen uplo_len); -extern E_f clanhp_(char *norm, char *uplo, integer *n, complex *ap, real *work, - ftnlen norm_len, ftnlen uplo_len); -extern E_f clanhs_(char *norm, integer *n, complex *a, integer *lda, real *work, - ftnlen norm_len); -extern E_f clanht_(char *norm, integer *n, real *d__, complex *e, - ftnlen norm_len); -extern E_f clansb_(char *norm, char *uplo, integer *n, integer *k, complex *ab, - integer *ldab, real *work, ftnlen norm_len, ftnlen uplo_len); -extern E_f clansp_(char *norm, char *uplo, integer *n, complex *ap, real *work, - ftnlen norm_len, ftnlen uplo_len); -extern E_f clansy_(char *norm, char *uplo, integer *n, complex *a, integer *lda, - real *work, ftnlen norm_len, ftnlen uplo_len); -extern E_f clantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, - complex *ab, integer *ldab, real *work, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern E_f clantp_(char *norm, char *uplo, char *diag, integer *n, complex *ap, - real *work, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern E_f clantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, - complex *a, integer *lda, real *work, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern int clapll_(integer *n, complex *x, integer *incx, complex *y, - integer *incy, real *ssmin); -extern int clapmt_(logical *forwrd, integer *m, integer *n, complex *x, - integer *ldx, integer *k); -extern int claqgb_(integer *m, integer *n, integer *kl, integer *ku, - complex *ab, integer *ldab, real *r__, real *c__, - real *rowcnd, real *colcnd, real *amax, char *equed, - ftnlen equed_len); -extern int claqge_(integer *m, integer *n, complex *a, integer *lda, real *r__, - real *c__, real *rowcnd, real *colcnd, real *amax, - char *equed, ftnlen equed_len); -extern int claqhb_(char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *s, real *scond, real *amax, char *equed, - ftnlen uplo_len, ftnlen equed_len); -extern int claqhe_(char *uplo, integer *n, complex *a, integer *lda, real *s, - real *scond, real *amax, char *equed, ftnlen uplo_len, - ftnlen equed_len); -extern int claqhp_(char *uplo, integer *n, complex *ap, real *s, real *scond, - real *amax, char *equed, ftnlen uplo_len, ftnlen equed_len); -extern int claqp2_(integer *m, integer *n, integer *offset, complex *a, - integer *lda, integer *jpvt, complex *tau, real *vn1, - real *vn2, complex *work); -extern int claqps_(integer *m, integer *n, integer *offset, integer *nb, - integer *kb, complex *a, integer *lda, integer *jpvt, - complex *tau, real *vn1, real *vn2, complex *auxv, - complex *f, integer *ldf); -extern int claqsb_(char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *s, real *scond, real *amax, char *equed, - ftnlen uplo_len, ftnlen equed_len); -extern int claqsp_(char *uplo, integer *n, complex *ap, real *s, real *scond, - real *amax, char *equed, ftnlen uplo_len, ftnlen equed_len); -extern int claqsy_(char *uplo, integer *n, complex *a, integer *lda, real *s, - real *scond, real *amax, char *equed, ftnlen uplo_len, - ftnlen equed_len); -extern int clar1v_(integer *n, integer *b1, integer *bn, real *sigma, real *d__, - real *l, real *ld, real *lld, real *gersch, complex *z__, - real *ztz, real *mingma, integer *r__, integer *isuppz, - real *work); -extern int clar2v_(integer *n, complex *x, complex *y, complex *z__, - integer *incx, real *c__, complex *s, integer *incc); -extern int clarcm_(integer *m, integer *n, real *a, integer *lda, complex *b, - integer *ldb, complex *c__, integer *ldc, real *rwork); -extern int clarf_(char *side, integer *m, integer *n, complex *v, integer *incv, - complex *tau, complex *c__, integer *ldc, complex *work, - ftnlen side_len); -extern int clarfb_(char *side, char *trans, char *direct, char *storev, - integer *m, integer *n, integer *k, complex *v, integer *ldv, - complex *t, integer *ldt, complex *c__, integer *ldc, - complex *work, integer *ldwork, ftnlen side_len, - ftnlen trans_len, ftnlen direct_len, ftnlen storev_len); -extern int clarfg_(integer *n, complex *alpha, complex *x, integer *incx, - complex *tau); -extern int clarft_(char *direct, char *storev, integer *n, integer *k, - complex *v, integer *ldv, complex *tau, complex *t, - integer *ldt, ftnlen direct_len, ftnlen storev_len); -extern int clarfx_(char *side, integer *m, integer *n, complex *v, complex *tau, - complex *c__, integer *ldc, complex *work, ftnlen side_len); -extern int clargv_(integer *n, complex *x, integer *incx, complex *y, - integer *incy, real *c__, integer *incc); -extern int clarnv_(integer *idist, integer *iseed, integer *n, complex *x); -extern int clarrv_(integer *n, real *d__, real *l, integer *isplit, integer *m, - real *w, integer *iblock, real *gersch, real *tol, - complex *z__, integer *ldz, integer *isuppz, real *work, - integer *iwork, integer *info); -extern int clartg_(complex *f, complex *g, real *cs, complex *sn, complex *r__); -extern int clartv_(integer *n, complex *x, integer *incx, complex *y, - integer *incy, real *c__, complex *s, integer *incc); -extern int clarz_(char *side, integer *m, integer *n, integer *l, complex *v, - integer *incv, complex *tau, complex *c__, integer *ldc, - complex *work, ftnlen side_len); -extern int clarzb_(char *side, char *trans, char *direct, char *storev, - integer *m, integer *n, integer *k, integer *l, complex *v, - integer *ldv, complex *t, integer *ldt, complex *c__, - integer *ldc, complex *work, integer *ldwork, - ftnlen side_len, ftnlen trans_len, ftnlen direct_len, - ftnlen storev_len); -extern int clarzt_(char *direct, char *storev, integer *n, integer *k, - complex *v, integer *ldv, complex *tau, complex *t, - integer *ldt, ftnlen direct_len, ftnlen storev_len); -extern int clascl_(char *type__, integer *kl, integer *ku, real *cfrom, - real *cto, integer *m, integer *n, complex *a, integer *lda, - integer *info, ftnlen type_len); -extern int claset_(char *uplo, integer *m, integer *n, complex *alpha, - complex *beta, complex *a, integer *lda, ftnlen uplo_len); -extern int clasr_(char *side, char *pivot, char *direct, integer *m, integer *n, - real *c__, real *s, complex *a, integer *lda, ftnlen side_len, - ftnlen pivot_len, ftnlen direct_len); -extern int classq_(integer *n, complex *x, integer *incx, real *scale, - real *sumsq); -extern int claswp_(integer *n, complex *a, integer *lda, integer *k1, - integer *k2, integer *ipiv, integer *incx); -extern int clasyf_(char *uplo, integer *n, integer *nb, integer *kb, complex *a, - integer *lda, integer *ipiv, complex *w, integer *ldw, - integer *info, ftnlen uplo_len); -extern int clatbs_(char *uplo, char *trans, char *diag, char *normin, - integer *n, integer *kd, complex *ab, integer *ldab, - complex *x, real *scale, real *cnorm, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len, - ftnlen normin_len); -extern int clatdf_(integer *ijob, integer *n, complex *z__, integer *ldz, - complex *rhs, real *rdsum, real *rdscal, integer *ipiv, - integer *jpiv); -extern int clatps_(char *uplo, char *trans, char *diag, char *normin, - integer *n, complex *ap, complex *x, real *scale, - real *cnorm, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len, ftnlen normin_len); -extern int clatrd_(char *uplo, integer *n, integer *nb, complex *a, - integer *lda, real *e, complex *tau, complex *w, - integer *ldw, ftnlen uplo_len); -extern int clatrs_(char *uplo, char *trans, char *diag, char *normin, - integer *n, complex *a, integer *lda, complex *x, - real *scale, real *cnorm, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len, ftnlen normin_len); -extern int clatrz_(integer *m, integer *n, integer *l, complex *a, integer *lda, - complex *tau, complex *work); -extern int clatzm_(char *side, integer *m, integer *n, complex *v, - integer *incv, complex *tau, complex *c1, complex *c2, - integer *ldc, complex *work, ftnlen side_len); -extern int clauu2_(char *uplo, integer *n, complex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int clauum_(char *uplo, integer *n, complex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int cpbcon_(char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *anorm, real *rcond, complex *work, - real *rwork, integer *info, ftnlen uplo_len); -extern int cpbequ_(char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, real *s, real *scond, real *amax, - integer *info, ftnlen uplo_len); -extern int cpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, - complex *ab, integer *ldab, complex *afb, integer *ldafb, - complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen uplo_len); -extern int cpbstf_(char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int cpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, - complex *ab, integer *ldab, complex *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int cpbsvx_(char *fact, char *uplo, integer *n, integer *kd, - integer *nrhs, complex *ab, integer *ldab, complex *afb, - integer *ldafb, char *equed, real *s, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen fact_len, ftnlen uplo_len, - ftnlen equed_len); -extern int cpbtf2_(char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int cpbtrf_(char *uplo, integer *n, integer *kd, complex *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int cpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, - complex *ab, integer *ldab, complex *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int cpocon_(char *uplo, integer *n, complex *a, integer *lda, - real *anorm, real *rcond, complex *work, real *rwork, - integer *info, ftnlen uplo_len); -extern int cpoequ_(integer *n, complex *a, integer *lda, real *s, real *scond, - real *amax, integer *info); -extern int cporfs_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, complex *b, - integer *ldb, complex *x, integer *ldx, real *ferr, - real *berr, complex *work, real *rwork, integer *info, - ftnlen uplo_len); -extern int cposv_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int cposvx_(char *fact, char *uplo, integer *n, integer *nrhs, - complex *a, integer *lda, complex *af, integer *ldaf, - char *equed, real *s, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, - complex *work, real *rwork, integer *info, ftnlen fact_len, - ftnlen uplo_len, ftnlen equed_len); -extern int cpotf2_(char *uplo, integer *n, complex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int cpotrf_(char *uplo, integer *n, complex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int cpotri_(char *uplo, integer *n, complex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int cpotrs_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int cppcon_(char *uplo, integer *n, complex *ap, real *anorm, - real *rcond, complex *work, real *rwork, integer *info, - ftnlen uplo_len); -extern int cppequ_(char *uplo, integer *n, complex *ap, real *s, real *scond, - real *amax, integer *info, ftnlen uplo_len); -extern int cpprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, - complex *afp, complex *b, integer *ldb, complex *x, - integer *ldx, real *ferr, real *berr, complex *work, - real *rwork, integer *info, ftnlen uplo_len); -extern int cppsv_(char *uplo, integer *n, integer *nrhs, complex *ap, - complex *b, integer *ldb, integer *info, ftnlen uplo_len); -extern int cppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, - complex *ap, complex *afp, char *equed, real *s, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen fact_len, ftnlen uplo_len, - ftnlen equed_len); -extern int cpptrf_(char *uplo, integer *n, complex *ap, integer *info, - ftnlen uplo_len); -extern int cpptri_(char *uplo, integer *n, complex *ap, integer *info, - ftnlen uplo_len); -extern int cpptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, - complex *b, integer *ldb, integer *info, ftnlen uplo_len); -extern int cptcon_(integer *n, real *d__, complex *e, real *anorm, real *rcond, - real *rwork, integer *info); -extern int cpteqr_(char *compz, integer *n, real *d__, real *e, complex *z__, - integer *ldz, real *work, integer *info, ftnlen compz_len); -extern int cptrfs_(char *uplo, integer *n, integer *nrhs, real *d__, complex *e, - real *df, complex *ef, complex *b, integer *ldb, complex *x, - integer *ldx, real *ferr, real *berr, complex *work, - real *rwork, integer *info, ftnlen uplo_len); -extern int cptsv_(integer *n, integer *nrhs, real *d__, complex *e, complex *b, - integer *ldb, integer *info); -extern int cptsvx_(char *fact, integer *n, integer *nrhs, real *d__, complex *e, - real *df, complex *ef, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, - complex *work, real *rwork, integer *info, ftnlen fact_len); -extern int cpttrf_(integer *n, real *d__, complex *e, integer *info); -extern int cpttrs_(char *uplo, integer *n, integer *nrhs, real *d__, complex *e, - complex *b, integer *ldb, integer *info, ftnlen uplo_len); -extern int cptts2_(integer *iuplo, integer *n, integer *nrhs, real *d__, - complex *e, complex *b, integer *ldb); -extern int crot_(integer *n, complex *cx, integer *incx, complex *cy, - integer *incy, real *c__, complex *s); -extern int cspcon_(char *uplo, integer *n, complex *ap, integer *ipiv, - real *anorm, real *rcond, complex *work, integer *info, - ftnlen uplo_len); -extern int cspmv_(char *uplo, integer *n, complex *alpha, complex *ap, - complex *x, integer *incx, complex *beta, complex *y, - integer *incy, ftnlen uplo_len); -extern int cspr_(char *uplo, integer *n, complex *alpha, complex *x, - integer *incx, complex *ap, ftnlen uplo_len); -extern int csprfs_(char *uplo, integer *n, integer *nrhs, complex *ap, - complex *afp, integer *ipiv, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, - complex *work, real *rwork, integer *info, ftnlen uplo_len); -extern int cspsv_(char *uplo, integer *n, integer *nrhs, complex *ap, - integer *ipiv, complex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int cspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, - complex *ap, complex *afp, integer *ipiv, complex *b, - integer *ldb, complex *x, integer *ldx, real *rcond, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen fact_len, ftnlen uplo_len); -extern int csptrf_(char *uplo, integer *n, complex *ap, integer *ipiv, - integer *info, ftnlen uplo_len); -extern int csptri_(char *uplo, integer *n, complex *ap, integer *ipiv, - complex *work, integer *info, ftnlen uplo_len); -extern int csptrs_(char *uplo, integer *n, integer *nrhs, complex *ap, - integer *ipiv, complex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int csrot_(integer *n, complex *cx, integer *incx, complex *cy, - integer *incy, real *c__, real *s); -extern int csrscl_(integer *n, real *sa, complex *sx, integer *incx); -extern int cstedc_(char *compz, integer *n, real *d__, real *e, complex *z__, - integer *ldz, complex *work, integer *lwork, real *rwork, - integer *lrwork, integer *iwork, integer *liwork, - integer *info, ftnlen compz_len); -extern int cstegr_(char *jobz, char *range, integer *n, real *d__, real *e, - real *vl, real *vu, integer *il, integer *iu, real *abstol, - integer *m, real *w, complex *z__, integer *ldz, - integer *isuppz, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len); -extern int cstein_(integer *n, real *d__, real *e, integer *m, real *w, - integer *iblock, integer *isplit, complex *z__, integer *ldz, - real *work, integer *iwork, integer *ifail, integer *info); -extern int csteqr_(char *compz, integer *n, real *d__, real *e, complex *z__, - integer *ldz, real *work, integer *info, ftnlen compz_len); -extern int csycon_(char *uplo, integer *n, complex *a, integer *lda, - integer *ipiv, real *anorm, real *rcond, complex *work, - integer *info, ftnlen uplo_len); -extern int csymv_(char *uplo, integer *n, complex *alpha, complex *a, - integer *lda, complex *x, integer *incx, complex *beta, - complex *y, integer *incy, ftnlen uplo_len); -extern int csyr_(char *uplo, integer *n, complex *alpha, complex *x, - integer *incx, complex *a, integer *lda, ftnlen uplo_len); -extern int csyrfs_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, complex *af, integer *ldaf, integer *ipiv, - complex *b, integer *ldb, complex *x, integer *ldx, - real *ferr, real *berr, complex *work, real *rwork, - integer *info, ftnlen uplo_len); -extern int csysv_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, integer *ipiv, complex *b, integer *ldb, - complex *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int csysvx_(char *fact, char *uplo, integer *n, integer *nrhs, - complex *a, integer *lda, complex *af, integer *ldaf, - integer *ipiv, complex *b, integer *ldb, complex *x, - integer *ldx, real *rcond, real *ferr, real *berr, - complex *work, integer *lwork, real *rwork, integer *info, - ftnlen fact_len, ftnlen uplo_len); -extern int csytf2_(char *uplo, integer *n, complex *a, integer *lda, - integer *ipiv, integer *info, ftnlen uplo_len); -extern int csytrf_(char *uplo, integer *n, complex *a, integer *lda, - integer *ipiv, complex *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int csytri_(char *uplo, integer *n, complex *a, integer *lda, - integer *ipiv, complex *work, integer *info, - ftnlen uplo_len); -extern int csytrs_(char *uplo, integer *n, integer *nrhs, complex *a, - integer *lda, integer *ipiv, complex *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int ctbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, - complex *ab, integer *ldab, real *rcond, complex *work, - real *rwork, integer *info, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern int ctbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, complex *ab, integer *ldab, complex *b, - integer *ldb, complex *x, integer *ldx, real *ferr, - real *berr, complex *work, real *rwork, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ctbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, complex *ab, integer *ldab, complex *b, - integer *ldb, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int ctgevc_(char *side, char *howmny, logical *select, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, - complex *vl, integer *ldvl, complex *vr, integer *ldvr, - integer *mm, integer *m, complex *work, real *rwork, - integer *info, ftnlen side_len, ftnlen howmny_len); -extern int ctgex2_(logical *wantq, logical *wantz, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, complex *q, - integer *ldq, complex *z__, integer *ldz, integer *j1, - integer *info); -extern int ctgexc_(logical *wantq, logical *wantz, integer *n, complex *a, - integer *lda, complex *b, integer *ldb, complex *q, - integer *ldq, complex *z__, integer *ldz, integer *ifst, - integer *ilst, integer *info); -extern int ctgsen_(integer *ijob, logical *wantq, logical *wantz, - logical *select, integer *n, complex *a, integer *lda, - complex *b, integer *ldb, complex *alpha, complex *beta, - complex *q, integer *ldq, complex *z__, integer *ldz, - integer *m, real *pl, real *pr, real *dif, complex *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info); -extern int ctgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, - integer *n, integer *k, integer *l, complex *a, integer *lda, - complex *b, integer *ldb, real *tola, real *tolb, - real *alpha, real *beta, complex *u, integer *ldu, - complex *v, integer *ldv, complex *q, integer *ldq, - complex *work, integer *ncycle, integer *info, - ftnlen jobu_len, ftnlen jobv_len, ftnlen jobq_len); -extern int ctgsna_(char *job, char *howmny, logical *select, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, - complex *vl, integer *ldvl, complex *vr, integer *ldvr, - real *s, real *dif, integer *mm, integer *m, complex *work, - integer *lwork, integer *iwork, integer *info, - ftnlen job_len, ftnlen howmny_len); -extern int ctgsy2_(char *trans, integer *ijob, integer *m, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, - complex *c__, integer *ldc, complex *d__, integer *ldd, - complex *e, integer *lde, complex *f, integer *ldf, - real *scale, real *rdsum, real *rdscal, integer *info, - ftnlen trans_len); -extern int ctgsyl_(char *trans, integer *ijob, integer *m, integer *n, - complex *a, integer *lda, complex *b, integer *ldb, - complex *c__, integer *ldc, complex *d__, integer *ldd, - complex *e, integer *lde, complex *f, integer *ldf, - real *scale, real *dif, complex *work, integer *lwork, - integer *iwork, integer *info, ftnlen trans_len); -extern int ctpcon_(char *norm, char *uplo, char *diag, integer *n, complex *ap, - real *rcond, complex *work, real *rwork, integer *info, - ftnlen norm_len, ftnlen uplo_len, ftnlen diag_len); -extern int ctprfs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, complex *ap, complex *b, integer *ldb, - complex *x, integer *ldx, real *ferr, real *berr, - complex *work, real *rwork, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int ctptri_(char *uplo, char *diag, integer *n, complex *ap, - integer *info, ftnlen uplo_len, ftnlen diag_len); -extern int ctptrs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, complex *ap, complex *b, integer *ldb, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int ctrcon_(char *norm, char *uplo, char *diag, integer *n, complex *a, - integer *lda, real *rcond, complex *work, real *rwork, - integer *info, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern int ctrevc_(char *side, char *howmny, logical *select, integer *n, - complex *t, integer *ldt, complex *vl, integer *ldvl, - complex *vr, integer *ldvr, integer *mm, integer *m, - complex *work, real *rwork, integer *info, ftnlen side_len, - ftnlen howmny_len); -extern int ctrexc_(char *compq, integer *n, complex *t, integer *ldt, - complex *q, integer *ldq, integer *ifst, integer *ilst, - integer *info, ftnlen compq_len); -extern int ctrrfs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, complex *a, integer *lda, complex *b, - integer *ldb, complex *x, integer *ldx, real *ferr, - real *berr, complex *work, real *rwork, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ctrsen_(char *job, char *compq, logical *select, integer *n, - complex *t, integer *ldt, complex *q, integer *ldq, - complex *w, integer *m, real *s, real *sep, complex *work, - integer *lwork, integer *info, ftnlen job_len, - ftnlen compq_len); -extern int ctrsna_(char *job, char *howmny, logical *select, integer *n, - complex *t, integer *ldt, complex *vl, integer *ldvl, - complex *vr, integer *ldvr, real *s, real *sep, integer *mm, - integer *m, complex *work, integer *ldwork, real *rwork, - integer *info, ftnlen job_len, ftnlen howmny_len); -extern int ctrsyl_(char *trana, char *tranb, integer *isgn, integer *m, - integer *n, complex *a, integer *lda, complex *b, - integer *ldb, complex *c__, integer *ldc, real *scale, - integer *info, ftnlen trana_len, ftnlen tranb_len); -extern int ctrti2_(char *uplo, char *diag, integer *n, complex *a, integer *lda, - integer *info, ftnlen uplo_len, ftnlen diag_len); -extern int ctrtri_(char *uplo, char *diag, integer *n, complex *a, integer *lda, - integer *info, ftnlen uplo_len, ftnlen diag_len); -extern int ctrtrs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, complex *a, integer *lda, complex *b, - integer *ldb, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int ctzrqf_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, integer *info); -extern int ctzrzf_(integer *m, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cung2l_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *info); -extern int cung2r_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *info); -extern int cungbr_(char *vect, integer *m, integer *n, integer *k, complex *a, - integer *lda, complex *tau, complex *work, integer *lwork, - integer *info, ftnlen vect_len); -extern int cunghr_(integer *n, integer *ilo, integer *ihi, complex *a, - integer *lda, complex *tau, complex *work, integer *lwork, - integer *info); -extern int cungl2_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *info); -extern int cunglq_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cungql_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cungqr_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cungr2_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *info); -extern int cungrq_(integer *m, integer *n, integer *k, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info); -extern int cungtr_(char *uplo, integer *n, complex *a, integer *lda, - complex *tau, complex *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int cunm2l_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int cunm2r_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int cunmbr_(char *vect, char *side, char *trans, integer *m, integer *n, - integer *k, complex *a, integer *lda, complex *tau, - complex *c__, integer *ldc, complex *work, integer *lwork, - integer *info, ftnlen vect_len, ftnlen side_len, - ftnlen trans_len); -extern int cunmhr_(char *side, char *trans, integer *m, integer *n, - integer *ilo, integer *ihi, complex *a, integer *lda, - complex *tau, complex *c__, integer *ldc, complex *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int cunml2_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int cunmlq_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int cunmql_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int cunmqr_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int cunmr2_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int cunmr3_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, complex *a, integer *lda, complex *tau, - complex *c__, integer *ldc, complex *work, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int cunmrq_(char *side, char *trans, integer *m, integer *n, integer *k, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int cunmrz_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, complex *a, integer *lda, complex *tau, - complex *c__, integer *ldc, complex *work, integer *lwork, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int cunmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - complex *a, integer *lda, complex *tau, complex *c__, - integer *ldc, complex *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen uplo_len, ftnlen trans_len); -extern int cupgtr_(char *uplo, integer *n, complex *ap, complex *tau, - complex *q, integer *ldq, complex *work, integer *info, - ftnlen uplo_len); -extern int cupmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - complex *ap, complex *tau, complex *c__, integer *ldc, - complex *work, integer *info, ftnlen side_len, - ftnlen uplo_len, ftnlen trans_len); -extern int dbdsdc_(char *uplo, char *compq, integer *n, doublereal *d__, - doublereal *e, doublereal *u, integer *ldu, doublereal *vt, - integer *ldvt, doublereal *q, integer *iq, doublereal *work, - integer *iwork, integer *info, ftnlen uplo_len, - ftnlen compq_len); -extern int dbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, - integer *ncc, doublereal *d__, doublereal *e, doublereal *vt, - integer *ldvt, doublereal *u, integer *ldu, doublereal *c__, - integer *ldc, doublereal *work, integer *info, - ftnlen uplo_len); -extern int ddisna_(char *job, integer *m, integer *n, doublereal *d__, - doublereal *sep, integer *info, ftnlen job_len); -extern int dgbbrd_(char *vect, integer *m, integer *n, integer *ncc, - integer *kl, integer *ku, doublereal *ab, integer *ldab, - doublereal *d__, doublereal *e, doublereal *q, integer *ldq, - doublereal *pt, integer *ldpt, doublereal *c__, integer *ldc, - doublereal *work, integer *info, ftnlen vect_len); -extern int dgbcon_(char *norm, integer *n, integer *kl, integer *ku, - doublereal *ab, integer *ldab, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublereal *work, - integer *iwork, integer *info, ftnlen norm_len); -extern int dgbequ_(integer *m, integer *n, integer *kl, integer *ku, - doublereal *ab, integer *ldab, doublereal *r__, - doublereal *c__, doublereal *rowcnd, doublereal *colcnd, - doublereal *amax, integer *info); -extern int dgbrfs_(char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, doublereal *ab, integer *ldab, - doublereal *afb, integer *ldafb, integer *ipiv, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info, ftnlen trans_len); -extern int dgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, - doublereal *ab, integer *ldab, integer *ipiv, doublereal *b, - integer *ldb, integer *info); -extern int dgbsvx_(char *fact, char *trans, integer *n, integer *kl, - integer *ku, integer *nrhs, doublereal *ab, integer *ldab, - doublereal *afb, integer *ldafb, integer *ipiv, char *equed, - doublereal *r__, doublereal *c__, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info, ftnlen fact_len, - ftnlen trans_len, ftnlen equed_len); -extern int dgbtf2_(integer *m, integer *n, integer *kl, integer *ku, - doublereal *ab, integer *ldab, integer *ipiv, integer *info); -extern int dgbtrf_(integer *m, integer *n, integer *kl, integer *ku, - doublereal *ab, integer *ldab, integer *ipiv, integer *info); -extern int dgbtrs_(char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, doublereal *ab, integer *ldab, integer *ipiv, - doublereal *b, integer *ldb, integer *info, - ftnlen trans_len); -extern int dgebak_(char *job, char *side, integer *n, integer *ilo, - integer *ihi, doublereal *scale, integer *m, doublereal *v, - integer *ldv, integer *info, ftnlen job_len, - ftnlen side_len); -extern int dgebal_(char *job, integer *n, doublereal *a, integer *lda, - integer *ilo, integer *ihi, doublereal *scale, integer *info, - ftnlen job_len); -extern int dgebd2_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *d__, doublereal *e, doublereal *tauq, - doublereal *taup, doublereal *work, integer *info); -extern int dgebrd_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *d__, doublereal *e, doublereal *tauq, - doublereal *taup, doublereal *work, integer *lwork, - integer *info); -extern int dgecon_(char *norm, integer *n, doublereal *a, integer *lda, - doublereal *anorm, doublereal *rcond, doublereal *work, - integer *iwork, integer *info, ftnlen norm_len); -extern int dgeequ_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, integer *info); -extern int dgees_(char *jobvs, char *sort, L_fp select, integer *n, - doublereal *a, integer *lda, integer *sdim, doublereal *wr, - doublereal *wi, doublereal *vs, integer *ldvs, - doublereal *work, integer *lwork, logical *bwork, - integer *info, ftnlen jobvs_len, ftnlen sort_len); -extern int dgeesx_(char *jobvs, char *sort, L_fp select, char *sense, - integer *n, doublereal *a, integer *lda, integer *sdim, - doublereal *wr, doublereal *wi, doublereal *vs, - integer *ldvs, doublereal *rconde, doublereal *rcondv, - doublereal *work, integer *lwork, integer *iwork, - integer *liwork, logical *bwork, integer *info, - ftnlen jobvs_len, ftnlen sort_len, ftnlen sense_len); -extern int dgeev_(char *jobvl, char *jobvr, integer *n, doublereal *a, - integer *lda, doublereal *wr, doublereal *wi, doublereal *vl, - integer *ldvl, doublereal *vr, integer *ldvr, - doublereal *work, integer *lwork, integer *info, - ftnlen jobvl_len, ftnlen jobvr_len); -extern int dgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, - integer *n, doublereal *a, integer *lda, doublereal *wr, - doublereal *wi, doublereal *vl, integer *ldvl, - doublereal *vr, integer *ldvr, integer *ilo, integer *ihi, - doublereal *scale, doublereal *abnrm, doublereal *rconde, - doublereal *rcondv, doublereal *work, integer *lwork, - integer *iwork, integer *info, ftnlen balanc_len, - ftnlen jobvl_len, ftnlen jobvr_len, ftnlen sense_len); -extern int dgegs_(char *jobvsl, char *jobvsr, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *alphar, - doublereal *alphai, doublereal *beta, doublereal *vsl, - integer *ldvsl, doublereal *vsr, integer *ldvsr, - doublereal *work, integer *lwork, integer *info, - ftnlen jobvsl_len, ftnlen jobvsr_len); -extern int dgegv_(char *jobvl, char *jobvr, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *alphar, - doublereal *alphai, doublereal *beta, doublereal *vl, - integer *ldvl, doublereal *vr, integer *ldvr, - doublereal *work, integer *lwork, integer *info, - ftnlen jobvl_len, ftnlen jobvr_len); -extern int dgehd2_(integer *n, integer *ilo, integer *ihi, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *info); -extern int dgehrd_(integer *n, integer *ilo, integer *ihi, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *lwork, integer *info); -extern int dgelq2_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); -extern int dgelqf_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, - integer *info); -extern int dgels_(char *trans, integer *m, integer *n, integer *nrhs, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *work, integer *lwork, integer *info, - ftnlen trans_len); -extern int dgelsd_(integer *m, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *s, - doublereal *rcond, integer *rank, doublereal *work, - integer *lwork, integer *iwork, integer *info); -extern int dgelss_(integer *m, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *s, - doublereal *rcond, integer *rank, doublereal *work, - integer *lwork, integer *info); -extern int dgelsx_(integer *m, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *b, integer *ldb, integer *jpvt, - doublereal *rcond, integer *rank, doublereal *work, - integer *info); -extern int dgelsy_(integer *m, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *b, integer *ldb, integer *jpvt, - doublereal *rcond, integer *rank, doublereal *work, - integer *lwork, integer *info); -extern int dgeql2_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); -extern int dgeqlf_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, - integer *info); -extern int dgeqp3_(integer *m, integer *n, doublereal *a, integer *lda, - integer *jpvt, doublereal *tau, doublereal *work, - integer *lwork, integer *info); -extern int dgeqpf_(integer *m, integer *n, doublereal *a, integer *lda, - integer *jpvt, doublereal *tau, doublereal *work, - integer *info); -extern int dgeqr2_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); -extern int dgeqrf_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, - integer *info); -extern int dgerfs_(char *trans, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info, ftnlen trans_len); -extern int dgerq2_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *info); -extern int dgerqf_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, - integer *info); -extern int dgesc2_(integer *n, doublereal *a, integer *lda, doublereal *rhs, - integer *ipiv, integer *jpiv, doublereal *scale); -extern int dgesdd_(char *jobz, integer *m, integer *n, doublereal *a, - integer *lda, doublereal *s, doublereal *u, integer *ldu, - doublereal *vt, integer *ldvt, doublereal *work, - integer *lwork, integer *iwork, integer *info, - ftnlen jobz_len); -extern int dgesv_(integer *n, integer *nrhs, doublereal *a, integer *lda, - integer *ipiv, doublereal *b, integer *ldb, integer *info); -extern int dgesvd_(char *jobu, char *jobvt, integer *m, integer *n, - doublereal *a, integer *lda, doublereal *s, doublereal *u, - integer *ldu, doublereal *vt, integer *ldvt, - doublereal *work, integer *lwork, integer *info, - ftnlen jobu_len, ftnlen jobvt_len); -extern int dgesvx_(char *fact, char *trans, integer *n, integer *nrhs, - doublereal *a, integer *lda, doublereal *af, integer *ldaf, - integer *ipiv, char *equed, doublereal *r__, doublereal *c__, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info, - ftnlen fact_len, ftnlen trans_len, ftnlen equed_len); -extern int dgetc2_(integer *n, doublereal *a, integer *lda, integer *ipiv, - integer *jpiv, integer *info); -extern int dgetf2_(integer *m, integer *n, doublereal *a, integer *lda, - integer *ipiv, integer *info); -extern int dgetrf_(integer *m, integer *n, doublereal *a, integer *lda, - integer *ipiv, integer *info); -extern int dgetri_(integer *n, doublereal *a, integer *lda, integer *ipiv, - doublereal *work, integer *lwork, integer *info); -extern int dgetrs_(char *trans, integer *n, integer *nrhs, doublereal *a, - integer *lda, integer *ipiv, doublereal *b, integer *ldb, - integer *info, ftnlen trans_len); -extern int dggbak_(char *job, char *side, integer *n, integer *ilo, - integer *ihi, doublereal *lscale, doublereal *rscale, - integer *m, doublereal *v, integer *ldv, integer *info, - ftnlen job_len, ftnlen side_len); -extern int dggbal_(char *job, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb, integer *ilo, integer *ihi, - doublereal *lscale, doublereal *rscale, doublereal *work, - integer *info, ftnlen job_len); -extern int dgges_(char *jobvsl, char *jobvsr, char *sort, L_fp delctg, - integer *n, doublereal *a, integer *lda, doublereal *b, - integer *ldb, integer *sdim, doublereal *alphar, - doublereal *alphai, doublereal *beta, doublereal *vsl, - integer *ldvsl, doublereal *vsr, integer *ldvsr, - doublereal *work, integer *lwork, logical *bwork, - integer *info, ftnlen jobvsl_len, ftnlen jobvsr_len, - ftnlen sort_len); -extern int dggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp delctg, - char *sense, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb, integer *sdim, - doublereal *alphar, doublereal *alphai, doublereal *beta, - doublereal *vsl, integer *ldvsl, doublereal *vsr, - integer *ldvsr, doublereal *rconde, doublereal *rcondv, - doublereal *work, integer *lwork, integer *iwork, - integer *liwork, logical *bwork, integer *info, - ftnlen jobvsl_len, ftnlen jobvsr_len, ftnlen sort_len, - ftnlen sense_len); -extern int dggev_(char *jobvl, char *jobvr, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *alphar, - doublereal *alphai, doublereal *beta, doublereal *vl, - integer *ldvl, doublereal *vr, integer *ldvr, - doublereal *work, integer *lwork, integer *info, - ftnlen jobvl_len, ftnlen jobvr_len); -extern int dggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, - integer *n, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *alphar, doublereal *alphai, - doublereal *beta, doublereal *vl, integer *ldvl, - doublereal *vr, integer *ldvr, integer *ilo, integer *ihi, - doublereal *lscale, doublereal *rscale, doublereal *abnrm, - doublereal *bbnrm, doublereal *rconde, doublereal *rcondv, - doublereal *work, integer *lwork, integer *iwork, - logical *bwork, integer *info, ftnlen balanc_len, - ftnlen jobvl_len, ftnlen jobvr_len, ftnlen sense_len); -extern int dggglm_(integer *n, integer *m, integer *p, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *d__, - doublereal *x, doublereal *y, doublereal *work, - integer *lwork, integer *info); -extern int dgghrd_(char *compq, char *compz, integer *n, integer *ilo, - integer *ihi, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *q, integer *ldq, doublereal *z__, - integer *ldz, integer *info, ftnlen compq_len, - ftnlen compz_len); -extern int dgglse_(integer *m, integer *n, integer *p, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *c__, - doublereal *d__, doublereal *x, doublereal *work, - integer *lwork, integer *info); -extern int dggqrf_(integer *n, integer *m, integer *p, doublereal *a, - integer *lda, doublereal *taua, doublereal *b, integer *ldb, - doublereal *taub, doublereal *work, integer *lwork, - integer *info); -extern int dggrqf_(integer *m, integer *p, integer *n, doublereal *a, - integer *lda, doublereal *taua, doublereal *b, integer *ldb, - doublereal *taub, doublereal *work, integer *lwork, - integer *info); -extern int dggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, - integer *p, integer *k, integer *l, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *alpha, - doublereal *beta, doublereal *u, integer *ldu, doublereal *v, - integer *ldv, doublereal *q, integer *ldq, doublereal *work, - integer *iwork, integer *info, ftnlen jobu_len, - ftnlen jobv_len, ftnlen jobq_len); -extern int dggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, - integer *n, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *tola, doublereal *tolb, integer *k, - integer *l, doublereal *u, integer *ldu, doublereal *v, - integer *ldv, doublereal *q, integer *ldq, integer *iwork, - doublereal *tau, doublereal *work, integer *info, - ftnlen jobu_len, ftnlen jobv_len, ftnlen jobq_len); -extern int dgtcon_(char *norm, integer *n, doublereal *dl, doublereal *d__, - doublereal *du, doublereal *du2, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublereal *work, - integer *iwork, integer *info, ftnlen norm_len); -extern int dgtrfs_(char *trans, integer *n, integer *nrhs, doublereal *dl, - doublereal *d__, doublereal *du, doublereal *dlf, - doublereal *df, doublereal *duf, doublereal *du2, - integer *ipiv, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info, - ftnlen trans_len); -extern int dgtsv_(integer *n, integer *nrhs, doublereal *dl, doublereal *d__, - doublereal *du, doublereal *b, integer *ldb, integer *info); -extern int dgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, - doublereal *dl, doublereal *d__, doublereal *du, - doublereal *dlf, doublereal *df, doublereal *duf, - doublereal *du2, integer *ipiv, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info, ftnlen fact_len, - ftnlen trans_len); -extern int dgttrf_(integer *n, doublereal *dl, doublereal *d__, doublereal *du, - doublereal *du2, integer *ipiv, integer *info); -extern int dgttrs_(char *trans, integer *n, integer *nrhs, doublereal *dl, - doublereal *d__, doublereal *du, doublereal *du2, - integer *ipiv, doublereal *b, integer *ldb, integer *info, - ftnlen trans_len); -extern int dgtts2_(integer *itrans, integer *n, integer *nrhs, doublereal *dl, - doublereal *d__, doublereal *du, doublereal *du2, - integer *ipiv, doublereal *b, integer *ldb); -extern int dhgeqz_(char *job, char *compq, char *compz, integer *n, - integer *ilo, integer *ihi, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *alphar, - doublereal *alphai, doublereal *beta, doublereal *q, - integer *ldq, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *info, - ftnlen job_len, ftnlen compq_len, ftnlen compz_len); -extern int dhsein_(char *side, char *eigsrc, char *initv, logical *select, - integer *n, doublereal *h__, integer *ldh, doublereal *wr, - doublereal *wi, doublereal *vl, integer *ldvl, - doublereal *vr, integer *ldvr, integer *mm, integer *m, - doublereal *work, integer *ifaill, integer *ifailr, - integer *info, ftnlen side_len, ftnlen eigsrc_len, - ftnlen initv_len); -extern int dhseqr_(char *job, char *compz, integer *n, integer *ilo, - integer *ihi, doublereal *h__, integer *ldh, doublereal *wr, - doublereal *wi, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *info, - ftnlen job_len, ftnlen compz_len); -extern int dlabad_(doublereal *small, doublereal *large); -extern int dlabrd_(integer *m, integer *n, integer *nb, doublereal *a, - integer *lda, doublereal *d__, doublereal *e, - doublereal *tauq, doublereal *taup, doublereal *x, - integer *ldx, doublereal *y, integer *ldy); -extern int dlacon_(integer *n, doublereal *v, doublereal *x, integer *isgn, - doublereal *est, integer *kase); -extern int dlacpy_(char *uplo, integer *m, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, ftnlen uplo_len); -extern int dladiv_(doublereal *a, doublereal *b, doublereal *c__, - doublereal *d__, doublereal *p, doublereal *q); -extern int dlae2_(doublereal *a, doublereal *b, doublereal *c__, - doublereal *rt1, doublereal *rt2); -extern int dlaebz_(integer *ijob, integer *nitmax, integer *n, integer *mmax, - integer *minp, integer *nbmin, doublereal *abstol, - doublereal *reltol, doublereal *pivmin, doublereal *d__, - doublereal *e, doublereal *e2, integer *nval, doublereal *ab, - doublereal *c__, integer *mout, integer *nab, - doublereal *work, integer *iwork, integer *info); -extern int dlaed0_(integer *icompq, integer *qsiz, integer *n, doublereal *d__, - doublereal *e, doublereal *q, integer *ldq, - doublereal *qstore, integer *ldqs, doublereal *work, - integer *iwork, integer *info); -extern int dlaed1_(integer *n, doublereal *d__, doublereal *q, integer *ldq, - integer *indxq, doublereal *rho, integer *cutpnt, - doublereal *work, integer *iwork, integer *info); -extern int dlaed2_(integer *k, integer *n, integer *n1, doublereal *d__, - doublereal *q, integer *ldq, integer *indxq, doublereal *rho, - doublereal *z__, doublereal *dlamda, doublereal *w, - doublereal *q2, integer *indx, integer *indxc, - integer *indxp, integer *coltyp, integer *info); -extern int dlaed3_(integer *k, integer *n, integer *n1, doublereal *d__, - doublereal *q, integer *ldq, doublereal *rho, - doublereal *dlamda, doublereal *q2, integer *indx, - integer *ctot, doublereal *w, doublereal *s, integer *info); -extern int dlaed4_(integer *n, integer *i__, doublereal *d__, doublereal *z__, - doublereal *delta, doublereal *rho, doublereal *dlam, - integer *info); -extern int dlaed5_(integer *i__, doublereal *d__, doublereal *z__, - doublereal *delta, doublereal *rho, doublereal *dlam); -extern int dlaed6_(integer *kniter, logical *orgati, doublereal *rho, - doublereal *d__, doublereal *z__, doublereal *finit, - doublereal *tau, integer *info); -extern int dlaed7_(integer *icompq, integer *n, integer *qsiz, integer *tlvls, - integer *curlvl, integer *curpbm, doublereal *d__, - doublereal *q, integer *ldq, integer *indxq, doublereal *rho, - integer *cutpnt, doublereal *qstore, integer *qptr, - integer *prmptr, integer *perm, integer *givptr, - integer *givcol, doublereal *givnum, doublereal *work, - integer *iwork, integer *info); -extern int dlaed8_(integer *icompq, integer *k, integer *n, integer *qsiz, - doublereal *d__, doublereal *q, integer *ldq, integer *indxq, - doublereal *rho, integer *cutpnt, doublereal *z__, - doublereal *dlamda, doublereal *q2, integer *ldq2, - doublereal *w, integer *perm, integer *givptr, - integer *givcol, doublereal *givnum, integer *indxp, - integer *indx, integer *info); -extern int dlaed9_(integer *k, integer *kstart, integer *kstop, integer *n, - doublereal *d__, doublereal *q, integer *ldq, - doublereal *rho, doublereal *dlamda, doublereal *w, - doublereal *s, integer *lds, integer *info); -extern int dlaeda_(integer *n, integer *tlvls, integer *curlvl, integer *curpbm, - integer *prmptr, integer *perm, integer *givptr, - integer *givcol, doublereal *givnum, doublereal *q, - integer *qptr, doublereal *z__, doublereal *ztemp, - integer *info); -extern int dlaein_(logical *rightv, logical *noinit, integer *n, - doublereal *h__, integer *ldh, doublereal *wr, - doublereal *wi, doublereal *vr, doublereal *vi, - doublereal *b, integer *ldb, doublereal *work, - doublereal *eps3, doublereal *smlnum, doublereal *bignum, - integer *info); -extern int dlaev2_(doublereal *a, doublereal *b, doublereal *c__, - doublereal *rt1, doublereal *rt2, doublereal *cs1, - doublereal *sn1); -extern int dlaexc_(logical *wantq, integer *n, doublereal *t, integer *ldt, - doublereal *q, integer *ldq, integer *j1, integer *n1, - integer *n2, doublereal *work, integer *info); -extern int dlag2_(doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *safmin, doublereal *scale1, doublereal *scale2, - doublereal *wr1, doublereal *wr2, doublereal *wi); -extern int dlags2_(logical *upper, doublereal *a1, doublereal *a2, - doublereal *a3, doublereal *b1, doublereal *b2, - doublereal *b3, doublereal *csu, doublereal *snu, - doublereal *csv, doublereal *snv, doublereal *csq, - doublereal *snq); -extern int dlagtf_(integer *n, doublereal *a, doublereal *lambda, doublereal *b, - doublereal *c__, doublereal *tol, doublereal *d__, - integer *in, integer *info); -extern int dlagtm_(char *trans, integer *n, integer *nrhs, doublereal *alpha, - doublereal *dl, doublereal *d__, doublereal *du, - doublereal *x, integer *ldx, doublereal *beta, doublereal *b, - integer *ldb, ftnlen trans_len); -extern int dlagts_(integer *job, integer *n, doublereal *a, doublereal *b, - doublereal *c__, doublereal *d__, integer *in, doublereal *y, - doublereal *tol, integer *info); -extern int dlagv2_(doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *alphar, doublereal *alphai, doublereal *beta, - doublereal *csl, doublereal *snl, doublereal *csr, - doublereal *snr); -extern int dlahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, - integer *ihi, doublereal *h__, integer *ldh, doublereal *wr, - doublereal *wi, integer *iloz, integer *ihiz, - doublereal *z__, integer *ldz, integer *info); -extern int dlahrd_(integer *n, integer *k, integer *nb, doublereal *a, - integer *lda, doublereal *tau, doublereal *t, integer *ldt, - doublereal *y, integer *ldy); -extern int dlaic1_(integer *job, integer *j, doublereal *x, doublereal *sest, - doublereal *w, doublereal *gamma, doublereal *sestpr, - doublereal *s, doublereal *c__); -extern int dlaln2_(logical *ltrans, integer *na, integer *nw, doublereal *smin, - doublereal *ca, doublereal *a, integer *lda, doublereal *d1, - doublereal *d2, doublereal *b, integer *ldb, doublereal *wr, - doublereal *wi, doublereal *x, integer *ldx, - doublereal *scale, doublereal *xnorm, integer *info); -extern int dlals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *nrhs, doublereal *b, integer *ldb, doublereal *bx, - integer *ldbx, integer *perm, integer *givptr, - integer *givcol, integer *ldgcol, doublereal *givnum, - integer *ldgnum, doublereal *poles, doublereal *difl, - doublereal *difr, doublereal *z__, integer *k, - doublereal *c__, doublereal *s, doublereal *work, - integer *info); -extern int dlalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, - doublereal *b, integer *ldb, doublereal *bx, integer *ldbx, - doublereal *u, integer *ldu, doublereal *vt, integer *k, - doublereal *difl, doublereal *difr, doublereal *z__, - doublereal *poles, integer *givptr, integer *givcol, - integer *ldgcol, integer *perm, doublereal *givnum, - doublereal *c__, doublereal *s, doublereal *work, - integer *iwork, integer *info); -extern int dlalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, - doublereal *d__, doublereal *e, doublereal *b, integer *ldb, - doublereal *rcond, integer *rank, doublereal *work, - integer *iwork, integer *info, ftnlen uplo_len); -extern doublereal dlamch_(char *cmach, ftnlen cmach_len); -extern int dlamc1_(integer *beta, integer *t, logical *rnd, logical *ieee1); -extern int dlamc2_(integer *beta, integer *t, logical *rnd, doublereal *eps, - integer *emin, doublereal *rmin, integer *emax, - doublereal *rmax); -extern doublereal dlamc3_(doublereal *a, doublereal *b); -extern int dlamc4_(integer *emin, doublereal *start, integer *base); -extern int dlamc5_(integer *beta, integer *p, integer *emin, logical *ieee, - integer *emax, doublereal *rmax); -extern int dlamrg_(integer *n1, integer *n2, doublereal *a, integer *dtrd1, - integer *dtrd2, integer *index); -extern doublereal dlangb_(char *norm, integer *n, integer *kl, integer *ku, - doublereal *ab, integer *ldab, doublereal *work, - ftnlen norm_len); -extern doublereal dlange_(char *norm, integer *m, integer *n, doublereal *a, - integer *lda, doublereal *work, ftnlen norm_len); -extern doublereal dlangt_(char *norm, integer *n, doublereal *dl, - doublereal *d__, doublereal *du, ftnlen norm_len); -extern doublereal dlanhs_(char *norm, integer *n, doublereal *a, integer *lda, - doublereal *work, ftnlen norm_len); -extern doublereal dlansb_(char *norm, char *uplo, integer *n, integer *k, - doublereal *ab, integer *ldab, doublereal *work, - ftnlen norm_len, ftnlen uplo_len); -extern doublereal dlansp_(char *norm, char *uplo, integer *n, doublereal *ap, - doublereal *work, ftnlen norm_len, ftnlen uplo_len); -extern doublereal dlanst_(char *norm, integer *n, doublereal *d__, - doublereal *e, ftnlen norm_len); -extern doublereal dlansy_(char *norm, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *work, ftnlen norm_len, - ftnlen uplo_len); -extern doublereal dlantb_(char *norm, char *uplo, char *diag, integer *n, - integer *k, doublereal *ab, integer *ldab, - doublereal *work, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern doublereal dlantp_(char *norm, char *uplo, char *diag, integer *n, - doublereal *ap, doublereal *work, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern doublereal dlantr_(char *norm, char *uplo, char *diag, integer *m, - integer *n, doublereal *a, integer *lda, - doublereal *work, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern int dlanv2_(doublereal *a, doublereal *b, doublereal *c__, - doublereal *d__, doublereal *rt1r, doublereal *rt1i, - doublereal *rt2r, doublereal *rt2i, doublereal *cs, - doublereal *sn); -extern int dlapll_(integer *n, doublereal *x, integer *incx, doublereal *y, - integer *incy, doublereal *ssmin); -extern int dlapmt_(logical *forwrd, integer *m, integer *n, doublereal *x, - integer *ldx, integer *k); -extern doublereal dlapy2_(doublereal *x, doublereal *y); -extern doublereal dlapy3_(doublereal *x, doublereal *y, doublereal *z__); -extern int dlaqgb_(integer *m, integer *n, integer *kl, integer *ku, - doublereal *ab, integer *ldab, doublereal *r__, - doublereal *c__, doublereal *rowcnd, doublereal *colcnd, - doublereal *amax, char *equed, ftnlen equed_len); -extern int dlaqge_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, char *equed, - ftnlen equed_len); -extern int dlaqp2_(integer *m, integer *n, integer *offset, doublereal *a, - integer *lda, integer *jpvt, doublereal *tau, - doublereal *vn1, doublereal *vn2, doublereal *work); -extern int dlaqps_(integer *m, integer *n, integer *offset, integer *nb, - integer *kb, doublereal *a, integer *lda, integer *jpvt, - doublereal *tau, doublereal *vn1, doublereal *vn2, - doublereal *auxv, doublereal *f, integer *ldf); -extern int dlaqsb_(char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, doublereal *s, doublereal *scond, - doublereal *amax, char *equed, ftnlen uplo_len, - ftnlen equed_len); -extern int dlaqsp_(char *uplo, integer *n, doublereal *ap, doublereal *s, - doublereal *scond, doublereal *amax, char *equed, - ftnlen uplo_len, ftnlen equed_len); -extern int dlaqsy_(char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *s, doublereal *scond, doublereal *amax, - char *equed, ftnlen uplo_len, ftnlen equed_len); -extern int dlaqtr_(logical *ltran, logical *lreal, integer *n, doublereal *t, - integer *ldt, doublereal *b, doublereal *w, - doublereal *scale, doublereal *x, doublereal *work, - integer *info); -extern int dlar1v_(integer *n, integer *b1, integer *bn, doublereal *sigma, - doublereal *d__, doublereal *l, doublereal *ld, - doublereal *lld, doublereal *gersch, doublereal *z__, - doublereal *ztz, doublereal *mingma, integer *r__, - integer *isuppz, doublereal *work); -extern int dlar2v_(integer *n, doublereal *x, doublereal *y, doublereal *z__, - integer *incx, doublereal *c__, doublereal *s, - integer *incc); -extern int dlarf_(char *side, integer *m, integer *n, doublereal *v, - integer *incv, doublereal *tau, doublereal *c__, integer *ldc, - doublereal *work, ftnlen side_len); -extern int dlarfb_(char *side, char *trans, char *direct, char *storev, - integer *m, integer *n, integer *k, doublereal *v, - integer *ldv, doublereal *t, integer *ldt, doublereal *c__, - integer *ldc, doublereal *work, integer *ldwork, - ftnlen side_len, ftnlen trans_len, ftnlen direct_len, - ftnlen storev_len); -extern int dlarfg_(integer *n, doublereal *alpha, doublereal *x, integer *incx, - doublereal *tau); -extern int dlarft_(char *direct, char *storev, integer *n, integer *k, - doublereal *v, integer *ldv, doublereal *tau, doublereal *t, - integer *ldt, ftnlen direct_len, ftnlen storev_len); -extern int dlarfx_(char *side, integer *m, integer *n, doublereal *v, - doublereal *tau, doublereal *c__, integer *ldc, - doublereal *work, ftnlen side_len); -extern int dlargv_(integer *n, doublereal *x, integer *incx, doublereal *y, - integer *incy, doublereal *c__, integer *incc); -extern int dlarnv_(integer *idist, integer *iseed, integer *n, doublereal *x); -extern int dlarrb_(integer *n, doublereal *d__, doublereal *l, doublereal *ld, - doublereal *lld, integer *ifirst, integer *ilast, - doublereal *sigma, doublereal *reltol, doublereal *w, - doublereal *wgap, doublereal *werr, doublereal *work, - integer *iwork, integer *info); -extern int dlarre_(integer *n, doublereal *d__, doublereal *e, doublereal *tol, - integer *nsplit, integer *isplit, integer *m, doublereal *w, - doublereal *woff, doublereal *gersch, doublereal *work, - integer *info); -extern int dlarrf_(integer *n, doublereal *d__, doublereal *l, doublereal *ld, - doublereal *lld, integer *ifirst, integer *ilast, - doublereal *w, doublereal *dplus, doublereal *lplus, - doublereal *work, integer *iwork, integer *info); -extern int dlarrv_(integer *n, doublereal *d__, doublereal *l, integer *isplit, - integer *m, doublereal *w, integer *iblock, - doublereal *gersch, doublereal *tol, doublereal *z__, - integer *ldz, integer *isuppz, doublereal *work, - integer *iwork, integer *info); -extern int dlartg_(doublereal *f, doublereal *g, doublereal *cs, doublereal *sn, - doublereal *r__); -extern int dlartv_(integer *n, doublereal *x, integer *incx, doublereal *y, - integer *incy, doublereal *c__, doublereal *s, - integer *incc); -extern int dlaruv_(integer *iseed, integer *n, doublereal *x); -extern int dlarz_(char *side, integer *m, integer *n, integer *l, doublereal *v, - integer *incv, doublereal *tau, doublereal *c__, integer *ldc, - doublereal *work, ftnlen side_len); -extern int dlarzb_(char *side, char *trans, char *direct, char *storev, - integer *m, integer *n, integer *k, integer *l, - doublereal *v, integer *ldv, doublereal *t, integer *ldt, - doublereal *c__, integer *ldc, doublereal *work, - integer *ldwork, ftnlen side_len, ftnlen trans_len, - ftnlen direct_len, ftnlen storev_len); -extern int dlarzt_(char *direct, char *storev, integer *n, integer *k, - doublereal *v, integer *ldv, doublereal *tau, doublereal *t, - integer *ldt, ftnlen direct_len, ftnlen storev_len); -extern int dlas2_(doublereal *f, doublereal *g, doublereal *h__, - doublereal *ssmin, doublereal *ssmax); -extern int dlascl_(char *type__, integer *kl, integer *ku, doublereal *cfrom, - doublereal *cto, integer *m, integer *n, doublereal *a, - integer *lda, integer *info, ftnlen type_len); -extern int dlasd0_(integer *n, integer *sqre, doublereal *d__, doublereal *e, - doublereal *u, integer *ldu, doublereal *vt, integer *ldvt, - integer *smlsiz, integer *iwork, doublereal *work, - integer *info); -extern int dlasd1_(integer *nl, integer *nr, integer *sqre, doublereal *d__, - doublereal *alpha, doublereal *beta, doublereal *u, - integer *ldu, doublereal *vt, integer *ldvt, integer *idxq, - integer *iwork, doublereal *work, integer *info); -extern int dlasd2_(integer *nl, integer *nr, integer *sqre, integer *k, - doublereal *d__, doublereal *z__, doublereal *alpha, - doublereal *beta, doublereal *u, integer *ldu, - doublereal *vt, integer *ldvt, doublereal *dsigma, - doublereal *u2, integer *ldu2, doublereal *vt2, - integer *ldvt2, integer *idxp, integer *idx, integer *idxc, - integer *idxq, integer *coltyp, integer *info); -extern int dlasd3_(integer *nl, integer *nr, integer *sqre, integer *k, - doublereal *d__, doublereal *q, integer *ldq, - doublereal *dsigma, doublereal *u, integer *ldu, - doublereal *u2, integer *ldu2, doublereal *vt, integer *ldvt, - doublereal *vt2, integer *ldvt2, integer *idxc, - integer *ctot, doublereal *z__, integer *info); -extern int dlasd4_(integer *n, integer *i__, doublereal *d__, doublereal *z__, - doublereal *delta, doublereal *rho, doublereal *sigma, - doublereal *work, integer *info); -extern int dlasd5_(integer *i__, doublereal *d__, doublereal *z__, - doublereal *delta, doublereal *rho, doublereal *dsigma, - doublereal *work); -extern int dlasd6_(integer *icompq, integer *nl, integer *nr, integer *sqre, - doublereal *d__, doublereal *vf, doublereal *vl, - doublereal *alpha, doublereal *beta, integer *idxq, - integer *perm, integer *givptr, integer *givcol, - integer *ldgcol, doublereal *givnum, integer *ldgnum, - doublereal *poles, doublereal *difl, doublereal *difr, - doublereal *z__, integer *k, doublereal *c__, doublereal *s, - doublereal *work, integer *iwork, integer *info); -extern int dlasd7_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *k, doublereal *d__, doublereal *z__, doublereal *zw, - doublereal *vf, doublereal *vfw, doublereal *vl, - doublereal *vlw, doublereal *alpha, doublereal *beta, - doublereal *dsigma, integer *idx, integer *idxp, - integer *idxq, integer *perm, integer *givptr, - integer *givcol, integer *ldgcol, doublereal *givnum, - integer *ldgnum, doublereal *c__, doublereal *s, - integer *info); -extern int dlasd8_(integer *icompq, integer *k, doublereal *d__, - doublereal *z__, doublereal *vf, doublereal *vl, - doublereal *difl, doublereal *difr, integer *lddifr, - doublereal *dsigma, doublereal *work, integer *info); -extern int dlasd9_(integer *icompq, integer *ldu, integer *k, doublereal *d__, - doublereal *z__, doublereal *vf, doublereal *vl, - doublereal *difl, doublereal *difr, doublereal *dsigma, - doublereal *work, integer *info); -extern int dlasda_(integer *icompq, integer *smlsiz, integer *n, integer *sqre, - doublereal *d__, doublereal *e, doublereal *u, integer *ldu, - doublereal *vt, integer *k, doublereal *difl, - doublereal *difr, doublereal *z__, doublereal *poles, - integer *givptr, integer *givcol, integer *ldgcol, - integer *perm, doublereal *givnum, doublereal *c__, - doublereal *s, doublereal *work, integer *iwork, - integer *info); -extern int dlasdq_(char *uplo, integer *sqre, integer *n, integer *ncvt, - integer *nru, integer *ncc, doublereal *d__, doublereal *e, - doublereal *vt, integer *ldvt, doublereal *u, integer *ldu, - doublereal *c__, integer *ldc, doublereal *work, - integer *info, ftnlen uplo_len); -extern int dlasdt_(integer *n, integer *lvl, integer *nd, integer *inode, - integer *ndiml, integer *ndimr, integer *msub); -extern int dlaset_(char *uplo, integer *m, integer *n, doublereal *alpha, - doublereal *beta, doublereal *a, integer *lda, - ftnlen uplo_len); -extern int dlasq1_(integer *n, doublereal *d__, doublereal *e, doublereal *work, - integer *info); -extern int dlasq2_(integer *n, doublereal *z__, integer *info); -extern int dlasq3_(integer *i0, integer *n0, doublereal *z__, integer *pp, - doublereal *dmin__, doublereal *sigma, doublereal *desig, - doublereal *qmax, integer *nfail, integer *iter, - integer *ndiv); -extern int dlasq4_(integer *i0, integer *n0, doublereal *z__, integer *pp, - integer *n0in, doublereal *dmin__, doublereal *dmin1, - doublereal *dmin2, doublereal *dn, doublereal *dn1, - doublereal *dn2, doublereal *tau, integer *ttype); -extern int dlasq5_(integer *i0, integer *n0, doublereal *z__, integer *pp, - doublereal *tau, doublereal *dmin__, doublereal *dmin1, - doublereal *dmin2, doublereal *dn, doublereal *dnm1, - doublereal *dnm2); -extern int dlasq6_(integer *i0, integer *n0, doublereal *z__, integer *pp, - doublereal *dmin__, doublereal *dmin1, doublereal *dmin2, - doublereal *dn, doublereal *dnm1, doublereal *dnm2); -extern int dlasr_(char *side, char *pivot, char *direct, integer *m, integer *n, - doublereal *c__, doublereal *s, doublereal *a, integer *lda, - ftnlen side_len, ftnlen pivot_len, ftnlen direct_len); -extern int dlasrt_(char *id, integer *n, doublereal *d__, integer *info, - ftnlen id_len); -extern int dlassq_(integer *n, doublereal *x, integer *incx, doublereal *scale, - doublereal *sumsq); -extern int dlasv2_(doublereal *f, doublereal *g, doublereal *h__, - doublereal *ssmin, doublereal *ssmax, doublereal *snr, - doublereal *csr, doublereal *snl, doublereal *csl); -extern int dlaswp_(integer *n, doublereal *a, integer *lda, integer *k1, - integer *k2, integer *ipiv, integer *incx); -extern int dlasy2_(logical *ltranl, logical *ltranr, integer *isgn, integer *n1, - integer *n2, doublereal *tl, integer *ldtl, doublereal *tr, - integer *ldtr, doublereal *b, integer *ldb, - doublereal *scale, doublereal *x, integer *ldx, - doublereal *xnorm, integer *info); -extern int dlasyf_(char *uplo, integer *n, integer *nb, integer *kb, - doublereal *a, integer *lda, integer *ipiv, doublereal *w, - integer *ldw, integer *info, ftnlen uplo_len); -extern int dlatbs_(char *uplo, char *trans, char *diag, char *normin, - integer *n, integer *kd, doublereal *ab, integer *ldab, - doublereal *x, doublereal *scale, doublereal *cnorm, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len, ftnlen normin_len); -extern int dlatdf_(integer *ijob, integer *n, doublereal *z__, integer *ldz, - doublereal *rhs, doublereal *rdsum, doublereal *rdscal, - integer *ipiv, integer *jpiv); -extern int dlatps_(char *uplo, char *trans, char *diag, char *normin, - integer *n, doublereal *ap, doublereal *x, doublereal *scale, - doublereal *cnorm, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len, ftnlen normin_len); -extern int dlatrd_(char *uplo, integer *n, integer *nb, doublereal *a, - integer *lda, doublereal *e, doublereal *tau, doublereal *w, - integer *ldw, ftnlen uplo_len); -extern int dlatrs_(char *uplo, char *trans, char *diag, char *normin, - integer *n, doublereal *a, integer *lda, doublereal *x, - doublereal *scale, doublereal *cnorm, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len, - ftnlen normin_len); -extern int dlatrz_(integer *m, integer *n, integer *l, doublereal *a, - integer *lda, doublereal *tau, doublereal *work); -extern int dlatzm_(char *side, integer *m, integer *n, doublereal *v, - integer *incv, doublereal *tau, doublereal *c1, - doublereal *c2, integer *ldc, doublereal *work, - ftnlen side_len); -extern int dlauu2_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int dlauum_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int dopgtr_(char *uplo, integer *n, doublereal *ap, doublereal *tau, - doublereal *q, integer *ldq, doublereal *work, integer *info, - ftnlen uplo_len); -extern int dopmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - doublereal *ap, doublereal *tau, doublereal *c__, - integer *ldc, doublereal *work, integer *info, - ftnlen side_len, ftnlen uplo_len, ftnlen trans_len); -extern int dorg2l_(integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *info); -extern int dorg2r_(integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *info); -extern int dorgbr_(char *vect, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *work, integer *lwork, integer *info, - ftnlen vect_len); -extern int dorghr_(integer *n, integer *ilo, integer *ihi, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *lwork, integer *info); -extern int dorgl2_(integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *info); -extern int dorglq_(integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *lwork, integer *info); -extern int dorgql_(integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *lwork, integer *info); -extern int dorgqr_(integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *lwork, integer *info); -extern int dorgr2_(integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *info); -extern int dorgrq_(integer *m, integer *n, integer *k, doublereal *a, - integer *lda, doublereal *tau, doublereal *work, - integer *lwork, integer *info); -extern int dorgtr_(char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, - integer *info, ftnlen uplo_len); -extern int dorm2l_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int dorm2r_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int dormbr_(char *vect, char *side, char *trans, integer *m, integer *n, - integer *k, doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *lwork, integer *info, ftnlen vect_len, - ftnlen side_len, ftnlen trans_len); -extern int dormhr_(char *side, char *trans, integer *m, integer *n, - integer *ilo, integer *ihi, doublereal *a, integer *lda, - doublereal *tau, doublereal *c__, integer *ldc, - doublereal *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int dorml2_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int dormlq_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int dormql_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int dormqr_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int dormr2_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int dormr3_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int dormrq_(char *side, char *trans, integer *m, integer *n, integer *k, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int dormrz_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int dormtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - doublereal *a, integer *lda, doublereal *tau, - doublereal *c__, integer *ldc, doublereal *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen uplo_len, ftnlen trans_len); -extern int dpbcon_(char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, doublereal *anorm, doublereal *rcond, - doublereal *work, integer *iwork, integer *info, - ftnlen uplo_len); -extern int dpbequ_(char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, doublereal *s, doublereal *scond, - doublereal *amax, integer *info, ftnlen uplo_len); -extern int dpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, - doublereal *ab, integer *ldab, doublereal *afb, - integer *ldafb, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info, - ftnlen uplo_len); -extern int dpbstf_(char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int dpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, - doublereal *ab, integer *ldab, doublereal *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int dpbsvx_(char *fact, char *uplo, integer *n, integer *kd, - integer *nrhs, doublereal *ab, integer *ldab, - doublereal *afb, integer *ldafb, char *equed, doublereal *s, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info, - ftnlen fact_len, ftnlen uplo_len, ftnlen equed_len); -extern int dpbtf2_(char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int dpbtrf_(char *uplo, integer *n, integer *kd, doublereal *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int dpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, - doublereal *ab, integer *ldab, doublereal *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int dpocon_(char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *anorm, doublereal *rcond, doublereal *work, - integer *iwork, integer *info, ftnlen uplo_len); -extern int dpoequ_(integer *n, doublereal *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, integer *info); -extern int dporfs_(char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, - integer *info, ftnlen uplo_len); -extern int dposv_(char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int dposvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublereal *a, integer *lda, doublereal *af, integer *ldaf, - char *equed, doublereal *s, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info, ftnlen fact_len, - ftnlen uplo_len, ftnlen equed_len); -extern int dpotf2_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int dpotrf_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int dpotri_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int dpotrs_(char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int dppcon_(char *uplo, integer *n, doublereal *ap, doublereal *anorm, - doublereal *rcond, doublereal *work, integer *iwork, - integer *info, ftnlen uplo_len); -extern int dppequ_(char *uplo, integer *n, doublereal *ap, doublereal *s, - doublereal *scond, doublereal *amax, integer *info, - ftnlen uplo_len); -extern int dpprfs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, - doublereal *afp, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info, - ftnlen uplo_len); -extern int dppsv_(char *uplo, integer *n, integer *nrhs, doublereal *ap, - doublereal *b, integer *ldb, integer *info, ftnlen uplo_len); -extern int dppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublereal *ap, doublereal *afp, char *equed, doublereal *s, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info, - ftnlen fact_len, ftnlen uplo_len, ftnlen equed_len); -extern int dpptrf_(char *uplo, integer *n, doublereal *ap, integer *info, - ftnlen uplo_len); -extern int dpptri_(char *uplo, integer *n, doublereal *ap, integer *info, - ftnlen uplo_len); -extern int dpptrs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, - doublereal *b, integer *ldb, integer *info, ftnlen uplo_len); -extern int dptcon_(integer *n, doublereal *d__, doublereal *e, - doublereal *anorm, doublereal *rcond, doublereal *work, - integer *info); -extern int dpteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, - integer *info, ftnlen compz_len); -extern int dptrfs_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *df, doublereal *ef, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *info); -extern int dptsv_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *b, integer *ldb, integer *info); -extern int dptsvx_(char *fact, integer *n, integer *nrhs, doublereal *d__, - doublereal *e, doublereal *df, doublereal *ef, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublereal *work, - integer *info, ftnlen fact_len); -extern int dpttrf_(integer *n, doublereal *d__, doublereal *e, integer *info); -extern int dpttrs_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *b, integer *ldb, integer *info); -extern int dptts2_(integer *n, integer *nrhs, doublereal *d__, doublereal *e, - doublereal *b, integer *ldb); -extern int drscl_(integer *n, doublereal *sa, doublereal *sx, integer *incx); -extern int dsbev_(char *jobz, char *uplo, integer *n, integer *kd, - doublereal *ab, integer *ldab, doublereal *w, doublereal *z__, - integer *ldz, doublereal *work, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int dsbevd_(char *jobz, char *uplo, integer *n, integer *kd, - doublereal *ab, integer *ldab, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int dsbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, - doublereal *ab, integer *ldab, doublereal *q, integer *ldq, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int dsbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, - doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, - doublereal *x, integer *ldx, doublereal *work, integer *info, - ftnlen vect_len, ftnlen uplo_len); -extern int dsbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, - doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int dsbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - doublereal *ab, integer *ldab, doublereal *bb, integer *ldbb, - doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int dsbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, - integer *kb, doublereal *ab, integer *ldab, doublereal *bb, - integer *ldbb, doublereal *q, integer *ldq, doublereal *vl, - doublereal *vu, integer *il, integer *iu, doublereal *abstol, - integer *m, doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int dsbtrd_(char *vect, char *uplo, integer *n, integer *kd, - doublereal *ab, integer *ldab, doublereal *d__, - doublereal *e, doublereal *q, integer *ldq, doublereal *work, - integer *info, ftnlen vect_len, ftnlen uplo_len); -extern doublereal dsecnd_(void); -extern int dspcon_(char *uplo, integer *n, doublereal *ap, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublereal *work, - integer *iwork, integer *info, ftnlen uplo_len); -extern int dspev_(char *jobz, char *uplo, integer *n, doublereal *ap, - doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int dspevd_(char *jobz, char *uplo, integer *n, doublereal *ap, - doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int dspevx_(char *jobz, char *range, char *uplo, integer *n, - doublereal *ap, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int dspgst_(integer *itype, char *uplo, integer *n, doublereal *ap, - doublereal *bp, integer *info, ftnlen uplo_len); -extern int dspgv_(integer *itype, char *jobz, char *uplo, integer *n, - doublereal *ap, doublereal *bp, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int dspgvd_(integer *itype, char *jobz, char *uplo, integer *n, - doublereal *ap, doublereal *bp, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int dspgvx_(integer *itype, char *jobz, char *range, char *uplo, - integer *n, doublereal *ap, doublereal *bp, doublereal *vl, - doublereal *vu, integer *il, integer *iu, doublereal *abstol, - integer *m, doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int dsprfs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, - doublereal *afp, integer *ipiv, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, - integer *info, ftnlen uplo_len); -extern int dspsv_(char *uplo, integer *n, integer *nrhs, doublereal *ap, - integer *ipiv, doublereal *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int dspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublereal *ap, doublereal *afp, integer *ipiv, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublereal *work, integer *iwork, integer *info, - ftnlen fact_len, ftnlen uplo_len); -extern int dsptrd_(char *uplo, integer *n, doublereal *ap, doublereal *d__, - doublereal *e, doublereal *tau, integer *info, - ftnlen uplo_len); -extern int dsptrf_(char *uplo, integer *n, doublereal *ap, integer *ipiv, - integer *info, ftnlen uplo_len); -extern int dsptri_(char *uplo, integer *n, doublereal *ap, integer *ipiv, - doublereal *work, integer *info, ftnlen uplo_len); -extern int dsptrs_(char *uplo, integer *n, integer *nrhs, doublereal *ap, - integer *ipiv, doublereal *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int dstebz_(char *range, char *order, integer *n, doublereal *vl, - doublereal *vu, integer *il, integer *iu, doublereal *abstol, - doublereal *d__, doublereal *e, integer *m, integer *nsplit, - doublereal *w, integer *iblock, integer *isplit, - doublereal *work, integer *iwork, integer *info, - ftnlen range_len, ftnlen order_len); -extern int dstedc_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info, ftnlen compz_len); -extern int dstegr_(char *jobz, char *range, integer *n, doublereal *d__, - doublereal *e, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublereal *z__, integer *ldz, integer *isuppz, - doublereal *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len); -extern int dstein_(integer *n, doublereal *d__, doublereal *e, integer *m, - doublereal *w, integer *iblock, integer *isplit, - doublereal *z__, integer *ldz, doublereal *work, - integer *iwork, integer *ifail, integer *info); -extern int dsteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, - integer *info, ftnlen compz_len); -extern int dsterf_(integer *n, doublereal *d__, doublereal *e, integer *info); -extern int dstev_(char *jobz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, - integer *info, ftnlen jobz_len); -extern int dstevd_(char *jobz, integer *n, doublereal *d__, doublereal *e, - doublereal *z__, integer *ldz, doublereal *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len); -extern int dstevr_(char *jobz, char *range, integer *n, doublereal *d__, - doublereal *e, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublereal *z__, integer *ldz, integer *isuppz, - doublereal *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len); -extern int dstevx_(char *jobz, char *range, integer *n, doublereal *d__, - doublereal *e, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len); -extern int dsycon_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *ipiv, doublereal *anorm, doublereal *rcond, - doublereal *work, integer *iwork, integer *info, - ftnlen uplo_len); -extern int dsyev_(char *jobz, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *w, doublereal *work, integer *lwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int dsyevd_(char *jobz, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *w, doublereal *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int dsyevr_(char *jobz, char *range, char *uplo, integer *n, - doublereal *a, integer *lda, doublereal *vl, doublereal *vu, - integer *il, integer *iu, doublereal *abstol, integer *m, - doublereal *w, doublereal *z__, integer *ldz, - integer *isuppz, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int dsyevx_(char *jobz, char *range, char *uplo, integer *n, - doublereal *a, integer *lda, doublereal *vl, doublereal *vu, - integer *il, integer *iu, doublereal *abstol, integer *m, - doublereal *w, doublereal *z__, integer *ldz, - doublereal *work, integer *lwork, integer *iwork, - integer *ifail, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int dsygs2_(integer *itype, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int dsygst_(integer *itype, char *uplo, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int dsygv_(integer *itype, char *jobz, char *uplo, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *w, doublereal *work, integer *lwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int dsygvd_(integer *itype, char *jobz, char *uplo, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *w, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int dsygvx_(integer *itype, char *jobz, char *range, char *uplo, - integer *n, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublereal *z__, integer *ldz, doublereal *work, - integer *lwork, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int dsyrfs_(char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, doublereal *af, integer *ldaf, integer *ipiv, - doublereal *b, integer *ldb, doublereal *x, integer *ldx, - doublereal *ferr, doublereal *berr, doublereal *work, - integer *iwork, integer *info, ftnlen uplo_len); -extern int dsysv_(char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, integer *ipiv, doublereal *b, integer *ldb, - doublereal *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int dsysvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublereal *a, integer *lda, doublereal *af, integer *ldaf, - integer *ipiv, doublereal *b, integer *ldb, doublereal *x, - integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublereal *work, integer *lwork, - integer *iwork, integer *info, ftnlen fact_len, - ftnlen uplo_len); -extern int dsytd2_(char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *d__, doublereal *e, doublereal *tau, - integer *info, ftnlen uplo_len); -extern int dsytf2_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *ipiv, integer *info, ftnlen uplo_len); -extern int dsytrd_(char *uplo, integer *n, doublereal *a, integer *lda, - doublereal *d__, doublereal *e, doublereal *tau, - doublereal *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int dsytrf_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *ipiv, doublereal *work, integer *lwork, - integer *info, ftnlen uplo_len); -extern int dsytri_(char *uplo, integer *n, doublereal *a, integer *lda, - integer *ipiv, doublereal *work, integer *info, - ftnlen uplo_len); -extern int dsytrs_(char *uplo, integer *n, integer *nrhs, doublereal *a, - integer *lda, integer *ipiv, doublereal *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int dtbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, - doublereal *ab, integer *ldab, doublereal *rcond, - doublereal *work, integer *iwork, integer *info, - ftnlen norm_len, ftnlen uplo_len, ftnlen diag_len); -extern int dtbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, doublereal *ab, integer *ldab, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int dtbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, doublereal *ab, integer *ldab, doublereal *b, - integer *ldb, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int dtgevc_(char *side, char *howmny, logical *select, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, - integer *mm, integer *m, doublereal *work, integer *info, - ftnlen side_len, ftnlen howmny_len); -extern int dtgex2_(logical *wantq, logical *wantz, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *q, - integer *ldq, doublereal *z__, integer *ldz, integer *j1, - integer *n1, integer *n2, doublereal *work, integer *lwork, - integer *info); -extern int dtgexc_(logical *wantq, logical *wantz, integer *n, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *q, - integer *ldq, doublereal *z__, integer *ldz, integer *ifst, - integer *ilst, doublereal *work, integer *lwork, - integer *info); -extern int dtgsen_(integer *ijob, logical *wantq, logical *wantz, - logical *select, integer *n, doublereal *a, integer *lda, - doublereal *b, integer *ldb, doublereal *alphar, - doublereal *alphai, doublereal *beta, doublereal *q, - integer *ldq, doublereal *z__, integer *ldz, integer *m, - doublereal *pl, doublereal *pr, doublereal *dif, - doublereal *work, integer *lwork, integer *iwork, - integer *liwork, integer *info); -extern int dtgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, - integer *n, integer *k, integer *l, doublereal *a, - integer *lda, doublereal *b, integer *ldb, doublereal *tola, - doublereal *tolb, doublereal *alpha, doublereal *beta, - doublereal *u, integer *ldu, doublereal *v, integer *ldv, - doublereal *q, integer *ldq, doublereal *work, - integer *ncycle, integer *info, ftnlen jobu_len, - ftnlen jobv_len, ftnlen jobq_len); -extern int dtgsna_(char *job, char *howmny, logical *select, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *vl, integer *ldvl, doublereal *vr, integer *ldvr, - doublereal *s, doublereal *dif, integer *mm, integer *m, - doublereal *work, integer *lwork, integer *iwork, - integer *info, ftnlen job_len, ftnlen howmny_len); -extern int dtgsy2_(char *trans, integer *ijob, integer *m, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *c__, integer *ldc, doublereal *d__, integer *ldd, - doublereal *e, integer *lde, doublereal *f, integer *ldf, - doublereal *scale, doublereal *rdsum, doublereal *rdscal, - integer *iwork, integer *pq, integer *info, - ftnlen trans_len); -extern int dtgsyl_(char *trans, integer *ijob, integer *m, integer *n, - doublereal *a, integer *lda, doublereal *b, integer *ldb, - doublereal *c__, integer *ldc, doublereal *d__, integer *ldd, - doublereal *e, integer *lde, doublereal *f, integer *ldf, - doublereal *scale, doublereal *dif, doublereal *work, - integer *lwork, integer *iwork, integer *info, - ftnlen trans_len); -extern int dtpcon_(char *norm, char *uplo, char *diag, integer *n, - doublereal *ap, doublereal *rcond, doublereal *work, - integer *iwork, integer *info, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern int dtprfs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, doublereal *ap, doublereal *b, integer *ldb, - doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int dtptri_(char *uplo, char *diag, integer *n, doublereal *ap, - integer *info, ftnlen uplo_len, ftnlen diag_len); -extern int dtptrs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, doublereal *ap, doublereal *b, integer *ldb, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int dtrcon_(char *norm, char *uplo, char *diag, integer *n, - doublereal *a, integer *lda, doublereal *rcond, - doublereal *work, integer *iwork, integer *info, - ftnlen norm_len, ftnlen uplo_len, ftnlen diag_len); -extern int dtrevc_(char *side, char *howmny, logical *select, integer *n, - doublereal *t, integer *ldt, doublereal *vl, integer *ldvl, - doublereal *vr, integer *ldvr, integer *mm, integer *m, - doublereal *work, integer *info, ftnlen side_len, - ftnlen howmny_len); -extern int dtrexc_(char *compq, integer *n, doublereal *t, integer *ldt, - doublereal *q, integer *ldq, integer *ifst, integer *ilst, - doublereal *work, integer *info, ftnlen compq_len); -extern int dtrrfs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublereal *work, integer *iwork, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int dtrsen_(char *job, char *compq, logical *select, integer *n, - doublereal *t, integer *ldt, doublereal *q, integer *ldq, - doublereal *wr, doublereal *wi, integer *m, doublereal *s, - doublereal *sep, doublereal *work, integer *lwork, - integer *iwork, integer *liwork, integer *info, - ftnlen job_len, ftnlen compq_len); -extern int dtrsna_(char *job, char *howmny, logical *select, integer *n, - doublereal *t, integer *ldt, doublereal *vl, integer *ldvl, - doublereal *vr, integer *ldvr, doublereal *s, - doublereal *sep, integer *mm, integer *m, doublereal *work, - integer *ldwork, integer *iwork, integer *info, - ftnlen job_len, ftnlen howmny_len); -extern int dtrsyl_(char *trana, char *tranb, integer *isgn, integer *m, - integer *n, doublereal *a, integer *lda, doublereal *b, - integer *ldb, doublereal *c__, integer *ldc, - doublereal *scale, integer *info, ftnlen trana_len, - ftnlen tranb_len); -extern int dtrti2_(char *uplo, char *diag, integer *n, doublereal *a, - integer *lda, integer *info, ftnlen uplo_len, - ftnlen diag_len); -extern int dtrtri_(char *uplo, char *diag, integer *n, doublereal *a, - integer *lda, integer *info, ftnlen uplo_len, - ftnlen diag_len); -extern int dtrtrs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, doublereal *a, integer *lda, doublereal *b, - integer *ldb, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int dtzrqf_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, integer *info); -extern int dtzrzf_(integer *m, integer *n, doublereal *a, integer *lda, - doublereal *tau, doublereal *work, integer *lwork, - integer *info); -extern doublereal dzsum1_(integer *n, doublecomplex *cx, integer *incx); -extern integer icmax1_(integer *n, complex *cx, integer *incx); -extern integer ieeeck_(integer *ispec, real *zero, real *one); -extern integer ilaenv_(integer *ispec, char *name__, char *opts, integer *n1, - integer *n2, integer *n3, integer *n4, ftnlen name_len, - ftnlen opts_len); -extern integer izmax1_(integer *n, doublecomplex *cx, integer *incx); -extern logical lsame_(char *ca, char *cb, ftnlen ca_len, ftnlen cb_len); -extern logical lsamen_(integer *n, char *ca, char *cb, ftnlen ca_len, - ftnlen cb_len); -extern int sbdsdc_(char *uplo, char *compq, integer *n, real *d__, real *e, - real *u, integer *ldu, real *vt, integer *ldvt, real *q, - integer *iq, real *work, integer *iwork, integer *info, - ftnlen uplo_len, ftnlen compq_len); -extern int sbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, - integer *ncc, real *d__, real *e, real *vt, integer *ldvt, - real *u, integer *ldu, real *c__, integer *ldc, real *work, - integer *info, ftnlen uplo_len); -extern E_f scsum1_(integer *n, complex *cx, integer *incx); -extern int sdisna_(char *job, integer *m, integer *n, real *d__, real *sep, - integer *info, ftnlen job_len); -extern E_f second_(void); -extern int sgbbrd_(char *vect, integer *m, integer *n, integer *ncc, - integer *kl, integer *ku, real *ab, integer *ldab, real *d__, - real *e, real *q, integer *ldq, real *pt, integer *ldpt, - real *c__, integer *ldc, real *work, integer *info, - ftnlen vect_len); -extern int sgbcon_(char *norm, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, integer *ipiv, real *anorm, real *rcond, - real *work, integer *iwork, integer *info, ftnlen norm_len); -extern int sgbequ_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, real *r__, real *c__, real *rowcnd, - real *colcnd, real *amax, integer *info); -extern int sgbrfs_(char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, real *ab, integer *ldab, real *afb, - integer *ldafb, integer *ipiv, real *b, integer *ldb, - real *x, integer *ldx, real *ferr, real *berr, real *work, - integer *iwork, integer *info, ftnlen trans_len); -extern int sgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, real *ab, - integer *ldab, integer *ipiv, real *b, integer *ldb, - integer *info); -extern int sgbsvx_(char *fact, char *trans, integer *n, integer *kl, - integer *ku, integer *nrhs, real *ab, integer *ldab, - real *afb, integer *ldafb, integer *ipiv, char *equed, - real *r__, real *c__, real *b, integer *ldb, real *x, - integer *ldx, real *rcond, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen fact_len, - ftnlen trans_len, ftnlen equed_len); -extern int sgbtf2_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, integer *ipiv, integer *info); -extern int sgbtrf_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, integer *ipiv, integer *info); -extern int sgbtrs_(char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, real *ab, integer *ldab, integer *ipiv, - real *b, integer *ldb, integer *info, ftnlen trans_len); -extern int sgebak_(char *job, char *side, integer *n, integer *ilo, - integer *ihi, real *scale, integer *m, real *v, integer *ldv, - integer *info, ftnlen job_len, ftnlen side_len); -extern int sgebal_(char *job, integer *n, real *a, integer *lda, integer *ilo, - integer *ihi, real *scale, integer *info, ftnlen job_len); -extern int sgebd2_(integer *m, integer *n, real *a, integer *lda, real *d__, - real *e, real *tauq, real *taup, real *work, integer *info); -extern int sgebrd_(integer *m, integer *n, real *a, integer *lda, real *d__, - real *e, real *tauq, real *taup, real *work, integer *lwork, - integer *info); -extern int sgecon_(char *norm, integer *n, real *a, integer *lda, real *anorm, - real *rcond, real *work, integer *iwork, integer *info, - ftnlen norm_len); -extern int sgeequ_(integer *m, integer *n, real *a, integer *lda, real *r__, - real *c__, real *rowcnd, real *colcnd, real *amax, - integer *info); -extern int sgees_(char *jobvs, char *sort, L_fp select, integer *n, real *a, - integer *lda, integer *sdim, real *wr, real *wi, real *vs, - integer *ldvs, real *work, integer *lwork, logical *bwork, - integer *info, ftnlen jobvs_len, ftnlen sort_len); -extern int sgeesx_(char *jobvs, char *sort, L_fp select, char *sense, - integer *n, real *a, integer *lda, integer *sdim, real *wr, - real *wi, real *vs, integer *ldvs, real *rconde, - real *rcondv, real *work, integer *lwork, integer *iwork, - integer *liwork, logical *bwork, integer *info, - ftnlen jobvs_len, ftnlen sort_len, ftnlen sense_len); -extern int sgeev_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, - real *wr, real *wi, real *vl, integer *ldvl, real *vr, - integer *ldvr, real *work, integer *lwork, integer *info, - ftnlen jobvl_len, ftnlen jobvr_len); -extern int sgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, - integer *n, real *a, integer *lda, real *wr, real *wi, - real *vl, integer *ldvl, real *vr, integer *ldvr, - integer *ilo, integer *ihi, real *scale, real *abnrm, - real *rconde, real *rcondv, real *work, integer *lwork, - integer *iwork, integer *info, ftnlen balanc_len, - ftnlen jobvl_len, ftnlen jobvr_len, ftnlen sense_len); -extern int sgegs_(char *jobvsl, char *jobvsr, integer *n, real *a, integer *lda, - real *b, integer *ldb, real *alphar, real *alphai, real *beta, - real *vsl, integer *ldvsl, real *vsr, integer *ldvsr, - real *work, integer *lwork, integer *info, ftnlen jobvsl_len, - ftnlen jobvsr_len); -extern int sgegv_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, - real *b, integer *ldb, real *alphar, real *alphai, real *beta, - real *vl, integer *ldvl, real *vr, integer *ldvr, real *work, - integer *lwork, integer *info, ftnlen jobvl_len, - ftnlen jobvr_len); -extern int sgehd2_(integer *n, integer *ilo, integer *ihi, real *a, - integer *lda, real *tau, real *work, integer *info); -extern int sgehrd_(integer *n, integer *ilo, integer *ihi, real *a, - integer *lda, real *tau, real *work, integer *lwork, - integer *info); -extern int sgelq2_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *info); -extern int sgelqf_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); -extern int sgels_(char *trans, integer *m, integer *n, integer *nrhs, real *a, - integer *lda, real *b, integer *ldb, real *work, - integer *lwork, integer *info, ftnlen trans_len); -extern int sgelsd_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, - real *b, integer *ldb, real *s, real *rcond, integer *rank, - real *work, integer *lwork, integer *iwork, integer *info); -extern int sgelss_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, - real *b, integer *ldb, real *s, real *rcond, integer *rank, - real *work, integer *lwork, integer *info); -extern int sgelsx_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, - real *b, integer *ldb, integer *jpvt, real *rcond, - integer *rank, real *work, integer *info); -extern int sgelsy_(integer *m, integer *n, integer *nrhs, real *a, integer *lda, - real *b, integer *ldb, integer *jpvt, real *rcond, - integer *rank, real *work, integer *lwork, integer *info); -extern int sgeql2_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *info); -extern int sgeqlf_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); -extern int sgeqp3_(integer *m, integer *n, real *a, integer *lda, integer *jpvt, - real *tau, real *work, integer *lwork, integer *info); -extern int sgeqpf_(integer *m, integer *n, real *a, integer *lda, integer *jpvt, - real *tau, real *work, integer *info); -extern int sgeqr2_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *info); -extern int sgeqrf_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); -extern int sgerfs_(char *trans, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, - real *b, integer *ldb, real *x, integer *ldx, real *ferr, - real *berr, real *work, integer *iwork, integer *info, - ftnlen trans_len); -extern int sgerq2_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *info); -extern int sgerqf_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); -extern int sgesc2_(integer *n, real *a, integer *lda, real *rhs, integer *ipiv, - integer *jpiv, real *scale); -extern int sgesdd_(char *jobz, integer *m, integer *n, real *a, integer *lda, - real *s, real *u, integer *ldu, real *vt, integer *ldvt, - real *work, integer *lwork, integer *iwork, integer *info, - ftnlen jobz_len); -extern int sgesv_(integer *n, integer *nrhs, real *a, integer *lda, - integer *ipiv, real *b, integer *ldb, integer *info); -extern int sgesvd_(char *jobu, char *jobvt, integer *m, integer *n, real *a, - integer *lda, real *s, real *u, integer *ldu, real *vt, - integer *ldvt, real *work, integer *lwork, integer *info, - ftnlen jobu_len, ftnlen jobvt_len); -extern int sgesvx_(char *fact, char *trans, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, - char *equed, real *r__, real *c__, real *b, integer *ldb, - real *x, integer *ldx, real *rcond, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen fact_len, - ftnlen trans_len, ftnlen equed_len); -extern int sgetc2_(integer *n, real *a, integer *lda, integer *ipiv, - integer *jpiv, integer *info); -extern int sgetf2_(integer *m, integer *n, real *a, integer *lda, integer *ipiv, - integer *info); -extern int sgetrf_(integer *m, integer *n, real *a, integer *lda, integer *ipiv, - integer *info); -extern int sgetri_(integer *n, real *a, integer *lda, integer *ipiv, real *work, - integer *lwork, integer *info); -extern int sgetrs_(char *trans, integer *n, integer *nrhs, real *a, - integer *lda, integer *ipiv, real *b, integer *ldb, - integer *info, ftnlen trans_len); -extern int sggbak_(char *job, char *side, integer *n, integer *ilo, - integer *ihi, real *lscale, real *rscale, integer *m, - real *v, integer *ldv, integer *info, ftnlen job_len, - ftnlen side_len); -extern int sggbal_(char *job, integer *n, real *a, integer *lda, real *b, - integer *ldb, integer *ilo, integer *ihi, real *lscale, - real *rscale, real *work, integer *info, ftnlen job_len); -extern int sgges_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, - integer *n, real *a, integer *lda, real *b, integer *ldb, - integer *sdim, real *alphar, real *alphai, real *beta, - real *vsl, integer *ldvsl, real *vsr, integer *ldvsr, - real *work, integer *lwork, logical *bwork, integer *info, - ftnlen jobvsl_len, ftnlen jobvsr_len, ftnlen sort_len); -extern int sggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp selctg, - char *sense, integer *n, real *a, integer *lda, real *b, - integer *ldb, integer *sdim, real *alphar, real *alphai, - real *beta, real *vsl, integer *ldvsl, real *vsr, - integer *ldvsr, real *rconde, real *rcondv, real *work, - integer *lwork, integer *iwork, integer *liwork, - logical *bwork, integer *info, ftnlen jobvsl_len, - ftnlen jobvsr_len, ftnlen sort_len, ftnlen sense_len); -extern int sggev_(char *jobvl, char *jobvr, integer *n, real *a, integer *lda, - real *b, integer *ldb, real *alphar, real *alphai, real *beta, - real *vl, integer *ldvl, real *vr, integer *ldvr, real *work, - integer *lwork, integer *info, ftnlen jobvl_len, - ftnlen jobvr_len); -extern int sggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, - integer *n, real *a, integer *lda, real *b, integer *ldb, - real *alphar, real *alphai, real *beta, real *vl, - integer *ldvl, real *vr, integer *ldvr, integer *ilo, - integer *ihi, real *lscale, real *rscale, real *abnrm, - real *bbnrm, real *rconde, real *rcondv, real *work, - integer *lwork, integer *iwork, logical *bwork, - integer *info, ftnlen balanc_len, ftnlen jobvl_len, - ftnlen jobvr_len, ftnlen sense_len); -extern int sggglm_(integer *n, integer *m, integer *p, real *a, integer *lda, - real *b, integer *ldb, real *d__, real *x, real *y, - real *work, integer *lwork, integer *info); -extern int sgghrd_(char *compq, char *compz, integer *n, integer *ilo, - integer *ihi, real *a, integer *lda, real *b, integer *ldb, - real *q, integer *ldq, real *z__, integer *ldz, - integer *info, ftnlen compq_len, ftnlen compz_len); -extern int sgglse_(integer *m, integer *n, integer *p, real *a, integer *lda, - real *b, integer *ldb, real *c__, real *d__, real *x, - real *work, integer *lwork, integer *info); -extern int sggqrf_(integer *n, integer *m, integer *p, real *a, integer *lda, - real *taua, real *b, integer *ldb, real *taub, real *work, - integer *lwork, integer *info); -extern int sggrqf_(integer *m, integer *p, integer *n, real *a, integer *lda, - real *taua, real *b, integer *ldb, real *taub, real *work, - integer *lwork, integer *info); -extern int sggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, - integer *p, integer *k, integer *l, real *a, integer *lda, - real *b, integer *ldb, real *alpha, real *beta, real *u, - integer *ldu, real *v, integer *ldv, real *q, integer *ldq, - real *work, integer *iwork, integer *info, ftnlen jobu_len, - ftnlen jobv_len, ftnlen jobq_len); -extern int sggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, - integer *n, real *a, integer *lda, real *b, integer *ldb, - real *tola, real *tolb, integer *k, integer *l, real *u, - integer *ldu, real *v, integer *ldv, real *q, integer *ldq, - integer *iwork, real *tau, real *work, integer *info, - ftnlen jobu_len, ftnlen jobv_len, ftnlen jobq_len); -extern int sgtcon_(char *norm, integer *n, real *dl, real *d__, real *du, - real *du2, integer *ipiv, real *anorm, real *rcond, - real *work, integer *iwork, integer *info, ftnlen norm_len); -extern int sgtrfs_(char *trans, integer *n, integer *nrhs, real *dl, real *d__, - real *du, real *dlf, real *df, real *duf, real *du2, - integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, - real *ferr, real *berr, real *work, integer *iwork, - integer *info, ftnlen trans_len); -extern int sgtsv_(integer *n, integer *nrhs, real *dl, real *d__, real *du, - real *b, integer *ldb, integer *info); -extern int sgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, real *dl, - real *d__, real *du, real *dlf, real *df, real *duf, - real *du2, integer *ipiv, real *b, integer *ldb, real *x, - integer *ldx, real *rcond, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen fact_len, - ftnlen trans_len); -extern int sgttrf_(integer *n, real *dl, real *d__, real *du, real *du2, - integer *ipiv, integer *info); -extern int sgttrs_(char *trans, integer *n, integer *nrhs, real *dl, real *d__, - real *du, real *du2, integer *ipiv, real *b, integer *ldb, - integer *info, ftnlen trans_len); -extern int sgtts2_(integer *itrans, integer *n, integer *nrhs, real *dl, - real *d__, real *du, real *du2, integer *ipiv, real *b, - integer *ldb); -extern int shgeqz_(char *job, char *compq, char *compz, integer *n, - integer *ilo, integer *ihi, real *a, integer *lda, real *b, - integer *ldb, real *alphar, real *alphai, real *beta, - real *q, integer *ldq, real *z__, integer *ldz, real *work, - integer *lwork, integer *info, ftnlen job_len, - ftnlen compq_len, ftnlen compz_len); -extern int shsein_(char *side, char *eigsrc, char *initv, logical *select, - integer *n, real *h__, integer *ldh, real *wr, real *wi, - real *vl, integer *ldvl, real *vr, integer *ldvr, - integer *mm, integer *m, real *work, integer *ifaill, - integer *ifailr, integer *info, ftnlen side_len, - ftnlen eigsrc_len, ftnlen initv_len); -extern int shseqr_(char *job, char *compz, integer *n, integer *ilo, - integer *ihi, real *h__, integer *ldh, real *wr, real *wi, - real *z__, integer *ldz, real *work, integer *lwork, - integer *info, ftnlen job_len, ftnlen compz_len); -extern int slabad_(real *small, real *large); -extern int slabrd_(integer *m, integer *n, integer *nb, real *a, integer *lda, - real *d__, real *e, real *tauq, real *taup, real *x, - integer *ldx, real *y, integer *ldy); -extern int slacon_(integer *n, real *v, real *x, integer *isgn, real *est, - integer *kase); -extern int slacpy_(char *uplo, integer *m, integer *n, real *a, integer *lda, - real *b, integer *ldb, ftnlen uplo_len); -extern int sladiv_(real *a, real *b, real *c__, real *d__, real *p, real *q); -extern int slae2_(real *a, real *b, real *c__, real *rt1, real *rt2); -extern int slaebz_(integer *ijob, integer *nitmax, integer *n, integer *mmax, - integer *minp, integer *nbmin, real *abstol, real *reltol, - real *pivmin, real *d__, real *e, real *e2, integer *nval, - real *ab, real *c__, integer *mout, integer *nab, real *work, - integer *iwork, integer *info); -extern int slaed0_(integer *icompq, integer *qsiz, integer *n, real *d__, - real *e, real *q, integer *ldq, real *qstore, integer *ldqs, - real *work, integer *iwork, integer *info); -extern int slaed1_(integer *n, real *d__, real *q, integer *ldq, integer *indxq, - real *rho, integer *cutpnt, real *work, integer *iwork, - integer *info); -extern int slaed2_(integer *k, integer *n, integer *n1, real *d__, real *q, - integer *ldq, integer *indxq, real *rho, real *z__, - real *dlamda, real *w, real *q2, integer *indx, - integer *indxc, integer *indxp, integer *coltyp, - integer *info); -extern int slaed3_(integer *k, integer *n, integer *n1, real *d__, real *q, - integer *ldq, real *rho, real *dlamda, real *q2, - integer *indx, integer *ctot, real *w, real *s, - integer *info); -extern int slaed4_(integer *n, integer *i__, real *d__, real *z__, real *delta, - real *rho, real *dlam, integer *info); -extern int slaed5_(integer *i__, real *d__, real *z__, real *delta, real *rho, - real *dlam); -extern int slaed6_(integer *kniter, logical *orgati, real *rho, real *d__, - real *z__, real *finit, real *tau, integer *info); -extern int slaed7_(integer *icompq, integer *n, integer *qsiz, integer *tlvls, - integer *curlvl, integer *curpbm, real *d__, real *q, - integer *ldq, integer *indxq, real *rho, integer *cutpnt, - real *qstore, integer *qptr, integer *prmptr, integer *perm, - integer *givptr, integer *givcol, real *givnum, real *work, - integer *iwork, integer *info); -extern int slaed8_(integer *icompq, integer *k, integer *n, integer *qsiz, - real *d__, real *q, integer *ldq, integer *indxq, real *rho, - integer *cutpnt, real *z__, real *dlamda, real *q2, - integer *ldq2, real *w, integer *perm, integer *givptr, - integer *givcol, real *givnum, integer *indxp, integer *indx, - integer *info); -extern int slaed9_(integer *k, integer *kstart, integer *kstop, integer *n, - real *d__, real *q, integer *ldq, real *rho, real *dlamda, - real *w, real *s, integer *lds, integer *info); -extern int slaeda_(integer *n, integer *tlvls, integer *curlvl, integer *curpbm, - integer *prmptr, integer *perm, integer *givptr, - integer *givcol, real *givnum, real *q, integer *qptr, - real *z__, real *ztemp, integer *info); -extern int slaein_(logical *rightv, logical *noinit, integer *n, real *h__, - integer *ldh, real *wr, real *wi, real *vr, real *vi, - real *b, integer *ldb, real *work, real *eps3, real *smlnum, - real *bignum, integer *info); -extern int slaev2_(real *a, real *b, real *c__, real *rt1, real *rt2, real *cs1, - real *sn1); -extern int slaexc_(logical *wantq, integer *n, real *t, integer *ldt, real *q, - integer *ldq, integer *j1, integer *n1, integer *n2, - real *work, integer *info); -extern int slag2_(real *a, integer *lda, real *b, integer *ldb, real *safmin, - real *scale1, real *scale2, real *wr1, real *wr2, real *wi); -extern int slags2_(logical *upper, real *a1, real *a2, real *a3, real *b1, - real *b2, real *b3, real *csu, real *snu, real *csv, - real *snv, real *csq, real *snq); -extern int slagtf_(integer *n, real *a, real *lambda, real *b, real *c__, - real *tol, real *d__, integer *in, integer *info); -extern int slagtm_(char *trans, integer *n, integer *nrhs, real *alpha, - real *dl, real *d__, real *du, real *x, integer *ldx, - real *beta, real *b, integer *ldb, ftnlen trans_len); -extern int slagts_(integer *job, integer *n, real *a, real *b, real *c__, - real *d__, integer *in, real *y, real *tol, integer *info); -extern int slagv2_(real *a, integer *lda, real *b, integer *ldb, real *alphar, - real *alphai, real *beta, real *csl, real *snl, real *csr, - real *snr); -extern int slahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, - integer *ihi, real *h__, integer *ldh, real *wr, real *wi, - integer *iloz, integer *ihiz, real *z__, integer *ldz, - integer *info); -extern int slahrd_(integer *n, integer *k, integer *nb, real *a, integer *lda, - real *tau, real *t, integer *ldt, real *y, integer *ldy); -extern int slaic1_(integer *job, integer *j, real *x, real *sest, real *w, - real *gamma, real *sestpr, real *s, real *c__); -extern int slaln2_(logical *ltrans, integer *na, integer *nw, real *smin, - real *ca, real *a, integer *lda, real *d1, real *d2, real *b, - integer *ldb, real *wr, real *wi, real *x, integer *ldx, - real *scale, real *xnorm, integer *info); -extern int slals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *nrhs, real *b, integer *ldb, real *bx, - integer *ldbx, integer *perm, integer *givptr, - integer *givcol, integer *ldgcol, real *givnum, - integer *ldgnum, real *poles, real *difl, real *difr, - real *z__, integer *k, real *c__, real *s, real *work, - integer *info); -extern int slalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, - real *b, integer *ldb, real *bx, integer *ldbx, real *u, - integer *ldu, real *vt, integer *k, real *difl, real *difr, - real *z__, real *poles, integer *givptr, integer *givcol, - integer *ldgcol, integer *perm, real *givnum, real *c__, - real *s, real *work, integer *iwork, integer *info); -extern int slalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, - real *d__, real *e, real *b, integer *ldb, real *rcond, - integer *rank, real *work, integer *iwork, integer *info, - ftnlen uplo_len); -extern E_f slamch_(char *cmach, ftnlen cmach_len); -extern int slamc1_(integer *beta, integer *t, logical *rnd, logical *ieee1); -extern int slamc2_(integer *beta, integer *t, logical *rnd, real *eps, - integer *emin, real *rmin, integer *emax, real *rmax); -extern E_f slamc3_(real *a, real *b); -extern int slamc4_(integer *emin, real *start, integer *base); -extern int slamc5_(integer *beta, integer *p, integer *emin, logical *ieee, - integer *emax, real *rmax); -extern int slamrg_(integer *n1, integer *n2, real *a, integer *strd1, - integer *strd2, integer *index); -extern E_f slangb_(char *norm, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, real *work, ftnlen norm_len); -extern E_f slange_(char *norm, integer *m, integer *n, real *a, integer *lda, - real *work, ftnlen norm_len); -extern E_f slangt_(char *norm, integer *n, real *dl, real *d__, real *du, - ftnlen norm_len); -extern E_f slanhs_(char *norm, integer *n, real *a, integer *lda, real *work, - ftnlen norm_len); -extern E_f slansb_(char *norm, char *uplo, integer *n, integer *k, real *ab, - integer *ldab, real *work, ftnlen norm_len, ftnlen uplo_len); -extern E_f slansp_(char *norm, char *uplo, integer *n, real *ap, real *work, - ftnlen norm_len, ftnlen uplo_len); -extern E_f slanst_(char *norm, integer *n, real *d__, real *e, ftnlen norm_len); -extern E_f slansy_(char *norm, char *uplo, integer *n, real *a, integer *lda, - real *work, ftnlen norm_len, ftnlen uplo_len); -extern E_f slantb_(char *norm, char *uplo, char *diag, integer *n, integer *k, - real *ab, integer *ldab, real *work, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern E_f slantp_(char *norm, char *uplo, char *diag, integer *n, real *ap, - real *work, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern E_f slantr_(char *norm, char *uplo, char *diag, integer *m, integer *n, - real *a, integer *lda, real *work, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern int slanv2_(real *a, real *b, real *c__, real *d__, real *rt1r, - real *rt1i, real *rt2r, real *rt2i, real *cs, real *sn); -extern int slapll_(integer *n, real *x, integer *incx, real *y, integer *incy, - real *ssmin); -extern int slapmt_(logical *forwrd, integer *m, integer *n, real *x, - integer *ldx, integer *k); -extern E_f slapy2_(real *x, real *y); -extern E_f slapy3_(real *x, real *y, real *z__); -extern int slaqgb_(integer *m, integer *n, integer *kl, integer *ku, real *ab, - integer *ldab, real *r__, real *c__, real *rowcnd, - real *colcnd, real *amax, char *equed, ftnlen equed_len); -extern int slaqge_(integer *m, integer *n, real *a, integer *lda, real *r__, - real *c__, real *rowcnd, real *colcnd, real *amax, - char *equed, ftnlen equed_len); -extern int slaqp2_(integer *m, integer *n, integer *offset, real *a, - integer *lda, integer *jpvt, real *tau, real *vn1, real *vn2, - real *work); -extern int slaqps_(integer *m, integer *n, integer *offset, integer *nb, - integer *kb, real *a, integer *lda, integer *jpvt, real *tau, - real *vn1, real *vn2, real *auxv, real *f, integer *ldf); -extern int slaqsb_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - real *s, real *scond, real *amax, char *equed, - ftnlen uplo_len, ftnlen equed_len); -extern int slaqsp_(char *uplo, integer *n, real *ap, real *s, real *scond, - real *amax, char *equed, ftnlen uplo_len, ftnlen equed_len); -extern int slaqsy_(char *uplo, integer *n, real *a, integer *lda, real *s, - real *scond, real *amax, char *equed, ftnlen uplo_len, - ftnlen equed_len); -extern int slaqtr_(logical *ltran, logical *lreal, integer *n, real *t, - integer *ldt, real *b, real *w, real *scale, real *x, - real *work, integer *info); -extern int slar1v_(integer *n, integer *b1, integer *bn, real *sigma, real *d__, - real *l, real *ld, real *lld, real *gersch, real *z__, - real *ztz, real *mingma, integer *r__, integer *isuppz, - real *work); -extern int slar2v_(integer *n, real *x, real *y, real *z__, integer *incx, - real *c__, real *s, integer *incc); -extern int slarf_(char *side, integer *m, integer *n, real *v, integer *incv, - real *tau, real *c__, integer *ldc, real *work, - ftnlen side_len); -extern int slarfb_(char *side, char *trans, char *direct, char *storev, - integer *m, integer *n, integer *k, real *v, integer *ldv, - real *t, integer *ldt, real *c__, integer *ldc, real *work, - integer *ldwork, ftnlen side_len, ftnlen trans_len, - ftnlen direct_len, ftnlen storev_len); -extern int slarfg_(integer *n, real *alpha, real *x, integer *incx, real *tau); -extern int slarft_(char *direct, char *storev, integer *n, integer *k, real *v, - integer *ldv, real *tau, real *t, integer *ldt, - ftnlen direct_len, ftnlen storev_len); -extern int slarfx_(char *side, integer *m, integer *n, real *v, real *tau, - real *c__, integer *ldc, real *work, ftnlen side_len); -extern int slargv_(integer *n, real *x, integer *incx, real *y, integer *incy, - real *c__, integer *incc); -extern int slarnv_(integer *idist, integer *iseed, integer *n, real *x); -extern int slarrb_(integer *n, real *d__, real *l, real *ld, real *lld, - integer *ifirst, integer *ilast, real *sigma, real *reltol, - real *w, real *wgap, real *werr, real *work, integer *iwork, - integer *info); -extern int slarre_(integer *n, real *d__, real *e, real *tol, integer *nsplit, - integer *isplit, integer *m, real *w, real *woff, - real *gersch, real *work, integer *info); -extern int slarrf_(integer *n, real *d__, real *l, real *ld, real *lld, - integer *ifirst, integer *ilast, real *w, real *dplus, - real *lplus, real *work, integer *iwork, integer *info); -extern int slarrv_(integer *n, real *d__, real *l, integer *isplit, integer *m, - real *w, integer *iblock, real *gersch, real *tol, real *z__, - integer *ldz, integer *isuppz, real *work, integer *iwork, - integer *info); -extern int slartg_(real *f, real *g, real *cs, real *sn, real *r__); -extern int slartv_(integer *n, real *x, integer *incx, real *y, integer *incy, - real *c__, real *s, integer *incc); -extern int slaruv_(integer *iseed, integer *n, real *x); -extern int slarz_(char *side, integer *m, integer *n, integer *l, real *v, - integer *incv, real *tau, real *c__, integer *ldc, real *work, - ftnlen side_len); -extern int slarzb_(char *side, char *trans, char *direct, char *storev, - integer *m, integer *n, integer *k, integer *l, real *v, - integer *ldv, real *t, integer *ldt, real *c__, integer *ldc, - real *work, integer *ldwork, ftnlen side_len, - ftnlen trans_len, ftnlen direct_len, ftnlen storev_len); -extern int slarzt_(char *direct, char *storev, integer *n, integer *k, real *v, - integer *ldv, real *tau, real *t, integer *ldt, - ftnlen direct_len, ftnlen storev_len); -extern int slas2_(real *f, real *g, real *h__, real *ssmin, real *ssmax); -extern int slascl_(char *type__, integer *kl, integer *ku, real *cfrom, - real *cto, integer *m, integer *n, real *a, integer *lda, - integer *info, ftnlen type_len); -extern int slasd0_(integer *n, integer *sqre, real *d__, real *e, real *u, - integer *ldu, real *vt, integer *ldvt, integer *smlsiz, - integer *iwork, real *work, integer *info); -extern int slasd1_(integer *nl, integer *nr, integer *sqre, real *d__, - real *alpha, real *beta, real *u, integer *ldu, real *vt, - integer *ldvt, integer *idxq, integer *iwork, real *work, - integer *info); -extern int slasd2_(integer *nl, integer *nr, integer *sqre, integer *k, - real *d__, real *z__, real *alpha, real *beta, real *u, - integer *ldu, real *vt, integer *ldvt, real *dsigma, - real *u2, integer *ldu2, real *vt2, integer *ldvt2, - integer *idxp, integer *idx, integer *idxc, integer *idxq, - integer *coltyp, integer *info); -extern int slasd3_(integer *nl, integer *nr, integer *sqre, integer *k, - real *d__, real *q, integer *ldq, real *dsigma, real *u, - integer *ldu, real *u2, integer *ldu2, real *vt, - integer *ldvt, real *vt2, integer *ldvt2, integer *idxc, - integer *ctot, real *z__, integer *info); -extern int slasd4_(integer *n, integer *i__, real *d__, real *z__, real *delta, - real *rho, real *sigma, real *work, integer *info); -extern int slasd5_(integer *i__, real *d__, real *z__, real *delta, real *rho, - real *dsigma, real *work); -extern int slasd6_(integer *icompq, integer *nl, integer *nr, integer *sqre, - real *d__, real *vf, real *vl, real *alpha, real *beta, - integer *idxq, integer *perm, integer *givptr, - integer *givcol, integer *ldgcol, real *givnum, - integer *ldgnum, real *poles, real *difl, real *difr, - real *z__, integer *k, real *c__, real *s, real *work, - integer *iwork, integer *info); -extern int slasd7_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *k, real *d__, real *z__, real *zw, real *vf, - real *vfw, real *vl, real *vlw, real *alpha, real *beta, - real *dsigma, integer *idx, integer *idxp, integer *idxq, - integer *perm, integer *givptr, integer *givcol, - integer *ldgcol, real *givnum, integer *ldgnum, real *c__, - real *s, integer *info); -extern int slasd8_(integer *icompq, integer *k, real *d__, real *z__, real *vf, - real *vl, real *difl, real *difr, integer *lddifr, - real *dsigma, real *work, integer *info); -extern int slasd9_(integer *icompq, integer *ldu, integer *k, real *d__, - real *z__, real *vf, real *vl, real *difl, real *difr, - real *dsigma, real *work, integer *info); -extern int slasda_(integer *icompq, integer *smlsiz, integer *n, integer *sqre, - real *d__, real *e, real *u, integer *ldu, real *vt, - integer *k, real *difl, real *difr, real *z__, real *poles, - integer *givptr, integer *givcol, integer *ldgcol, - integer *perm, real *givnum, real *c__, real *s, real *work, - integer *iwork, integer *info); -extern int slasdq_(char *uplo, integer *sqre, integer *n, integer *ncvt, - integer *nru, integer *ncc, real *d__, real *e, real *vt, - integer *ldvt, real *u, integer *ldu, real *c__, - integer *ldc, real *work, integer *info, ftnlen uplo_len); -extern int slasdt_(integer *n, integer *lvl, integer *nd, integer *inode, - integer *ndiml, integer *ndimr, integer *msub); -extern int slaset_(char *uplo, integer *m, integer *n, real *alpha, real *beta, - real *a, integer *lda, ftnlen uplo_len); -extern int slasq1_(integer *n, real *d__, real *e, real *work, integer *info); -extern int slasq2_(integer *n, real *z__, integer *info); -extern int slasq3_(integer *i0, integer *n0, real *z__, integer *pp, - real *dmin__, real *sigma, real *desig, real *qmax, - integer *nfail, integer *iter, integer *ndiv); -extern int slasq4_(integer *i0, integer *n0, real *z__, integer *pp, - integer *n0in, real *dmin__, real *dmin1, real *dmin2, - real *dn, real *dn1, real *dn2, real *tau, integer *ttype); -extern int slasq5_(integer *i0, integer *n0, real *z__, integer *pp, real *tau, - real *dmin__, real *dmin1, real *dmin2, real *dn, real *dnm1, - real *dnm2); -extern int slasq6_(integer *i0, integer *n0, real *z__, integer *pp, - real *dmin__, real *dmin1, real *dmin2, real *dn, real *dnm1, - real *dnm2); -extern int slasr_(char *side, char *pivot, char *direct, integer *m, integer *n, - real *c__, real *s, real *a, integer *lda, ftnlen side_len, - ftnlen pivot_len, ftnlen direct_len); -extern int slasrt_(char *id, integer *n, real *d__, integer *info, - ftnlen id_len); -extern int slassq_(integer *n, real *x, integer *incx, real *scale, - real *sumsq); -extern int slasv2_(real *f, real *g, real *h__, real *ssmin, real *ssmax, - real *snr, real *csr, real *snl, real *csl); -extern int slaswp_(integer *n, real *a, integer *lda, integer *k1, integer *k2, - integer *ipiv, integer *incx); -extern int slasy2_(logical *ltranl, logical *ltranr, integer *isgn, integer *n1, - integer *n2, real *tl, integer *ldtl, real *tr, - integer *ldtr, real *b, integer *ldb, real *scale, real *x, - integer *ldx, real *xnorm, integer *info); -extern int slasyf_(char *uplo, integer *n, integer *nb, integer *kb, real *a, - integer *lda, integer *ipiv, real *w, integer *ldw, - integer *info, ftnlen uplo_len); -extern int slatbs_(char *uplo, char *trans, char *diag, char *normin, - integer *n, integer *kd, real *ab, integer *ldab, real *x, - real *scale, real *cnorm, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len, ftnlen normin_len); -extern int slatdf_(integer *ijob, integer *n, real *z__, integer *ldz, - real *rhs, real *rdsum, real *rdscal, integer *ipiv, - integer *jpiv); -extern int slatps_(char *uplo, char *trans, char *diag, char *normin, - integer *n, real *ap, real *x, real *scale, real *cnorm, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len, ftnlen normin_len); -extern int slatrd_(char *uplo, integer *n, integer *nb, real *a, integer *lda, - real *e, real *tau, real *w, integer *ldw, ftnlen uplo_len); -extern int slatrs_(char *uplo, char *trans, char *diag, char *normin, - integer *n, real *a, integer *lda, real *x, real *scale, - real *cnorm, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len, ftnlen normin_len); -extern int slatrz_(integer *m, integer *n, integer *l, real *a, integer *lda, - real *tau, real *work); -extern int slatzm_(char *side, integer *m, integer *n, real *v, integer *incv, - real *tau, real *c1, real *c2, integer *ldc, real *work, - ftnlen side_len); -extern int slauu2_(char *uplo, integer *n, real *a, integer *lda, integer *info, - ftnlen uplo_len); -extern int slauum_(char *uplo, integer *n, real *a, integer *lda, integer *info, - ftnlen uplo_len); -extern int sopgtr_(char *uplo, integer *n, real *ap, real *tau, real *q, - integer *ldq, real *work, integer *info, ftnlen uplo_len); -extern int sopmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - real *ap, real *tau, real *c__, integer *ldc, real *work, - integer *info, ftnlen side_len, ftnlen uplo_len, - ftnlen trans_len); -extern int sorg2l_(integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *info); -extern int sorg2r_(integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *info); -extern int sorgbr_(char *vect, integer *m, integer *n, integer *k, real *a, - integer *lda, real *tau, real *work, integer *lwork, - integer *info, ftnlen vect_len); -extern int sorghr_(integer *n, integer *ilo, integer *ihi, real *a, - integer *lda, real *tau, real *work, integer *lwork, - integer *info); -extern int sorgl2_(integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *info); -extern int sorglq_(integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *lwork, integer *info); -extern int sorgql_(integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *lwork, integer *info); -extern int sorgqr_(integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *lwork, integer *info); -extern int sorgr2_(integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *info); -extern int sorgrq_(integer *m, integer *n, integer *k, real *a, integer *lda, - real *tau, real *work, integer *lwork, integer *info); -extern int sorgtr_(char *uplo, integer *n, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info, ftnlen uplo_len); -extern int sorm2l_(char *side, char *trans, integer *m, integer *n, integer *k, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sorm2r_(char *side, char *trans, integer *m, integer *n, integer *k, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sormbr_(char *vect, char *side, char *trans, integer *m, integer *n, - integer *k, real *a, integer *lda, real *tau, real *c__, - integer *ldc, real *work, integer *lwork, integer *info, - ftnlen vect_len, ftnlen side_len, ftnlen trans_len); -extern int sormhr_(char *side, char *trans, integer *m, integer *n, - integer *ilo, integer *ihi, real *a, integer *lda, real *tau, - real *c__, integer *ldc, real *work, integer *lwork, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int sorml2_(char *side, char *trans, integer *m, integer *n, integer *k, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sormlq_(char *side, char *trans, integer *m, integer *n, integer *k, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sormql_(char *side, char *trans, integer *m, integer *n, integer *k, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sormqr_(char *side, char *trans, integer *m, integer *n, integer *k, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sormr2_(char *side, char *trans, integer *m, integer *n, integer *k, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sormr3_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, real *a, integer *lda, real *tau, real *c__, - integer *ldc, real *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sormrq_(char *side, char *trans, integer *m, integer *n, integer *k, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int sormrz_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, real *a, integer *lda, real *tau, real *c__, - integer *ldc, real *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int sormtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - real *a, integer *lda, real *tau, real *c__, integer *ldc, - real *work, integer *lwork, integer *info, ftnlen side_len, - ftnlen uplo_len, ftnlen trans_len); -extern int spbcon_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - real *anorm, real *rcond, real *work, integer *iwork, - integer *info, ftnlen uplo_len); -extern int spbequ_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - real *s, real *scond, real *amax, integer *info, - ftnlen uplo_len); -extern int spbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, - integer *ldab, real *afb, integer *ldafb, real *b, - integer *ldb, real *x, integer *ldx, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen uplo_len); -extern int spbstf_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - integer *info, ftnlen uplo_len); -extern int spbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, - integer *ldab, real *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int spbsvx_(char *fact, char *uplo, integer *n, integer *kd, - integer *nrhs, real *ab, integer *ldab, real *afb, - integer *ldafb, char *equed, real *s, real *b, integer *ldb, - real *x, integer *ldx, real *rcond, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen fact_len, - ftnlen uplo_len, ftnlen equed_len); -extern int spbtf2_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - integer *info, ftnlen uplo_len); -extern int spbtrf_(char *uplo, integer *n, integer *kd, real *ab, integer *ldab, - integer *info, ftnlen uplo_len); -extern int spbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, real *ab, - integer *ldab, real *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int spocon_(char *uplo, integer *n, real *a, integer *lda, real *anorm, - real *rcond, real *work, integer *iwork, integer *info, - ftnlen uplo_len); -extern int spoequ_(integer *n, real *a, integer *lda, real *s, real *scond, - real *amax, integer *info); -extern int sporfs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, - real *af, integer *ldaf, real *b, integer *ldb, real *x, - integer *ldx, real *ferr, real *berr, real *work, - integer *iwork, integer *info, ftnlen uplo_len); -extern int sposv_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, - real *b, integer *ldb, integer *info, ftnlen uplo_len); -extern int sposvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, char *equed, real *s, - real *b, integer *ldb, real *x, integer *ldx, real *rcond, - real *ferr, real *berr, real *work, integer *iwork, - integer *info, ftnlen fact_len, ftnlen uplo_len, - ftnlen equed_len); -extern int spotf2_(char *uplo, integer *n, real *a, integer *lda, integer *info, - ftnlen uplo_len); -extern int spotrf_(char *uplo, integer *n, real *a, integer *lda, integer *info, - ftnlen uplo_len); -extern int spotri_(char *uplo, integer *n, real *a, integer *lda, integer *info, - ftnlen uplo_len); -extern int spotrs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, - real *b, integer *ldb, integer *info, ftnlen uplo_len); -extern int sppcon_(char *uplo, integer *n, real *ap, real *anorm, real *rcond, - real *work, integer *iwork, integer *info, ftnlen uplo_len); -extern int sppequ_(char *uplo, integer *n, real *ap, real *s, real *scond, - real *amax, integer *info, ftnlen uplo_len); -extern int spprfs_(char *uplo, integer *n, integer *nrhs, real *ap, real *afp, - real *b, integer *ldb, real *x, integer *ldx, real *ferr, - real *berr, real *work, integer *iwork, integer *info, - ftnlen uplo_len); -extern int sppsv_(char *uplo, integer *n, integer *nrhs, real *ap, real *b, - integer *ldb, integer *info, ftnlen uplo_len); -extern int sppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *ap, - real *afp, char *equed, real *s, real *b, integer *ldb, - real *x, integer *ldx, real *rcond, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen fact_len, - ftnlen uplo_len, ftnlen equed_len); -extern int spptrf_(char *uplo, integer *n, real *ap, integer *info, - ftnlen uplo_len); -extern int spptri_(char *uplo, integer *n, real *ap, integer *info, - ftnlen uplo_len); -extern int spptrs_(char *uplo, integer *n, integer *nrhs, real *ap, real *b, - integer *ldb, integer *info, ftnlen uplo_len); -extern int sptcon_(integer *n, real *d__, real *e, real *anorm, real *rcond, - real *work, integer *info); -extern int spteqr_(char *compz, integer *n, real *d__, real *e, real *z__, - integer *ldz, real *work, integer *info, ftnlen compz_len); -extern int sptrfs_(integer *n, integer *nrhs, real *d__, real *e, real *df, - real *ef, real *b, integer *ldb, real *x, integer *ldx, - real *ferr, real *berr, real *work, integer *info); -extern int sptsv_(integer *n, integer *nrhs, real *d__, real *e, real *b, - integer *ldb, integer *info); -extern int sptsvx_(char *fact, integer *n, integer *nrhs, real *d__, real *e, - real *df, real *ef, real *b, integer *ldb, real *x, - integer *ldx, real *rcond, real *ferr, real *berr, - real *work, integer *info, ftnlen fact_len); -extern int spttrf_(integer *n, real *d__, real *e, integer *info); -extern int spttrs_(integer *n, integer *nrhs, real *d__, real *e, real *b, - integer *ldb, integer *info); -extern int sptts2_(integer *n, integer *nrhs, real *d__, real *e, real *b, - integer *ldb); -extern int srscl_(integer *n, real *sa, real *sx, integer *incx); -extern int ssbev_(char *jobz, char *uplo, integer *n, integer *kd, real *ab, - integer *ldab, real *w, real *z__, integer *ldz, real *work, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int ssbevd_(char *jobz, char *uplo, integer *n, integer *kd, real *ab, - integer *ldab, real *w, real *z__, integer *ldz, real *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int ssbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, - real *ab, integer *ldab, real *q, integer *ldq, real *vl, - real *vu, integer *il, integer *iu, real *abstol, integer *m, - real *w, real *z__, integer *ldz, real *work, integer *iwork, - integer *ifail, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int ssbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, - real *ab, integer *ldab, real *bb, integer *ldbb, real *x, - integer *ldx, real *work, integer *info, ftnlen vect_len, - ftnlen uplo_len); -extern int ssbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - real *ab, integer *ldab, real *bb, integer *ldbb, real *w, - real *z__, integer *ldz, real *work, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int ssbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - real *ab, integer *ldab, real *bb, integer *ldbb, real *w, - real *z__, integer *ldz, real *work, integer *lwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int ssbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, - integer *kb, real *ab, integer *ldab, real *bb, - integer *ldbb, real *q, integer *ldq, real *vl, real *vu, - integer *il, integer *iu, real *abstol, integer *m, real *w, - real *z__, integer *ldz, real *work, integer *iwork, - integer *ifail, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int ssbtrd_(char *vect, char *uplo, integer *n, integer *kd, real *ab, - integer *ldab, real *d__, real *e, real *q, integer *ldq, - real *work, integer *info, ftnlen vect_len, ftnlen uplo_len); -extern int sspcon_(char *uplo, integer *n, real *ap, integer *ipiv, real *anorm, - real *rcond, real *work, integer *iwork, integer *info, - ftnlen uplo_len); -extern int sspev_(char *jobz, char *uplo, integer *n, real *ap, real *w, - real *z__, integer *ldz, real *work, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int sspevd_(char *jobz, char *uplo, integer *n, real *ap, real *w, - real *z__, integer *ldz, real *work, integer *lwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int sspevx_(char *jobz, char *range, char *uplo, integer *n, real *ap, - real *vl, real *vu, integer *il, integer *iu, real *abstol, - integer *m, real *w, real *z__, integer *ldz, real *work, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int sspgst_(integer *itype, char *uplo, integer *n, real *ap, real *bp, - integer *info, ftnlen uplo_len); -extern int sspgv_(integer *itype, char *jobz, char *uplo, integer *n, real *ap, - real *bp, real *w, real *z__, integer *ldz, real *work, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int sspgvd_(integer *itype, char *jobz, char *uplo, integer *n, real *ap, - real *bp, real *w, real *z__, integer *ldz, real *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int sspgvx_(integer *itype, char *jobz, char *range, char *uplo, - integer *n, real *ap, real *bp, real *vl, real *vu, - integer *il, integer *iu, real *abstol, integer *m, real *w, - real *z__, integer *ldz, real *work, integer *iwork, - integer *ifail, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int ssprfs_(char *uplo, integer *n, integer *nrhs, real *ap, real *afp, - integer *ipiv, real *b, integer *ldb, real *x, integer *ldx, - real *ferr, real *berr, real *work, integer *iwork, - integer *info, ftnlen uplo_len); -extern int sspsv_(char *uplo, integer *n, integer *nrhs, real *ap, - integer *ipiv, real *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int sspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *ap, - real *afp, integer *ipiv, real *b, integer *ldb, real *x, - integer *ldx, real *rcond, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen fact_len, - ftnlen uplo_len); -extern int ssptrd_(char *uplo, integer *n, real *ap, real *d__, real *e, - real *tau, integer *info, ftnlen uplo_len); -extern int ssptrf_(char *uplo, integer *n, real *ap, integer *ipiv, - integer *info, ftnlen uplo_len); -extern int ssptri_(char *uplo, integer *n, real *ap, integer *ipiv, real *work, - integer *info, ftnlen uplo_len); -extern int ssptrs_(char *uplo, integer *n, integer *nrhs, real *ap, - integer *ipiv, real *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int sstebz_(char *range, char *order, integer *n, real *vl, real *vu, - integer *il, integer *iu, real *abstol, real *d__, real *e, - integer *m, integer *nsplit, real *w, integer *iblock, - integer *isplit, real *work, integer *iwork, integer *info, - ftnlen range_len, ftnlen order_len); -extern int sstedc_(char *compz, integer *n, real *d__, real *e, real *z__, - integer *ldz, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen compz_len); -extern int sstegr_(char *jobz, char *range, integer *n, real *d__, real *e, - real *vl, real *vu, integer *il, integer *iu, real *abstol, - integer *m, real *w, real *z__, integer *ldz, - integer *isuppz, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len); -extern int sstein_(integer *n, real *d__, real *e, integer *m, real *w, - integer *iblock, integer *isplit, real *z__, integer *ldz, - real *work, integer *iwork, integer *ifail, integer *info); -extern int ssteqr_(char *compz, integer *n, real *d__, real *e, real *z__, - integer *ldz, real *work, integer *info, ftnlen compz_len); -extern int ssterf_(integer *n, real *d__, real *e, integer *info); -extern int sstev_(char *jobz, integer *n, real *d__, real *e, real *z__, - integer *ldz, real *work, integer *info, ftnlen jobz_len); -extern int sstevd_(char *jobz, integer *n, real *d__, real *e, real *z__, - integer *ldz, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len); -extern int sstevr_(char *jobz, char *range, integer *n, real *d__, real *e, - real *vl, real *vu, integer *il, integer *iu, real *abstol, - integer *m, real *w, real *z__, integer *ldz, - integer *isuppz, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len); -extern int sstevx_(char *jobz, char *range, integer *n, real *d__, real *e, - real *vl, real *vu, integer *il, integer *iu, real *abstol, - integer *m, real *w, real *z__, integer *ldz, real *work, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len); -extern int ssycon_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, - real *anorm, real *rcond, real *work, integer *iwork, - integer *info, ftnlen uplo_len); -extern int ssyev_(char *jobz, char *uplo, integer *n, real *a, integer *lda, - real *w, real *work, integer *lwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int ssyevd_(char *jobz, char *uplo, integer *n, real *a, integer *lda, - real *w, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int ssyevr_(char *jobz, char *range, char *uplo, integer *n, real *a, - integer *lda, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, real *z__, integer *ldz, - integer *isuppz, real *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int ssyevx_(char *jobz, char *range, char *uplo, integer *n, real *a, - integer *lda, real *vl, real *vu, integer *il, integer *iu, - real *abstol, integer *m, real *w, real *z__, integer *ldz, - real *work, integer *lwork, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int ssygs2_(integer *itype, char *uplo, integer *n, real *a, - integer *lda, real *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int ssygst_(integer *itype, char *uplo, integer *n, real *a, - integer *lda, real *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int ssygv_(integer *itype, char *jobz, char *uplo, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *w, real *work, - integer *lwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int ssygvd_(integer *itype, char *jobz, char *uplo, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *w, real *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int ssygvx_(integer *itype, char *jobz, char *range, char *uplo, - integer *n, real *a, integer *lda, real *b, integer *ldb, - real *vl, real *vu, integer *il, integer *iu, real *abstol, - integer *m, real *w, real *z__, integer *ldz, real *work, - integer *lwork, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int ssyrfs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, - real *af, integer *ldaf, integer *ipiv, real *b, - integer *ldb, real *x, integer *ldx, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen uplo_len); -extern int ssysv_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, - integer *ipiv, real *b, integer *ldb, real *work, - integer *lwork, integer *info, ftnlen uplo_len); -extern int ssysvx_(char *fact, char *uplo, integer *n, integer *nrhs, real *a, - integer *lda, real *af, integer *ldaf, integer *ipiv, - real *b, integer *ldb, real *x, integer *ldx, real *rcond, - real *ferr, real *berr, real *work, integer *lwork, - integer *iwork, integer *info, ftnlen fact_len, - ftnlen uplo_len); -extern int ssytd2_(char *uplo, integer *n, real *a, integer *lda, real *d__, - real *e, real *tau, integer *info, ftnlen uplo_len); -extern int ssytf2_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, - integer *info, ftnlen uplo_len); -extern int ssytrd_(char *uplo, integer *n, real *a, integer *lda, real *d__, - real *e, real *tau, real *work, integer *lwork, - integer *info, ftnlen uplo_len); -extern int ssytrf_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, - real *work, integer *lwork, integer *info, ftnlen uplo_len); -extern int ssytri_(char *uplo, integer *n, real *a, integer *lda, integer *ipiv, - real *work, integer *info, ftnlen uplo_len); -extern int ssytrs_(char *uplo, integer *n, integer *nrhs, real *a, integer *lda, - integer *ipiv, real *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int stbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, - real *ab, integer *ldab, real *rcond, real *work, - integer *iwork, integer *info, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern int stbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, real *ab, integer *ldab, real *b, - integer *ldb, real *x, integer *ldx, real *ferr, real *berr, - real *work, integer *iwork, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int stbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, real *ab, integer *ldab, real *b, - integer *ldb, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int stgevc_(char *side, char *howmny, logical *select, integer *n, - real *a, integer *lda, real *b, integer *ldb, real *vl, - integer *ldvl, real *vr, integer *ldvr, integer *mm, - integer *m, real *work, integer *info, ftnlen side_len, - ftnlen howmny_len); -extern int stgex2_(logical *wantq, logical *wantz, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *q, integer *ldq, - real *z__, integer *ldz, integer *j1, integer *n1, - integer *n2, real *work, integer *lwork, integer *info); -extern int stgexc_(logical *wantq, logical *wantz, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *q, integer *ldq, - real *z__, integer *ldz, integer *ifst, integer *ilst, - real *work, integer *lwork, integer *info); -extern int stgsen_(integer *ijob, logical *wantq, logical *wantz, - logical *select, integer *n, real *a, integer *lda, real *b, - integer *ldb, real *alphar, real *alphai, real *beta, - real *q, integer *ldq, real *z__, integer *ldz, integer *m, - real *pl, real *pr, real *dif, real *work, integer *lwork, - integer *iwork, integer *liwork, integer *info); -extern int stgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, - integer *n, integer *k, integer *l, real *a, integer *lda, - real *b, integer *ldb, real *tola, real *tolb, real *alpha, - real *beta, real *u, integer *ldu, real *v, integer *ldv, - real *q, integer *ldq, real *work, integer *ncycle, - integer *info, ftnlen jobu_len, ftnlen jobv_len, - ftnlen jobq_len); -extern int stgsna_(char *job, char *howmny, logical *select, integer *n, - real *a, integer *lda, real *b, integer *ldb, real *vl, - integer *ldvl, real *vr, integer *ldvr, real *s, real *dif, - integer *mm, integer *m, real *work, integer *lwork, - integer *iwork, integer *info, ftnlen job_len, - ftnlen howmny_len); -extern int stgsy2_(char *trans, integer *ijob, integer *m, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *c__, integer *ldc, - real *d__, integer *ldd, real *e, integer *lde, real *f, - integer *ldf, real *scale, real *rdsum, real *rdscal, - integer *iwork, integer *pq, integer *info, - ftnlen trans_len); -extern int stgsyl_(char *trans, integer *ijob, integer *m, integer *n, real *a, - integer *lda, real *b, integer *ldb, real *c__, integer *ldc, - real *d__, integer *ldd, real *e, integer *lde, real *f, - integer *ldf, real *scale, real *dif, real *work, - integer *lwork, integer *iwork, integer *info, - ftnlen trans_len); -extern int stpcon_(char *norm, char *uplo, char *diag, integer *n, real *ap, - real *rcond, real *work, integer *iwork, integer *info, - ftnlen norm_len, ftnlen uplo_len, ftnlen diag_len); -extern int stprfs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, real *ap, real *b, integer *ldb, real *x, - integer *ldx, real *ferr, real *berr, real *work, - integer *iwork, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int stptri_(char *uplo, char *diag, integer *n, real *ap, integer *info, - ftnlen uplo_len, ftnlen diag_len); -extern int stptrs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, real *ap, real *b, integer *ldb, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int strcon_(char *norm, char *uplo, char *diag, integer *n, real *a, - integer *lda, real *rcond, real *work, integer *iwork, - integer *info, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern int strevc_(char *side, char *howmny, logical *select, integer *n, - real *t, integer *ldt, real *vl, integer *ldvl, real *vr, - integer *ldvr, integer *mm, integer *m, real *work, - integer *info, ftnlen side_len, ftnlen howmny_len); -extern int strexc_(char *compq, integer *n, real *t, integer *ldt, real *q, - integer *ldq, integer *ifst, integer *ilst, real *work, - integer *info, ftnlen compq_len); -extern int strrfs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, real *a, integer *lda, real *b, integer *ldb, - real *x, integer *ldx, real *ferr, real *berr, real *work, - integer *iwork, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int strsen_(char *job, char *compq, logical *select, integer *n, real *t, - integer *ldt, real *q, integer *ldq, real *wr, real *wi, - integer *m, real *s, real *sep, real *work, integer *lwork, - integer *iwork, integer *liwork, integer *info, - ftnlen job_len, ftnlen compq_len); -extern int strsna_(char *job, char *howmny, logical *select, integer *n, - real *t, integer *ldt, real *vl, integer *ldvl, real *vr, - integer *ldvr, real *s, real *sep, integer *mm, integer *m, - real *work, integer *ldwork, integer *iwork, integer *info, - ftnlen job_len, ftnlen howmny_len); -extern int strsyl_(char *trana, char *tranb, integer *isgn, integer *m, - integer *n, real *a, integer *lda, real *b, integer *ldb, - real *c__, integer *ldc, real *scale, integer *info, - ftnlen trana_len, ftnlen tranb_len); -extern int strti2_(char *uplo, char *diag, integer *n, real *a, integer *lda, - integer *info, ftnlen uplo_len, ftnlen diag_len); -extern int strtri_(char *uplo, char *diag, integer *n, real *a, integer *lda, - integer *info, ftnlen uplo_len, ftnlen diag_len); -extern int strtrs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, real *a, integer *lda, real *b, integer *ldb, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len); -extern int stzrqf_(integer *m, integer *n, real *a, integer *lda, real *tau, - integer *info); -extern int stzrzf_(integer *m, integer *n, real *a, integer *lda, real *tau, - real *work, integer *lwork, integer *info); -extern int xerbla_(char *srname, integer *info, ftnlen srname_len); -extern int zbdsqr_(char *uplo, integer *n, integer *ncvt, integer *nru, - integer *ncc, doublereal *d__, doublereal *e, - doublecomplex *vt, integer *ldvt, doublecomplex *u, - integer *ldu, doublecomplex *c__, integer *ldc, - doublereal *rwork, integer *info, ftnlen uplo_len); -extern int zdrot_(integer *n, doublecomplex *cx, integer *incx, - doublecomplex *cy, integer *incy, doublereal *c__, - doublereal *s); -extern int zdrscl_(integer *n, doublereal *sa, doublecomplex *sx, - integer *incx); -extern int zgbbrd_(char *vect, integer *m, integer *n, integer *ncc, - integer *kl, integer *ku, doublecomplex *ab, integer *ldab, - doublereal *d__, doublereal *e, doublecomplex *q, - integer *ldq, doublecomplex *pt, integer *ldpt, - doublecomplex *c__, integer *ldc, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen vect_len); -extern int zgbcon_(char *norm, integer *n, integer *kl, integer *ku, - doublecomplex *ab, integer *ldab, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen norm_len); -extern int zgbequ_(integer *m, integer *n, integer *kl, integer *ku, - doublecomplex *ab, integer *ldab, doublereal *r__, - doublereal *c__, doublereal *rowcnd, doublereal *colcnd, - doublereal *amax, integer *info); -extern int zgbrfs_(char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, doublecomplex *ab, integer *ldab, - doublecomplex *afb, integer *ldafb, integer *ipiv, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen trans_len); -extern int zgbsv_(integer *n, integer *kl, integer *ku, integer *nrhs, - doublecomplex *ab, integer *ldab, integer *ipiv, - doublecomplex *b, integer *ldb, integer *info); -extern int zgbsvx_(char *fact, char *trans, integer *n, integer *kl, - integer *ku, integer *nrhs, doublecomplex *ab, integer *ldab, - doublecomplex *afb, integer *ldafb, integer *ipiv, - char *equed, doublereal *r__, doublereal *c__, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen fact_len, ftnlen trans_len, - ftnlen equed_len); -extern int zgbtf2_(integer *m, integer *n, integer *kl, integer *ku, - doublecomplex *ab, integer *ldab, integer *ipiv, - integer *info); -extern int zgbtrf_(integer *m, integer *n, integer *kl, integer *ku, - doublecomplex *ab, integer *ldab, integer *ipiv, - integer *info); -extern int zgbtrs_(char *trans, integer *n, integer *kl, integer *ku, - integer *nrhs, doublecomplex *ab, integer *ldab, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info, - ftnlen trans_len); -extern int zgebak_(char *job, char *side, integer *n, integer *ilo, - integer *ihi, doublereal *scale, integer *m, - doublecomplex *v, integer *ldv, integer *info, - ftnlen job_len, ftnlen side_len); -extern int zgebal_(char *job, integer *n, doublecomplex *a, integer *lda, - integer *ilo, integer *ihi, doublereal *scale, integer *info, - ftnlen job_len); -extern int zgebd2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tauq, - doublecomplex *taup, doublecomplex *work, integer *info); -extern int zgebrd_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tauq, - doublecomplex *taup, doublecomplex *work, integer *lwork, - integer *info); -extern int zgecon_(char *norm, integer *n, doublecomplex *a, integer *lda, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen norm_len); -extern int zgeequ_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, integer *info); -extern int zgees_(char *jobvs, char *sort, L_fp select, integer *n, - doublecomplex *a, integer *lda, integer *sdim, - doublecomplex *w, doublecomplex *vs, integer *ldvs, - doublecomplex *work, integer *lwork, doublereal *rwork, - logical *bwork, integer *info, ftnlen jobvs_len, - ftnlen sort_len); -extern int zgeesx_(char *jobvs, char *sort, L_fp select, char *sense, - integer *n, doublecomplex *a, integer *lda, integer *sdim, - doublecomplex *w, doublecomplex *vs, integer *ldvs, - doublereal *rconde, doublereal *rcondv, doublecomplex *work, - integer *lwork, doublereal *rwork, logical *bwork, - integer *info, ftnlen jobvs_len, ftnlen sort_len, - ftnlen sense_len); -extern int zgeev_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, - integer *lda, doublecomplex *w, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info, ftnlen jobvl_len, ftnlen jobvr_len); -extern int zgeevx_(char *balanc, char *jobvl, char *jobvr, char *sense, - integer *n, doublecomplex *a, integer *lda, doublecomplex *w, - doublecomplex *vl, integer *ldvl, doublecomplex *vr, - integer *ldvr, integer *ilo, integer *ihi, doublereal *scale, - doublereal *abnrm, doublereal *rconde, doublereal *rcondv, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info, ftnlen balanc_len, ftnlen jobvl_len, - ftnlen jobvr_len, ftnlen sense_len); -extern int zgegs_(char *jobvsl, char *jobvsr, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *alpha, doublecomplex *beta, doublecomplex *vsl, - integer *ldvsl, doublecomplex *vsr, integer *ldvsr, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info, ftnlen jobvsl_len, ftnlen jobvsr_len); -extern int zgegv_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *alpha, doublecomplex *beta, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info, ftnlen jobvl_len, ftnlen jobvr_len); -extern int zgehd2_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *info); -extern int zgehrd_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *lwork, integer *info); -extern int zgelq2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); -extern int zgelqf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); -extern int zgels_(char *trans, integer *m, integer *n, integer *nrhs, - doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *work, integer *lwork, - integer *info, ftnlen trans_len); -extern int zgelsd_(integer *m, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublereal *s, - doublereal *rcond, integer *rank, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *iwork, - integer *info); -extern int zgelss_(integer *m, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, doublereal *s, - doublereal *rcond, integer *rank, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *info); -extern int zgelsx_(integer *m, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, integer *jpvt, - doublereal *rcond, integer *rank, doublecomplex *work, - doublereal *rwork, integer *info); -extern int zgelsy_(integer *m, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, integer *jpvt, - doublereal *rcond, integer *rank, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *info); -extern int zgeql2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); -extern int zgeqlf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); -extern int zgeqp3_(integer *m, integer *n, doublecomplex *a, integer *lda, - integer *jpvt, doublecomplex *tau, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *info); -extern int zgeqpf_(integer *m, integer *n, doublecomplex *a, integer *lda, - integer *jpvt, doublecomplex *tau, doublecomplex *work, - doublereal *rwork, integer *info); -extern int zgeqr2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); -extern int zgeqrf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); -extern int zgerfs_(char *trans, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, - integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen trans_len); -extern int zgerq2_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *info); -extern int zgerqf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); -extern int zgesc2_(integer *n, doublecomplex *a, integer *lda, - doublecomplex *rhs, integer *ipiv, integer *jpiv, - doublereal *scale); -extern int zgesdd_(char *jobz, integer *m, integer *n, doublecomplex *a, - integer *lda, doublereal *s, doublecomplex *u, integer *ldu, - doublecomplex *vt, integer *ldvt, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *iwork, - integer *info, ftnlen jobz_len); -extern int zgesv_(integer *n, integer *nrhs, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info); -extern int zgesvd_(char *jobu, char *jobvt, integer *m, integer *n, - doublecomplex *a, integer *lda, doublereal *s, - doublecomplex *u, integer *ldu, doublecomplex *vt, - integer *ldvt, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *info, ftnlen jobu_len, - ftnlen jobvt_len); -extern int zgesvx_(char *fact, char *trans, integer *n, integer *nrhs, - doublecomplex *a, integer *lda, doublecomplex *af, - integer *ldaf, integer *ipiv, char *equed, doublereal *r__, - doublereal *c__, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen fact_len, - ftnlen trans_len, ftnlen equed_len); -extern int zgetc2_(integer *n, doublecomplex *a, integer *lda, integer *ipiv, - integer *jpiv, integer *info); -extern int zgetf2_(integer *m, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, integer *info); -extern int zgetrf_(integer *m, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, integer *info); -extern int zgetri_(integer *n, doublecomplex *a, integer *lda, integer *ipiv, - doublecomplex *work, integer *lwork, integer *info); -extern int zgetrs_(char *trans, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, - integer *info, ftnlen trans_len); -extern int zggbak_(char *job, char *side, integer *n, integer *ilo, - integer *ihi, doublereal *lscale, doublereal *rscale, - integer *m, doublecomplex *v, integer *ldv, integer *info, - ftnlen job_len, ftnlen side_len); -extern int zggbal_(char *job, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *ilo, integer *ihi, - doublereal *lscale, doublereal *rscale, doublereal *work, - integer *info, ftnlen job_len); -extern int zgges_(char *jobvsl, char *jobvsr, char *sort, L_fp delctg, - integer *n, doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, integer *sdim, doublecomplex *alpha, - doublecomplex *beta, doublecomplex *vsl, integer *ldvsl, - doublecomplex *vsr, integer *ldvsr, doublecomplex *work, - integer *lwork, doublereal *rwork, logical *bwork, - integer *info, ftnlen jobvsl_len, ftnlen jobvsr_len, - ftnlen sort_len); -extern int zggesx_(char *jobvsl, char *jobvsr, char *sort, L_fp delctg, - char *sense, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *sdim, - doublecomplex *alpha, doublecomplex *beta, - doublecomplex *vsl, integer *ldvsl, doublecomplex *vsr, - integer *ldvsr, doublereal *rconde, doublereal *rcondv, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *iwork, integer *liwork, logical *bwork, - integer *info, ftnlen jobvsl_len, ftnlen jobvsr_len, - ftnlen sort_len, ftnlen sense_len); -extern int zggev_(char *jobvl, char *jobvr, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *alpha, doublecomplex *beta, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *info, ftnlen jobvl_len, ftnlen jobvr_len); -extern int zggevx_(char *balanc, char *jobvl, char *jobvr, char *sense, - integer *n, doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *alpha, doublecomplex *beta, - doublecomplex *vl, integer *ldvl, doublecomplex *vr, - integer *ldvr, integer *ilo, integer *ihi, - doublereal *lscale, doublereal *rscale, doublereal *abnrm, - doublereal *bbnrm, doublereal *rconde, doublereal *rcondv, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *iwork, logical *bwork, integer *info, - ftnlen balanc_len, ftnlen jobvl_len, ftnlen jobvr_len, - ftnlen sense_len); -extern int zggglm_(integer *n, integer *m, integer *p, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *d__, doublecomplex *x, doublecomplex *y, - doublecomplex *work, integer *lwork, integer *info); -extern int zgghrd_(char *compq, char *compz, integer *n, integer *ilo, - integer *ihi, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *q, - integer *ldq, doublecomplex *z__, integer *ldz, - integer *info, ftnlen compq_len, ftnlen compz_len); -extern int zgglse_(integer *m, integer *n, integer *p, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *c__, doublecomplex *d__, doublecomplex *x, - doublecomplex *work, integer *lwork, integer *info); -extern int zggqrf_(integer *n, integer *m, integer *p, doublecomplex *a, - integer *lda, doublecomplex *taua, doublecomplex *b, - integer *ldb, doublecomplex *taub, doublecomplex *work, - integer *lwork, integer *info); -extern int zggrqf_(integer *m, integer *p, integer *n, doublecomplex *a, - integer *lda, doublecomplex *taua, doublecomplex *b, - integer *ldb, doublecomplex *taub, doublecomplex *work, - integer *lwork, integer *info); -extern int zggsvd_(char *jobu, char *jobv, char *jobq, integer *m, integer *n, - integer *p, integer *k, integer *l, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublereal *alpha, doublereal *beta, doublecomplex *u, - integer *ldu, doublecomplex *v, integer *ldv, - doublecomplex *q, integer *ldq, doublecomplex *work, - doublereal *rwork, integer *iwork, integer *info, - ftnlen jobu_len, ftnlen jobv_len, ftnlen jobq_len); -extern int zggsvp_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, - integer *n, doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublereal *tola, doublereal *tolb, integer *k, - integer *l, doublecomplex *u, integer *ldu, doublecomplex *v, - integer *ldv, doublecomplex *q, integer *ldq, integer *iwork, - doublereal *rwork, doublecomplex *tau, doublecomplex *work, - integer *info, ftnlen jobu_len, ftnlen jobv_len, - ftnlen jobq_len); -extern int zgtcon_(char *norm, integer *n, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, doublecomplex *du2, - integer *ipiv, doublereal *anorm, doublereal *rcond, - doublecomplex *work, integer *info, ftnlen norm_len); -extern int zgtrfs_(char *trans, integer *n, integer *nrhs, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, doublecomplex *dlf, - doublecomplex *df, doublecomplex *duf, doublecomplex *du2, - integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen trans_len); -extern int zgtsv_(integer *n, integer *nrhs, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, doublecomplex *b, - integer *ldb, integer *info); -extern int zgtsvx_(char *fact, char *trans, integer *n, integer *nrhs, - doublecomplex *dl, doublecomplex *d__, doublecomplex *du, - doublecomplex *dlf, doublecomplex *df, doublecomplex *duf, - doublecomplex *du2, integer *ipiv, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen fact_len, ftnlen trans_len); -extern int zgttrf_(integer *n, doublecomplex *dl, doublecomplex *d__, - doublecomplex *du, doublecomplex *du2, integer *ipiv, - integer *info); -extern int zgttrs_(char *trans, integer *n, integer *nrhs, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, doublecomplex *du2, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info, - ftnlen trans_len); -extern int zgtts2_(integer *itrans, integer *n, integer *nrhs, - doublecomplex *dl, doublecomplex *d__, doublecomplex *du, - doublecomplex *du2, integer *ipiv, doublecomplex *b, - integer *ldb); -extern int zhbev_(char *jobz, char *uplo, integer *n, integer *kd, - doublecomplex *ab, integer *ldab, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int zhbevd_(char *jobz, char *uplo, integer *n, integer *kd, - doublecomplex *ab, integer *ldab, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *lrwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int zhbevx_(char *jobz, char *range, char *uplo, integer *n, integer *kd, - doublecomplex *ab, integer *ldab, doublecomplex *q, - integer *ldq, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - doublereal *rwork, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int zhbgst_(char *vect, char *uplo, integer *n, integer *ka, integer *kb, - doublecomplex *ab, integer *ldab, doublecomplex *bb, - integer *ldbb, doublecomplex *x, integer *ldx, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen vect_len, ftnlen uplo_len); -extern int zhbgv_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - doublecomplex *ab, integer *ldab, doublecomplex *bb, - integer *ldbb, doublereal *w, doublecomplex *z__, - integer *ldz, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int zhbgvd_(char *jobz, char *uplo, integer *n, integer *ka, integer *kb, - doublecomplex *ab, integer *ldab, doublecomplex *bb, - integer *ldbb, doublereal *w, doublecomplex *z__, - integer *ldz, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *lrwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int zhbgvx_(char *jobz, char *range, char *uplo, integer *n, integer *ka, - integer *kb, doublecomplex *ab, integer *ldab, - doublecomplex *bb, integer *ldbb, doublecomplex *q, - integer *ldq, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - doublereal *rwork, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int zhbtrd_(char *vect, char *uplo, integer *n, integer *kd, - doublecomplex *ab, integer *ldab, doublereal *d__, - doublereal *e, doublecomplex *q, integer *ldq, - doublecomplex *work, integer *info, ftnlen vect_len, - ftnlen uplo_len); -extern int zhecon_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, doublereal *anorm, doublereal *rcond, - doublecomplex *work, integer *info, ftnlen uplo_len); -extern int zheev_(char *jobz, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublereal *w, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int zheevd_(char *jobz, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublereal *w, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *lrwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int zheevr_(char *jobz, char *range, char *uplo, integer *n, - doublecomplex *a, integer *lda, doublereal *vl, - doublereal *vu, integer *il, integer *iu, doublereal *abstol, - integer *m, doublereal *w, doublecomplex *z__, integer *ldz, - integer *isuppz, doublecomplex *work, integer *lwork, - doublereal *rwork, integer *lrwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int zheevx_(char *jobz, char *range, char *uplo, integer *n, - doublecomplex *a, integer *lda, doublereal *vl, - doublereal *vu, integer *il, integer *iu, doublereal *abstol, - integer *m, doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *iwork, integer *ifail, integer *info, - ftnlen jobz_len, ftnlen range_len, ftnlen uplo_len); -extern int zhegs2_(integer *itype, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zhegst_(integer *itype, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zhegv_(integer *itype, char *jobz, char *uplo, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublereal *w, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int zhegvd_(integer *itype, char *jobz, char *uplo, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublereal *w, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *lrwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int zhegvx_(integer *itype, char *jobz, char *range, char *uplo, - integer *n, doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *iwork, - integer *ifail, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int zherfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, - integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen uplo_len); -extern int zhesv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int zhesvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublecomplex *a, integer *lda, doublecomplex *af, - integer *ldaf, integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *info, - ftnlen fact_len, ftnlen uplo_len); -extern int zhetd2_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tau, - integer *info, ftnlen uplo_len); -extern int zhetf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, integer *info, ftnlen uplo_len); -extern int zhetrd_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *d__, doublereal *e, doublecomplex *tau, - doublecomplex *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int zhetrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *work, integer *lwork, - integer *info, ftnlen uplo_len); -extern int zhetri_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *work, integer *info, - ftnlen uplo_len); -extern int zhetrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int zhgeqz_(char *job, char *compq, char *compz, integer *n, - integer *ilo, integer *ihi, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *alpha, - doublecomplex *beta, doublecomplex *q, integer *ldq, - doublecomplex *z__, integer *ldz, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *info, - ftnlen job_len, ftnlen compq_len, ftnlen compz_len); -extern int zhpcon_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - integer *info, ftnlen uplo_len); -extern int zhpev_(char *jobz, char *uplo, integer *n, doublecomplex *ap, - doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int zhpevd_(char *jobz, char *uplo, integer *n, doublecomplex *ap, - doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, integer *lwork, doublereal *rwork, - integer *lrwork, integer *iwork, integer *liwork, - integer *info, ftnlen jobz_len, ftnlen uplo_len); -extern int zhpevx_(char *jobz, char *range, char *uplo, integer *n, - doublecomplex *ap, doublereal *vl, doublereal *vu, - integer *il, integer *iu, doublereal *abstol, integer *m, - doublereal *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, doublereal *rwork, integer *iwork, - integer *ifail, integer *info, ftnlen jobz_len, - ftnlen range_len, ftnlen uplo_len); -extern int zhpgst_(integer *itype, char *uplo, integer *n, doublecomplex *ap, - doublecomplex *bp, integer *info, ftnlen uplo_len); -extern int zhpgv_(integer *itype, char *jobz, char *uplo, integer *n, - doublecomplex *ap, doublecomplex *bp, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen jobz_len, - ftnlen uplo_len); -extern int zhpgvd_(integer *itype, char *jobz, char *uplo, integer *n, - doublecomplex *ap, doublecomplex *bp, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *lrwork, - integer *iwork, integer *liwork, integer *info, - ftnlen jobz_len, ftnlen uplo_len); -extern int zhpgvx_(integer *itype, char *jobz, char *range, char *uplo, - integer *n, doublecomplex *ap, doublecomplex *bp, - doublereal *vl, doublereal *vu, integer *il, integer *iu, - doublereal *abstol, integer *m, doublereal *w, - doublecomplex *z__, integer *ldz, doublecomplex *work, - doublereal *rwork, integer *iwork, integer *ifail, - integer *info, ftnlen jobz_len, ftnlen range_len, - ftnlen uplo_len); -extern int zhprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, integer *ipiv, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, - doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen uplo_len); -extern int zhpsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zhpsvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublecomplex *ap, doublecomplex *afp, integer *ipiv, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen fact_len, ftnlen uplo_len); -extern int zhptrd_(char *uplo, integer *n, doublecomplex *ap, doublereal *d__, - doublereal *e, doublecomplex *tau, integer *info, - ftnlen uplo_len); -extern int zhptrf_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - integer *info, ftnlen uplo_len); -extern int zhptri_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - doublecomplex *work, integer *info, ftnlen uplo_len); -extern int zhptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zhsein_(char *side, char *eigsrc, char *initv, logical *select, - integer *n, doublecomplex *h__, integer *ldh, - doublecomplex *w, doublecomplex *vl, integer *ldvl, - doublecomplex *vr, integer *ldvr, integer *mm, integer *m, - doublecomplex *work, doublereal *rwork, integer *ifaill, - integer *ifailr, integer *info, ftnlen side_len, - ftnlen eigsrc_len, ftnlen initv_len); -extern int zhseqr_(char *job, char *compz, integer *n, integer *ilo, - integer *ihi, doublecomplex *h__, integer *ldh, - doublecomplex *w, doublecomplex *z__, integer *ldz, - doublecomplex *work, integer *lwork, integer *info, - ftnlen job_len, ftnlen compz_len); -extern int zlabrd_(integer *m, integer *n, integer *nb, doublecomplex *a, - integer *lda, doublereal *d__, doublereal *e, - doublecomplex *tauq, doublecomplex *taup, doublecomplex *x, - integer *ldx, doublecomplex *y, integer *ldy); -extern int zlacgv_(integer *n, doublecomplex *x, integer *incx); -extern int zlacon_(integer *n, doublecomplex *v, doublecomplex *x, - doublereal *est, integer *kase); -extern int zlacp2_(char *uplo, integer *m, integer *n, doublereal *a, - integer *lda, doublecomplex *b, integer *ldb, - ftnlen uplo_len); -extern int zlacpy_(char *uplo, integer *m, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - ftnlen uplo_len); -extern int zlacrm_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *b, integer *ldb, doublecomplex *c__, - integer *ldc, doublereal *rwork); -extern int zlacrt_(integer *n, doublecomplex *cx, integer *incx, - doublecomplex *cy, integer *incy, doublecomplex *c__, - doublecomplex *s); -extern Z_f zladiv_(doublecomplex *ret_val, doublecomplex *x, doublecomplex *y); -extern int zlaed0_(integer *qsiz, integer *n, doublereal *d__, doublereal *e, - doublecomplex *q, integer *ldq, doublecomplex *qstore, - integer *ldqs, doublereal *rwork, integer *iwork, - integer *info); -extern int zlaed7_(integer *n, integer *cutpnt, integer *qsiz, integer *tlvls, - integer *curlvl, integer *curpbm, doublereal *d__, - doublecomplex *q, integer *ldq, doublereal *rho, - integer *indxq, doublereal *qstore, integer *qptr, - integer *prmptr, integer *perm, integer *givptr, - integer *givcol, doublereal *givnum, doublecomplex *work, - doublereal *rwork, integer *iwork, integer *info); -extern int zlaed8_(integer *k, integer *n, integer *qsiz, doublecomplex *q, - integer *ldq, doublereal *d__, doublereal *rho, - integer *cutpnt, doublereal *z__, doublereal *dlamda, - doublecomplex *q2, integer *ldq2, doublereal *w, - integer *indxp, integer *indx, integer *indxq, integer *perm, - integer *givptr, integer *givcol, doublereal *givnum, - integer *info); -extern int zlaein_(logical *rightv, logical *noinit, integer *n, - doublecomplex *h__, integer *ldh, doublecomplex *w, - doublecomplex *v, doublecomplex *b, integer *ldb, - doublereal *rwork, doublereal *eps3, doublereal *smlnum, - integer *info); -extern int zlaesy_(doublecomplex *a, doublecomplex *b, doublecomplex *c__, - doublecomplex *rt1, doublecomplex *rt2, - doublecomplex *evscal, doublecomplex *cs1, - doublecomplex *sn1); -extern int zlaev2_(doublecomplex *a, doublecomplex *b, doublecomplex *c__, - doublereal *rt1, doublereal *rt2, doublereal *cs1, - doublecomplex *sn1); -extern int zlags2_(logical *upper, doublereal *a1, doublecomplex *a2, - doublereal *a3, doublereal *b1, doublecomplex *b2, - doublereal *b3, doublereal *csu, doublecomplex *snu, - doublereal *csv, doublecomplex *snv, doublereal *csq, - doublecomplex *snq); -extern int zlagtm_(char *trans, integer *n, integer *nrhs, doublereal *alpha, - doublecomplex *dl, doublecomplex *d__, doublecomplex *du, - doublecomplex *x, integer *ldx, doublereal *beta, - doublecomplex *b, integer *ldb, ftnlen trans_len); -extern int zlahef_(char *uplo, integer *n, integer *nb, integer *kb, - doublecomplex *a, integer *lda, integer *ipiv, - doublecomplex *w, integer *ldw, integer *info, - ftnlen uplo_len); -extern int zlahqr_(logical *wantt, logical *wantz, integer *n, integer *ilo, - integer *ihi, doublecomplex *h__, integer *ldh, - doublecomplex *w, integer *iloz, integer *ihiz, - doublecomplex *z__, integer *ldz, integer *info); -extern int zlahrd_(integer *n, integer *k, integer *nb, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *t, - integer *ldt, doublecomplex *y, integer *ldy); -extern int zlaic1_(integer *job, integer *j, doublecomplex *x, doublereal *sest, - doublecomplex *w, doublecomplex *gamma, doublereal *sestpr, - doublecomplex *s, doublecomplex *c__); -extern int zlals0_(integer *icompq, integer *nl, integer *nr, integer *sqre, - integer *nrhs, doublecomplex *b, integer *ldb, - doublecomplex *bx, integer *ldbx, integer *perm, - integer *givptr, integer *givcol, integer *ldgcol, - doublereal *givnum, integer *ldgnum, doublereal *poles, - doublereal *difl, doublereal *difr, doublereal *z__, - integer *k, doublereal *c__, doublereal *s, - doublereal *rwork, integer *info); -extern int zlalsa_(integer *icompq, integer *smlsiz, integer *n, integer *nrhs, - doublecomplex *b, integer *ldb, doublecomplex *bx, - integer *ldbx, doublereal *u, integer *ldu, doublereal *vt, - integer *k, doublereal *difl, doublereal *difr, - doublereal *z__, doublereal *poles, integer *givptr, - integer *givcol, integer *ldgcol, integer *perm, - doublereal *givnum, doublereal *c__, doublereal *s, - doublereal *rwork, integer *iwork, integer *info); -extern int zlalsd_(char *uplo, integer *smlsiz, integer *n, integer *nrhs, - doublereal *d__, doublereal *e, doublecomplex *b, - integer *ldb, doublereal *rcond, integer *rank, - doublecomplex *work, doublereal *rwork, integer *iwork, - integer *info, ftnlen uplo_len); -extern doublereal zlangb_(char *norm, integer *n, integer *kl, integer *ku, - doublecomplex *ab, integer *ldab, doublereal *work, - ftnlen norm_len); -extern doublereal zlange_(char *norm, integer *m, integer *n, doublecomplex *a, - integer *lda, doublereal *work, ftnlen norm_len); -extern doublereal zlangt_(char *norm, integer *n, doublecomplex *dl, - doublecomplex *d__, doublecomplex *du, - ftnlen norm_len); -extern doublereal zlanhb_(char *norm, char *uplo, integer *n, integer *k, - doublecomplex *ab, integer *ldab, doublereal *work, - ftnlen norm_len, ftnlen uplo_len); -extern doublereal zlanhe_(char *norm, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublereal *work, ftnlen norm_len, - ftnlen uplo_len); -extern doublereal zlanhp_(char *norm, char *uplo, integer *n, doublecomplex *ap, - doublereal *work, ftnlen norm_len, ftnlen uplo_len); -extern doublereal zlanhs_(char *norm, integer *n, doublecomplex *a, - integer *lda, doublereal *work, ftnlen norm_len); -extern doublereal zlanht_(char *norm, integer *n, doublereal *d__, - doublecomplex *e, ftnlen norm_len); -extern doublereal zlansb_(char *norm, char *uplo, integer *n, integer *k, - doublecomplex *ab, integer *ldab, doublereal *work, - ftnlen norm_len, ftnlen uplo_len); -extern doublereal zlansp_(char *norm, char *uplo, integer *n, doublecomplex *ap, - doublereal *work, ftnlen norm_len, ftnlen uplo_len); -extern doublereal zlansy_(char *norm, char *uplo, integer *n, doublecomplex *a, - integer *lda, doublereal *work, ftnlen norm_len, - ftnlen uplo_len); -extern doublereal zlantb_(char *norm, char *uplo, char *diag, integer *n, - integer *k, doublecomplex *ab, integer *ldab, - doublereal *work, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern doublereal zlantp_(char *norm, char *uplo, char *diag, integer *n, - doublecomplex *ap, doublereal *work, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern doublereal zlantr_(char *norm, char *uplo, char *diag, integer *m, - integer *n, doublecomplex *a, integer *lda, - doublereal *work, ftnlen norm_len, ftnlen uplo_len, - ftnlen diag_len); -extern int zlapll_(integer *n, doublecomplex *x, integer *incx, - doublecomplex *y, integer *incy, doublereal *ssmin); -extern int zlapmt_(logical *forwrd, integer *m, integer *n, doublecomplex *x, - integer *ldx, integer *k); -extern int zlaqgb_(integer *m, integer *n, integer *kl, integer *ku, - doublecomplex *ab, integer *ldab, doublereal *r__, - doublereal *c__, doublereal *rowcnd, doublereal *colcnd, - doublereal *amax, char *equed, ftnlen equed_len); -extern int zlaqge_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublereal *r__, doublereal *c__, doublereal *rowcnd, - doublereal *colcnd, doublereal *amax, char *equed, - ftnlen equed_len); -extern int zlaqhb_(char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, doublereal *s, doublereal *scond, - doublereal *amax, char *equed, ftnlen uplo_len, - ftnlen equed_len); -extern int zlaqhe_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *s, doublereal *scond, doublereal *amax, - char *equed, ftnlen uplo_len, ftnlen equed_len); -extern int zlaqhp_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, - doublereal *scond, doublereal *amax, char *equed, - ftnlen uplo_len, ftnlen equed_len); -extern int zlaqp2_(integer *m, integer *n, integer *offset, doublecomplex *a, - integer *lda, integer *jpvt, doublecomplex *tau, - doublereal *vn1, doublereal *vn2, doublecomplex *work); -extern int zlaqps_(integer *m, integer *n, integer *offset, integer *nb, - integer *kb, doublecomplex *a, integer *lda, integer *jpvt, - doublecomplex *tau, doublereal *vn1, doublereal *vn2, - doublecomplex *auxv, doublecomplex *f, integer *ldf); -extern int zlaqsb_(char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, doublereal *s, doublereal *scond, - doublereal *amax, char *equed, ftnlen uplo_len, - ftnlen equed_len); -extern int zlaqsp_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, - doublereal *scond, doublereal *amax, char *equed, - ftnlen uplo_len, ftnlen equed_len); -extern int zlaqsy_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *s, doublereal *scond, doublereal *amax, - char *equed, ftnlen uplo_len, ftnlen equed_len); -extern int zlar1v_(integer *n, integer *b1, integer *bn, doublereal *sigma, - doublereal *d__, doublereal *l, doublereal *ld, - doublereal *lld, doublereal *gersch, doublecomplex *z__, - doublereal *ztz, doublereal *mingma, integer *r__, - integer *isuppz, doublereal *work); -extern int zlar2v_(integer *n, doublecomplex *x, doublecomplex *y, - doublecomplex *z__, integer *incx, doublereal *c__, - doublecomplex *s, integer *incc); -extern int zlarcm_(integer *m, integer *n, doublereal *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *c__, - integer *ldc, doublereal *rwork); -extern int zlarf_(char *side, integer *m, integer *n, doublecomplex *v, - integer *incv, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, ftnlen side_len); -extern int zlarfb_(char *side, char *trans, char *direct, char *storev, - integer *m, integer *n, integer *k, doublecomplex *v, - integer *ldv, doublecomplex *t, integer *ldt, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *ldwork, ftnlen side_len, ftnlen trans_len, - ftnlen direct_len, ftnlen storev_len); -extern int zlarfg_(integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *tau); -extern int zlarft_(char *direct, char *storev, integer *n, integer *k, - doublecomplex *v, integer *ldv, doublecomplex *tau, - doublecomplex *t, integer *ldt, ftnlen direct_len, - ftnlen storev_len); -extern int zlarfx_(char *side, integer *m, integer *n, doublecomplex *v, - doublecomplex *tau, doublecomplex *c__, integer *ldc, - doublecomplex *work, ftnlen side_len); -extern int zlargv_(integer *n, doublecomplex *x, integer *incx, - doublecomplex *y, integer *incy, doublereal *c__, - integer *incc); -extern int zlarnv_(integer *idist, integer *iseed, integer *n, - doublecomplex *x); -extern int zlarrv_(integer *n, doublereal *d__, doublereal *l, integer *isplit, - integer *m, doublereal *w, integer *iblock, - doublereal *gersch, doublereal *tol, doublecomplex *z__, - integer *ldz, integer *isuppz, doublereal *work, - integer *iwork, integer *info); -extern int zlartg_(doublecomplex *f, doublecomplex *g, doublereal *cs, - doublecomplex *sn, doublecomplex *r__); -extern int zlartv_(integer *n, doublecomplex *x, integer *incx, - doublecomplex *y, integer *incy, doublereal *c__, - doublecomplex *s, integer *incc); -extern int zlarz_(char *side, integer *m, integer *n, integer *l, - doublecomplex *v, integer *incv, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - ftnlen side_len); -extern int zlarzb_(char *side, char *trans, char *direct, char *storev, - integer *m, integer *n, integer *k, integer *l, - doublecomplex *v, integer *ldv, doublecomplex *t, - integer *ldt, doublecomplex *c__, integer *ldc, - doublecomplex *work, integer *ldwork, ftnlen side_len, - ftnlen trans_len, ftnlen direct_len, ftnlen storev_len); -extern int zlarzt_(char *direct, char *storev, integer *n, integer *k, - doublecomplex *v, integer *ldv, doublecomplex *tau, - doublecomplex *t, integer *ldt, ftnlen direct_len, - ftnlen storev_len); -extern int zlascl_(char *type__, integer *kl, integer *ku, doublereal *cfrom, - doublereal *cto, integer *m, integer *n, doublecomplex *a, - integer *lda, integer *info, ftnlen type_len); -extern int zlaset_(char *uplo, integer *m, integer *n, doublecomplex *alpha, - doublecomplex *beta, doublecomplex *a, integer *lda, - ftnlen uplo_len); -extern int zlasr_(char *side, char *pivot, char *direct, integer *m, integer *n, - doublereal *c__, doublereal *s, doublecomplex *a, - integer *lda, ftnlen side_len, ftnlen pivot_len, - ftnlen direct_len); -extern int zlassq_(integer *n, doublecomplex *x, integer *incx, - doublereal *scale, doublereal *sumsq); -extern int zlaswp_(integer *n, doublecomplex *a, integer *lda, integer *k1, - integer *k2, integer *ipiv, integer *incx); -extern int zlasyf_(char *uplo, integer *n, integer *nb, integer *kb, - doublecomplex *a, integer *lda, integer *ipiv, - doublecomplex *w, integer *ldw, integer *info, - ftnlen uplo_len); -extern int zlatbs_(char *uplo, char *trans, char *diag, char *normin, - integer *n, integer *kd, doublecomplex *ab, integer *ldab, - doublecomplex *x, doublereal *scale, doublereal *cnorm, - integer *info, ftnlen uplo_len, ftnlen trans_len, - ftnlen diag_len, ftnlen normin_len); -extern int zlatdf_(integer *ijob, integer *n, doublecomplex *z__, integer *ldz, - doublecomplex *rhs, doublereal *rdsum, doublereal *rdscal, - integer *ipiv, integer *jpiv); -extern int zlatps_(char *uplo, char *trans, char *diag, char *normin, - integer *n, doublecomplex *ap, doublecomplex *x, - doublereal *scale, doublereal *cnorm, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len, - ftnlen normin_len); -extern int zlatrd_(char *uplo, integer *n, integer *nb, doublecomplex *a, - integer *lda, doublereal *e, doublecomplex *tau, - doublecomplex *w, integer *ldw, ftnlen uplo_len); -extern int zlatrs_(char *uplo, char *trans, char *diag, char *normin, - integer *n, doublecomplex *a, integer *lda, doublecomplex *x, - doublereal *scale, doublereal *cnorm, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len, - ftnlen normin_len); -extern int zlatrz_(integer *m, integer *n, integer *l, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work); -extern int zlatzm_(char *side, integer *m, integer *n, doublecomplex *v, - integer *incv, doublecomplex *tau, doublecomplex *c1, - doublecomplex *c2, integer *ldc, doublecomplex *work, - ftnlen side_len); -extern int zlauu2_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int zlauum_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int zpbcon_(char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, doublereal *anorm, doublereal *rcond, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen uplo_len); -extern int zpbequ_(char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, doublereal *s, doublereal *scond, - doublereal *amax, integer *info, ftnlen uplo_len); -extern int zpbrfs_(char *uplo, integer *n, integer *kd, integer *nrhs, - doublecomplex *ab, integer *ldab, doublecomplex *afb, - integer *ldafb, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen uplo_len); -extern int zpbstf_(char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int zpbsv_(char *uplo, integer *n, integer *kd, integer *nrhs, - doublecomplex *ab, integer *ldab, doublecomplex *b, - integer *ldb, integer *info, ftnlen uplo_len); -extern int zpbsvx_(char *fact, char *uplo, integer *n, integer *kd, - integer *nrhs, doublecomplex *ab, integer *ldab, - doublecomplex *afb, integer *ldafb, char *equed, - doublereal *s, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen fact_len, - ftnlen uplo_len, ftnlen equed_len); -extern int zpbtf2_(char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int zpbtrf_(char *uplo, integer *n, integer *kd, doublecomplex *ab, - integer *ldab, integer *info, ftnlen uplo_len); -extern int zpbtrs_(char *uplo, integer *n, integer *kd, integer *nrhs, - doublecomplex *ab, integer *ldab, doublecomplex *b, - integer *ldb, integer *info, ftnlen uplo_len); -extern int zpocon_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen uplo_len); -extern int zpoequ_(integer *n, doublecomplex *a, integer *lda, doublereal *s, - doublereal *scond, doublereal *amax, integer *info); -extern int zporfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen uplo_len); -extern int zposv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zposvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublecomplex *a, integer *lda, doublecomplex *af, - integer *ldaf, char *equed, doublereal *s, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, - doublereal *rcond, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen fact_len, ftnlen uplo_len, ftnlen equed_len); -extern int zpotf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int zpotrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int zpotri_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *info, ftnlen uplo_len); -extern int zpotrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zppcon_(char *uplo, integer *n, doublecomplex *ap, doublereal *anorm, - doublereal *rcond, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen uplo_len); -extern int zppequ_(char *uplo, integer *n, doublecomplex *ap, doublereal *s, - doublereal *scond, doublereal *amax, integer *info, - ftnlen uplo_len); -extern int zpprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen uplo_len); -extern int zppsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zppsvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublecomplex *ap, doublecomplex *afp, char *equed, - doublereal *s, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen fact_len, - ftnlen uplo_len, ftnlen equed_len); -extern int zpptrf_(char *uplo, integer *n, doublecomplex *ap, integer *info, - ftnlen uplo_len); -extern int zpptri_(char *uplo, integer *n, doublecomplex *ap, integer *info, - ftnlen uplo_len); -extern int zpptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zptcon_(integer *n, doublereal *d__, doublecomplex *e, - doublereal *anorm, doublereal *rcond, doublereal *rwork, - integer *info); -extern int zpteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublecomplex *z__, integer *ldz, doublereal *work, - integer *info, ftnlen compz_len); -extern int zptrfs_(char *uplo, integer *n, integer *nrhs, doublereal *d__, - doublecomplex *e, doublereal *df, doublecomplex *ef, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen uplo_len); -extern int zptsv_(integer *n, integer *nrhs, doublereal *d__, doublecomplex *e, - doublecomplex *b, integer *ldb, integer *info); -extern int zptsvx_(char *fact, integer *n, integer *nrhs, doublereal *d__, - doublecomplex *e, doublereal *df, doublecomplex *ef, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen fact_len); -extern int zpttrf_(integer *n, doublereal *d__, doublecomplex *e, - integer *info); -extern int zpttrs_(char *uplo, integer *n, integer *nrhs, doublereal *d__, - doublecomplex *e, doublecomplex *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int zptts2_(integer *iuplo, integer *n, integer *nrhs, doublereal *d__, - doublecomplex *e, doublecomplex *b, integer *ldb); -extern int zrot_(integer *n, doublecomplex *cx, integer *incx, - doublecomplex *cy, integer *incy, doublereal *c__, - doublecomplex *s); -extern int zspcon_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - doublereal *anorm, doublereal *rcond, doublecomplex *work, - integer *info, ftnlen uplo_len); -extern int zspmv_(char *uplo, integer *n, doublecomplex *alpha, - doublecomplex *ap, doublecomplex *x, integer *incx, - doublecomplex *beta, doublecomplex *y, integer *incy, - ftnlen uplo_len); -extern int zspr_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *ap, ftnlen uplo_len); -extern int zsprfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - doublecomplex *afp, integer *ipiv, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, - doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen uplo_len); -extern int zspsv_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zspsvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublecomplex *ap, doublecomplex *afp, integer *ipiv, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *rcond, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen fact_len, ftnlen uplo_len); -extern int zsptrf_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - integer *info, ftnlen uplo_len); -extern int zsptri_(char *uplo, integer *n, doublecomplex *ap, integer *ipiv, - doublecomplex *work, integer *info, ftnlen uplo_len); -extern int zsptrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *ap, - integer *ipiv, doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len); -extern int zstedc_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublecomplex *z__, integer *ldz, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *lrwork, - integer *iwork, integer *liwork, integer *info, - ftnlen compz_len); -extern int zstegr_(char *jobz, char *range, integer *n, doublereal *d__, - doublereal *e, doublereal *vl, doublereal *vu, integer *il, - integer *iu, doublereal *abstol, integer *m, doublereal *w, - doublecomplex *z__, integer *ldz, integer *isuppz, - doublereal *work, integer *lwork, integer *iwork, - integer *liwork, integer *info, ftnlen jobz_len, - ftnlen range_len); -extern int zstein_(integer *n, doublereal *d__, doublereal *e, integer *m, - doublereal *w, integer *iblock, integer *isplit, - doublecomplex *z__, integer *ldz, doublereal *work, - integer *iwork, integer *ifail, integer *info); -extern int zsteqr_(char *compz, integer *n, doublereal *d__, doublereal *e, - doublecomplex *z__, integer *ldz, doublereal *work, - integer *info, ftnlen compz_len); -extern int zsycon_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, doublereal *anorm, doublereal *rcond, - doublecomplex *work, integer *info, ftnlen uplo_len); -extern int zsymv_(char *uplo, integer *n, doublecomplex *alpha, - doublecomplex *a, integer *lda, doublecomplex *x, - integer *incx, doublecomplex *beta, doublecomplex *y, - integer *incy, ftnlen uplo_len); -extern int zsyr_(char *uplo, integer *n, doublecomplex *alpha, doublecomplex *x, - integer *incx, doublecomplex *a, integer *lda, - ftnlen uplo_len); -extern int zsyrfs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, doublecomplex *af, integer *ldaf, - integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *ferr, - doublereal *berr, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen uplo_len); -extern int zsysv_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *work, integer *lwork, integer *info, - ftnlen uplo_len); -extern int zsysvx_(char *fact, char *uplo, integer *n, integer *nrhs, - doublecomplex *a, integer *lda, doublecomplex *af, - integer *ldaf, integer *ipiv, doublecomplex *b, integer *ldb, - doublecomplex *x, integer *ldx, doublereal *rcond, - doublereal *ferr, doublereal *berr, doublecomplex *work, - integer *lwork, doublereal *rwork, integer *info, - ftnlen fact_len, ftnlen uplo_len); -extern int zsytf2_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, integer *info, ftnlen uplo_len); -extern int zsytrf_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *work, integer *lwork, - integer *info, ftnlen uplo_len); -extern int zsytri_(char *uplo, integer *n, doublecomplex *a, integer *lda, - integer *ipiv, doublecomplex *work, integer *info, - ftnlen uplo_len); -extern int zsytrs_(char *uplo, integer *n, integer *nrhs, doublecomplex *a, - integer *lda, integer *ipiv, doublecomplex *b, integer *ldb, - integer *info, ftnlen uplo_len); -extern int ztbcon_(char *norm, char *uplo, char *diag, integer *n, integer *kd, - doublecomplex *ab, integer *ldab, doublereal *rcond, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen norm_len, ftnlen uplo_len, ftnlen diag_len); -extern int ztbrfs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, doublecomplex *ab, integer *ldab, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ztbtrs_(char *uplo, char *trans, char *diag, integer *n, integer *kd, - integer *nrhs, doublecomplex *ab, integer *ldab, - doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ztgevc_(char *side, char *howmny, logical *select, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *vl, integer *ldvl, - doublecomplex *vr, integer *ldvr, integer *mm, integer *m, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen side_len, ftnlen howmny_len); -extern int ztgex2_(logical *wantq, logical *wantz, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *q, integer *ldq, doublecomplex *z__, - integer *ldz, integer *j1, integer *info); -extern int ztgexc_(logical *wantq, logical *wantz, integer *n, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublecomplex *q, integer *ldq, doublecomplex *z__, - integer *ldz, integer *ifst, integer *ilst, integer *info); -extern int ztgsen_(integer *ijob, logical *wantq, logical *wantz, - logical *select, integer *n, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *alpha, - doublecomplex *beta, doublecomplex *q, integer *ldq, - doublecomplex *z__, integer *ldz, integer *m, doublereal *pl, - doublereal *pr, doublereal *dif, doublecomplex *work, - integer *lwork, integer *iwork, integer *liwork, - integer *info); -extern int ztgsja_(char *jobu, char *jobv, char *jobq, integer *m, integer *p, - integer *n, integer *k, integer *l, doublecomplex *a, - integer *lda, doublecomplex *b, integer *ldb, - doublereal *tola, doublereal *tolb, doublereal *alpha, - doublereal *beta, doublecomplex *u, integer *ldu, - doublecomplex *v, integer *ldv, doublecomplex *q, - integer *ldq, doublecomplex *work, integer *ncycle, - integer *info, ftnlen jobu_len, ftnlen jobv_len, - ftnlen jobq_len); -extern int ztgsna_(char *job, char *howmny, logical *select, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *vl, integer *ldvl, - doublecomplex *vr, integer *ldvr, doublereal *s, - doublereal *dif, integer *mm, integer *m, - doublecomplex *work, integer *lwork, integer *iwork, - integer *info, ftnlen job_len, ftnlen howmny_len); -extern int ztgsy2_(char *trans, integer *ijob, integer *m, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *c__, integer *ldc, - doublecomplex *d__, integer *ldd, doublecomplex *e, - integer *lde, doublecomplex *f, integer *ldf, - doublereal *scale, doublereal *rdsum, doublereal *rdscal, - integer *info, ftnlen trans_len); -extern int ztgsyl_(char *trans, integer *ijob, integer *m, integer *n, - doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *c__, integer *ldc, - doublecomplex *d__, integer *ldd, doublecomplex *e, - integer *lde, doublecomplex *f, integer *ldf, - doublereal *scale, doublereal *dif, doublecomplex *work, - integer *lwork, integer *iwork, integer *info, - ftnlen trans_len); -extern int ztpcon_(char *norm, char *uplo, char *diag, integer *n, - doublecomplex *ap, doublereal *rcond, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen norm_len, - ftnlen uplo_len, ftnlen diag_len); -extern int ztprfs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, doublecomplex *ap, doublecomplex *b, - integer *ldb, doublecomplex *x, integer *ldx, - doublereal *ferr, doublereal *berr, doublecomplex *work, - doublereal *rwork, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int ztptri_(char *uplo, char *diag, integer *n, doublecomplex *ap, - integer *info, ftnlen uplo_len, ftnlen diag_len); -extern int ztptrs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, doublecomplex *ap, doublecomplex *b, - integer *ldb, integer *info, ftnlen uplo_len, - ftnlen trans_len, ftnlen diag_len); -extern int ztrcon_(char *norm, char *uplo, char *diag, integer *n, - doublecomplex *a, integer *lda, doublereal *rcond, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen norm_len, ftnlen uplo_len, ftnlen diag_len); -extern int ztrevc_(char *side, char *howmny, logical *select, integer *n, - doublecomplex *t, integer *ldt, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, integer *mm, - integer *m, doublecomplex *work, doublereal *rwork, - integer *info, ftnlen side_len, ftnlen howmny_len); -extern int ztrexc_(char *compq, integer *n, doublecomplex *t, integer *ldt, - doublecomplex *q, integer *ldq, integer *ifst, integer *ilst, - integer *info, ftnlen compq_len); -extern int ztrrfs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, doublecomplex *x, - integer *ldx, doublereal *ferr, doublereal *berr, - doublecomplex *work, doublereal *rwork, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ztrsen_(char *job, char *compq, logical *select, integer *n, - doublecomplex *t, integer *ldt, doublecomplex *q, - integer *ldq, doublecomplex *w, integer *m, doublereal *s, - doublereal *sep, doublecomplex *work, integer *lwork, - integer *info, ftnlen job_len, ftnlen compq_len); -extern int ztrsna_(char *job, char *howmny, logical *select, integer *n, - doublecomplex *t, integer *ldt, doublecomplex *vl, - integer *ldvl, doublecomplex *vr, integer *ldvr, - doublereal *s, doublereal *sep, integer *mm, integer *m, - doublecomplex *work, integer *ldwork, doublereal *rwork, - integer *info, ftnlen job_len, ftnlen howmny_len); -extern int ztrsyl_(char *trana, char *tranb, integer *isgn, integer *m, - integer *n, doublecomplex *a, integer *lda, doublecomplex *b, - integer *ldb, doublecomplex *c__, integer *ldc, - doublereal *scale, integer *info, ftnlen trana_len, - ftnlen tranb_len); -extern int ztrti2_(char *uplo, char *diag, integer *n, doublecomplex *a, - integer *lda, integer *info, ftnlen uplo_len, - ftnlen diag_len); -extern int ztrtri_(char *uplo, char *diag, integer *n, doublecomplex *a, - integer *lda, integer *info, ftnlen uplo_len, - ftnlen diag_len); -extern int ztrtrs_(char *uplo, char *trans, char *diag, integer *n, - integer *nrhs, doublecomplex *a, integer *lda, - doublecomplex *b, integer *ldb, integer *info, - ftnlen uplo_len, ftnlen trans_len, ftnlen diag_len); -extern int ztzrqf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, integer *info); -extern int ztzrzf_(integer *m, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info); -extern int zung2l_(integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *info); -extern int zung2r_(integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *info); -extern int zungbr_(char *vect, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *work, integer *lwork, integer *info, - ftnlen vect_len); -extern int zunghr_(integer *n, integer *ilo, integer *ihi, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *lwork, integer *info); -extern int zungl2_(integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *info); -extern int zunglq_(integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *lwork, integer *info); -extern int zungql_(integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *lwork, integer *info); -extern int zungqr_(integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *lwork, integer *info); -extern int zungr2_(integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *info); -extern int zungrq_(integer *m, integer *n, integer *k, doublecomplex *a, - integer *lda, doublecomplex *tau, doublecomplex *work, - integer *lwork, integer *info); -extern int zungtr_(char *uplo, integer *n, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *work, integer *lwork, - integer *info, ftnlen uplo_len); -extern int zunm2l_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int zunm2r_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int zunmbr_(char *vect, char *side, char *trans, integer *m, integer *n, - integer *k, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *c__, integer *ldc, - doublecomplex *work, integer *lwork, integer *info, - ftnlen vect_len, ftnlen side_len, ftnlen trans_len); -extern int zunmhr_(char *side, char *trans, integer *m, integer *n, - integer *ilo, integer *ihi, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *c__, integer *ldc, - doublecomplex *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int zunml2_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int zunmlq_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int zunmql_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int zunmqr_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int zunmr2_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *info, ftnlen side_len, ftnlen trans_len); -extern int zunmr3_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *c__, integer *ldc, - doublecomplex *work, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int zunmrq_(char *side, char *trans, integer *m, integer *n, integer *k, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen trans_len); -extern int zunmrz_(char *side, char *trans, integer *m, integer *n, integer *k, - integer *l, doublecomplex *a, integer *lda, - doublecomplex *tau, doublecomplex *c__, integer *ldc, - doublecomplex *work, integer *lwork, integer *info, - ftnlen side_len, ftnlen trans_len); -extern int zunmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - doublecomplex *a, integer *lda, doublecomplex *tau, - doublecomplex *c__, integer *ldc, doublecomplex *work, - integer *lwork, integer *info, ftnlen side_len, - ftnlen uplo_len, ftnlen trans_len); -extern int zupgtr_(char *uplo, integer *n, doublecomplex *ap, - doublecomplex *tau, doublecomplex *q, integer *ldq, - doublecomplex *work, integer *info, ftnlen uplo_len); -extern int zupmtr_(char *side, char *uplo, char *trans, integer *m, integer *n, - doublecomplex *ap, doublecomplex *tau, doublecomplex *c__, - integer *ldc, doublecomplex *work, integer *info, - ftnlen side_len, ftnlen uplo_len, ftnlen trans_len); - -#endif diff --git a/lib/cairodriver/cairodriver.dox b/lib/cairodriver/cairodriver.dox index d7ce1ab60e2..ca3ac067e06 100644 --- a/lib/cairodriver/cairodriver.dox +++ b/lib/cairodriver/cairodriver.dox @@ -11,7 +11,7 @@ output, see Cairo website for details. GRASS Cairo display %driver was originally written by Lars Ahlzen (announcement). +href="https://lists.osgeo.org/pipermail/grass-dev/2007-October/033524.html">announcement). \section cairofunctions List of functions diff --git a/lib/db/README b/lib/db/README index 7268b4e182f..9dc8faf9ab6 100644 --- a/lib/db/README +++ b/lib/db/README @@ -26,7 +26,7 @@ DBMI Library Original author: Joel Jones (jjones * zorro.cecer.army.mil | jjones * uiuc.edu ) - Ref: http://lists.osgeo.org/pipermail/grass-dev/1995-February/002015.html + Ref: https://lists.osgeo.org/pipermail/grass-dev/1995-February/002015.html Directory contents: diff --git a/lib/db/dbmi_base/connect.c b/lib/db/dbmi_base/connect.c index 780d929dd3a..ced282405bd 100644 --- a/lib/db/dbmi_base/connect.c +++ b/lib/db/dbmi_base/connect.c @@ -87,11 +87,11 @@ int db_get_connection(dbConnection *connection) connection->group = (char *)G_getenv_nofatal2("DB_GROUP", G_VAR_MAPSET); /* try to get user/password */ - db_get_login2(connection->driverName, connection->databaseName, - (const char **)&(connection->user), - (const char **)&(connection->password), - (const char **)&(connection->hostName), - (const char **)&(connection->port)); + db_get_login(connection->driverName, connection->databaseName, + (const char **)&(connection->user), + (const char **)&(connection->password), + (const char **)&(connection->hostName), + (const char **)&(connection->port)); return DB_OK; } diff --git a/lib/db/dbmi_base/default_name.c b/lib/db/dbmi_base/default_name.c index f9904651a06..839060b44d9 100644 --- a/lib/db/dbmi_base/default_name.c +++ b/lib/db/dbmi_base/default_name.c @@ -123,7 +123,7 @@ int db_set_default_connection(void) * that here?) or $MAPSET/sqlite/mapname.sql as with dbf? */ - /* http://www.sqlite.org/lockingv3.html + /* https://www.sqlite.org/lockingv3.html * When SQLite creates a journal file on Unix, it opens the * directory that contains that file and calls fsync() on the * directory, in an effort to push the directory information to disk. diff --git a/lib/db/dbmi_base/login.c b/lib/db/dbmi_base/login.c index d79fc84e6cf..9c865233d2c 100644 --- a/lib/db/dbmi_base/login.c +++ b/lib/db/dbmi_base/login.c @@ -253,22 +253,23 @@ static int set_login(const char *driver, const char *database, const char *user, /*! \brief Set login parameters for driver/database - \deprecated Use db_set_login2() instead. - - \todo: GRASS 8: to be replaced by db_set_login2(). - \param driver driver name \param database database name \param user user name \param password password string + \param host host name + \param port + \param overwrite TRUE to overwrite existing connections \return DB_OK on success \return DB_FAILED on failure */ -int db_set_login(const char *driver, const char *database, const char *user, - const char *password) +int db_set_login2(const char *driver, const char *database, const char *user, + const char *password, const char *host, const char *port, + int overwrite) { - return set_login(driver, database, user, password, NULL, NULL, FALSE); + return db_set_login(driver, database, user, password, host, port, + overwrite); } /*! @@ -285,9 +286,9 @@ int db_set_login(const char *driver, const char *database, const char *user, \return DB_OK on success \return DB_FAILED on failure */ -int db_set_login2(const char *driver, const char *database, const char *user, - const char *password, const char *host, const char *port, - int overwrite) +int db_set_login(const char *driver, const char *database, const char *user, + const char *password, const char *host, const char *port, + int overwrite) { return set_login(driver, database, user, password, host, port, overwrite); } @@ -346,22 +347,20 @@ static int get_login(const char *driver, const char *database, If driver/database is not found, output arguments are set to NULL. - \deprecated Use db_set_login2() instead. - - \todo: GRASS 8: to be replaced by db_set_login2(). - \param driver driver name \param database database name (can be NULL) \param[out] user name \param[out] password string + \param[out] host name + \param[out] port \return DB_OK on success \return DB_FAILED on failure */ -int db_get_login(const char *driver, const char *database, const char **user, - const char **password) +int db_get_login2(const char *driver, const char *database, const char **user, + const char **password, const char **host, const char **port) { - return get_login(driver, database, user, password, NULL, NULL); + return db_get_login(driver, database, user, password, host, port); } /*! @@ -379,8 +378,8 @@ int db_get_login(const char *driver, const char *database, const char **user, \return DB_OK on success \return DB_FAILED on failure */ -int db_get_login2(const char *driver, const char *database, const char **user, - const char **password, const char **host, const char **port) +int db_get_login(const char *driver, const char *database, const char **user, + const char **password, const char **host, const char **port) { return get_login(driver, database, user, password, host, port); } diff --git a/lib/db/dbmilib.dox b/lib/db/dbmilib.dox index fdbac5fab36..0c85715e7f0 100644 --- a/lib/db/dbmilib.dox +++ b/lib/db/dbmilib.dox @@ -15,10 +15,10 @@ Interface) with its integrated drivers. At time of this writing following DBMI drivers for attribute storage are available: - DBF: xBase files (default) - - ODBC: to interface from http://www.unixodbc.org - - PostgreSQL driver (note that PostgreSQL can also be accessed through ODBC): http://www.postgresql.org + - ODBC: to interface from https://www.unixodbc.org + - PostgreSQL driver (note that PostgreSQL can also be accessed through ODBC): https://www.postgresql.org - mySQL: http://mysql.com/ - - SQLite: http://www.sqlite.org + - SQLite: https://www.sqlite.org These drivers are compiled depending on present DB related libraries and 'configure' settings. Only the DBF driver is always compiled. The diff --git a/lib/db/sqlp/sql.html b/lib/db/sqlp/sql.html index 730d0462c2a..eaed6a74b70 100644 --- a/lib/db/sqlp/sql.html +++ b/lib/db/sqlp/sql.html @@ -9,9 +9,9 @@ attribute table.

    GRASS GIS supports various RDBMS -(Relational +(Relational database management system) and embedded databases. SQL -(Structured Query +(Structured Query Language) queries are directly passed to the underlying database system. The set of supported SQL commands depends on the RDMBS and database driver selected. @@ -44,10 +44,10 @@

    Database drivers

    http://mysql.org/ --> odbcData storage via UnixODBC (PostgreSQL, Oracle, etc.) -http://www.unixodbc.org/ +https://www.unixodbc.org/ ogrData storage in OGR files -http://gdal.org/ +https://gdal.org/

    NOTES

    diff --git a/lib/external/shapelib/README.md b/lib/external/shapelib/README.md index e004d2d0419..d446eccd014 100644 --- a/lib/external/shapelib/README.md +++ b/lib/external/shapelib/README.md @@ -1,12 +1,13 @@ # Update history of SHAPELIB copy -* files `shpopen.c`, `shapefil.h`, `dbfopen.c` +* files `shpopen.c`, `shapefil.h`, `dbfopen.c`, `shapefil_private.h` from GDAL [ogr/ogrsf_frmts/shape/](https://github.com/OSGeo/gdal/tree/master/ogr/ogrsf_frmts/shape) * file `safileio.c` from [SHAPELIB](http://download.osgeo.org/shapelib/) ## Last update +* taken from GDAL 3.9.2 and SHAPELIB 1.6.0 (Sep 2024) * taken from GDAL 3.5.3 and SHAPELIB 1.5.0 (Dec 2022) * taken from GDAL 2.1.2 and SHAPELIB 1.3.0 (Thu Nov 24 10:45:41 CET 2016) * taken from GDAL 1.5.1-SVN (Sun Mar 30 11:20:43 CEST 2008) @@ -15,44 +16,5 @@ ## Summary of fixes -* dbfopen.c - around line 1229: GDAL bug [ticket-#809](http://trac.osgeo.org/gdal/ticket/809) - * safileio.c - SHP_CVSID: ISO C does not allow extra ‘;’ outside of a function - -## Full fix - -```diff -diff --git a/lib/external/shapelib/dbfopen.c b/lib/external/shapelib/dbfopen.c -index 5380e3e20b..5151148d33 100644 ---- a/lib/external/shapelib/dbfopen.c -+++ b/lib/external/shapelib/dbfopen.c -@@ -1226,9 +1226,10 @@ DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName, - else if( psDBF->pachFieldType[iField] == 'N' - || psDBF->pachFieldType[iField] == 'F' ) - { -- if( psDBF->panFieldDecimals[iField] > 0 -- || psDBF->panFieldSize[iField] >= 10 ) -+ if( psDBF->panFieldDecimals[iField] > 0 ) { -+ /* || psDBF->panFieldSize[iField] >= 10 ) */ /* GDAL bug #809 */ - return( FTDouble ); -+ } - else - return( FTInteger ); - } -diff --git a/lib/external/shapelib/safileio.c b/lib/external/shapelib/safileio.c -index 289d347eaf..7a614a5806 100644 ---- a/lib/external/shapelib/safileio.c -+++ b/lib/external/shapelib/safileio.c -@@ -74,7 +74,7 @@ - #include - #include - --SHP_CVSID("$Id: safileio.c,v 1.6 2018-06-15 19:56:32 erouault Exp $"); -+SHP_CVSID("$Id: safileio.c,v 1.6 2018-06-15 19:56:32 erouault Exp $") - - #ifdef SHPAPI_UTF8_HOOKS - # ifdef SHPAPI_WINDOWS - -``` + [shapelib commit 316ff87](https://github.com/OSGeo/shapelib/commit/316ff872566ea0d91d6b62fe01bfe39931db39aa#diff-f068bc465ca1a32e1b9c214d4eb9504ef9e0f3c4cabc1aa4bab8aa41e2248cc6R153) diff --git a/lib/external/shapelib/dbfopen.c b/lib/external/shapelib/dbfopen.c index 2bbba339e21..9078a29ba95 100644 --- a/lib/external/shapelib/dbfopen.c +++ b/lib/external/shapelib/dbfopen.c @@ -1,5 +1,4 @@ /****************************************************************************** - * $Id$ * * Project: Shapelib * Purpose: Implementation of .dbf access API documented in dbf_api.html. @@ -9,32 +8,10 @@ * Copyright (c) 1999, Frank Warmerdam * Copyright (c) 2012-2019, Even Rouault * - * This software is available under the following "MIT Style" license, - * or at the option of the licensee under the LGPL (see COPYING). This - * option is discussed in more detail in shapelib.html. - * - * -- - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later ******************************************************************************/ -#include "shapefil.h" +#include "shapefil_private.h" #include #include @@ -47,7 +24,9 @@ #include "cpl_string.h" #else -#if defined(WIN32) || defined(_WIN32) +#if defined(_MSC_VER) +#define STRCASECMP(a, b) (_stricmp(a, b)) +#elif defined(_WIN32) #define STRCASECMP(a, b) (stricmp(a, b)) #else #include @@ -58,7 +37,7 @@ #if _MSC_VER < 1900 #define snprintf _snprintf #endif -#elif defined(WIN32) || defined(_WIN32) +#elif defined(_WIN32) #ifndef snprintf #define snprintf _snprintf #endif @@ -68,8 +47,6 @@ #define CPLsnprintf snprintf #endif -SHP_CVSID("$Id$") - #ifndef FALSE #define FALSE 0 #define TRUE 1 @@ -91,33 +68,6 @@ CPL_INLINE static void CPL_IGNORE_RET_VAL_INT(CPL_UNUSED int unused) #define CPL_IGNORE_RET_VAL_INT(x) x #endif -#ifdef __cplusplus -#define STATIC_CAST(type, x) static_cast(x) -#define REINTERPRET_CAST(type, x) reinterpret_cast(x) -#define CONST_CAST(type, x) const_cast(x) -#define SHPLIB_NULLPTR nullptr -#else -#define STATIC_CAST(type, x) ((type)(x)) -#define REINTERPRET_CAST(type, x) ((type)(x)) -#define CONST_CAST(type, x) ((type)(x)) -#define SHPLIB_NULLPTR NULL -#endif - -/************************************************************************/ -/* SfRealloc() */ -/* */ -/* A realloc cover function that will access a NULL pointer as */ -/* a valid input. */ -/************************************************************************/ - -static void *SfRealloc(void *pMem, int nNewSize) -{ - if (pMem == SHPLIB_NULLPTR) - return malloc(nNewSize); - else - return realloc(pMem, nNewSize); -} - /************************************************************************/ /* DBFWriteHeader() */ /* */ @@ -137,9 +87,9 @@ static void DBFWriteHeader(DBFHandle psDBF) psDBF->bNoHeader = FALSE; /* -------------------------------------------------------------------- */ - /* Initialize the file header information. */ + /* Initialize the file header information. */ /* -------------------------------------------------------------------- */ - abyHeader[0] = 0x03; /* memo field? - just copying */ + abyHeader[0] = 0x03; /* memo field? - just copying */ /* write out update date */ abyHeader[1] = STATIC_CAST(unsigned char, psDBF->nUpdateYearSince1900); @@ -158,7 +108,7 @@ static void DBFWriteHeader(DBFHandle psDBF) /* -------------------------------------------------------------------- */ /* Write the initial 32 byte file header, and all the field */ - /* descriptions. */ + /* descriptions. */ /* -------------------------------------------------------------------- */ psDBF->sHooks.FSeek(psDBF->fp, 0, 0); psDBF->sHooks.FWrite(abyHeader, XBASE_FILEHDR_SZ, 1, psDBF->fp); @@ -344,7 +294,6 @@ void SHPAPI_CALL DBFSetLastModifiedDate(DBFHandle psDBF, int nYYSince1900, /************************************************************************/ DBFHandle SHPAPI_CALL DBFOpen(const char *pszFilename, const char *pszAccess) - { SAHooks sHooks; @@ -376,7 +325,7 @@ static int DBFGetLenWithoutExtension(const char *pszBasename) /************************************************************************/ DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess, - SAHooks *psHooks) + const SAHooks *psHooks) { /* -------------------------------------------------------------------- */ /* We only allow the access strings "rb" and "r+". */ @@ -393,8 +342,8 @@ DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess, pszAccess = "rb+"; /* -------------------------------------------------------------------- */ - /* Compute the base (layer) name. If there is any extension */ - /* on the passed in filename we will strip it off. */ + /* Compute the base (layer) name. If there is any extension */ + /* on the passed in filename we will strip it off. */ /* -------------------------------------------------------------------- */ const int nLenWithoutExtension = DBFGetLenWithoutExtension(pszFilename); char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); @@ -402,19 +351,20 @@ DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess, memcpy(pszFullname + nLenWithoutExtension, ".dbf", 5); DBFHandle psDBF = STATIC_CAST(DBFHandle, calloc(1, sizeof(DBFInfo))); - psDBF->fp = psHooks->FOpen(pszFullname, pszAccess); + psDBF->fp = psHooks->FOpen(pszFullname, pszAccess, psHooks->pvUserData); memcpy(&(psDBF->sHooks), psHooks, sizeof(SAHooks)); if (psDBF->fp == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".DBF", 5); - psDBF->fp = psDBF->sHooks.FOpen(pszFullname, pszAccess); + psDBF->fp = + psDBF->sHooks.FOpen(pszFullname, pszAccess, psHooks->pvUserData); } memcpy(pszFullname + nLenWithoutExtension, ".cpg", 5); - SAFile pfCPG = psHooks->FOpen(pszFullname, "r"); + SAFile pfCPG = psHooks->FOpen(pszFullname, "r", psHooks->pvUserData); if (pfCPG == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".CPG", 5); - pfCPG = psHooks->FOpen(pszFullname, "r"); + pfCPG = psHooks->FOpen(pszFullname, "r", psHooks->pvUserData); } free(pszFullname); @@ -495,7 +445,7 @@ DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszFilename, const char *pszAccess, /* -------------------------------------------------------------------- */ /* Read in Field Definitions */ /* -------------------------------------------------------------------- */ - pabyBuf = STATIC_CAST(unsigned char *, SfRealloc(pabyBuf, nHeadLen)); + pabyBuf = STATIC_CAST(unsigned char *, realloc(pabyBuf, nHeadLen)); psDBF->pszHeader = REINTERPRET_CAST(char *, pabyBuf); psDBF->sHooks.FSeek(psDBF->fp, XBASE_FILEHDR_SZ, 0); @@ -583,8 +533,8 @@ void SHPAPI_CALL DBFClose(DBFHandle psDBF) CPL_IGNORE_RET_VAL_INT(DBFFlushRecord(psDBF)); /* -------------------------------------------------------------------- */ - /* Update last access date, and number of records if we have */ - /* write access. */ + /* Update last access date, and number of records if we have */ + /* write access. */ /* -------------------------------------------------------------------- */ if (psDBF->bUpdated) DBFUpdateHeader(psDBF); @@ -645,11 +595,12 @@ DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszFilename, /************************************************************************/ DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszFilename, - const char *pszCodePage, SAHooks *psHooks) + const char *pszCodePage, + const SAHooks *psHooks) { /* -------------------------------------------------------------------- */ - /* Compute the base (layer) name. If there is any extension */ - /* on the passed in filename we will strip it off. */ + /* Compute the base (layer) name. If there is any extension */ + /* on the passed in filename we will strip it off. */ /* -------------------------------------------------------------------- */ const int nLenWithoutExtension = DBFGetLenWithoutExtension(pszFilename); char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); @@ -659,17 +610,7 @@ DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszFilename, /* -------------------------------------------------------------------- */ /* Create the file. */ /* -------------------------------------------------------------------- */ - SAFile fp = psHooks->FOpen(pszFullname, "wb"); - if (fp == SHPLIB_NULLPTR) { - free(pszFullname); - return SHPLIB_NULLPTR; - } - - char chZero = '\0'; - psHooks->FWrite(&chZero, 1, 1, fp); - psHooks->FClose(fp); - - fp = psHooks->FOpen(pszFullname, "rb+"); + SAFile fp = psHooks->FOpen(pszFullname, "wb+", psHooks->pvUserData); if (fp == SHPLIB_NULLPTR) { free(pszFullname); return SHPLIB_NULLPTR; @@ -685,7 +626,8 @@ DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszFilename, // a valid one } if (ldid < 0) { - SAFile fpCPG = psHooks->FOpen(pszFullname, "w"); + SAFile fpCPG = + psHooks->FOpen(pszFullname, "w", psHooks->pvUserData); psHooks->FWrite( CONST_CAST(void *, STATIC_CAST(const void *, pszCodePage)), strlen(pszCodePage), 1, fpCPG); @@ -693,13 +635,13 @@ DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszFilename, } } if (pszCodePage == SHPLIB_NULLPTR || ldid >= 0) { - psHooks->Remove(pszFullname); + psHooks->Remove(pszFullname, psHooks->pvUserData); } free(pszFullname); /* -------------------------------------------------------------------- */ - /* Create the info structure. */ + /* Create the info structure. */ /* -------------------------------------------------------------------- */ DBFHandle psDBF = STATIC_CAST(DBFHandle, calloc(1, sizeof(DBFInfo))); @@ -829,23 +771,22 @@ int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle psDBF, const char *pszFieldName, const int nOldHeaderLength = psDBF->nHeaderLength; /* -------------------------------------------------------------------- */ - /* SfRealloc all the arrays larger to hold the additional field */ + /* realloc all the arrays larger to hold the additional field */ /* information. */ /* -------------------------------------------------------------------- */ psDBF->nFields++; psDBF->panFieldOffset = STATIC_CAST( - int *, SfRealloc(psDBF->panFieldOffset, sizeof(int) * psDBF->nFields)); + int *, realloc(psDBF->panFieldOffset, sizeof(int) * psDBF->nFields)); psDBF->panFieldSize = STATIC_CAST( - int *, SfRealloc(psDBF->panFieldSize, sizeof(int) * psDBF->nFields)); + int *, realloc(psDBF->panFieldSize, sizeof(int) * psDBF->nFields)); - psDBF->panFieldDecimals = - STATIC_CAST(int *, SfRealloc(psDBF->panFieldDecimals, - sizeof(int) * psDBF->nFields)); + psDBF->panFieldDecimals = STATIC_CAST( + int *, realloc(psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields)); psDBF->pachFieldType = STATIC_CAST( - char *, SfRealloc(psDBF->pachFieldType, sizeof(char) * psDBF->nFields)); + char *, realloc(psDBF->pachFieldType, sizeof(char) * psDBF->nFields)); /* -------------------------------------------------------------------- */ /* Assign the new field information fields. */ @@ -863,7 +804,7 @@ int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle psDBF, const char *pszFieldName, psDBF->bUpdated = FALSE; psDBF->pszHeader = STATIC_CAST( - char *, SfRealloc(psDBF->pszHeader, psDBF->nFields * XBASE_FLDHDR_SZ)); + char *, realloc(psDBF->pszHeader, psDBF->nFields * XBASE_FLDHDR_SZ)); char *pszFInfo = psDBF->pszHeader + XBASE_FLDHDR_SZ * (psDBF->nFields - 1); @@ -887,7 +828,7 @@ int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle psDBF, const char *pszFieldName, /* Make the current record buffer appropriately larger. */ /* -------------------------------------------------------------------- */ psDBF->pszCurrentRecord = STATIC_CAST( - char *, SfRealloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); + char *, realloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); /* we're done if dealing with new .dbf */ if (psDBF->bNoHeader) @@ -971,13 +912,13 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField, return SHPLIB_NULLPTR; /* -------------------------------------------------------------------- */ - /* Have we read the record? */ + /* Have we read the record? */ /* -------------------------------------------------------------------- */ if (!DBFLoadRecord(psDBF, hEntity)) return SHPLIB_NULLPTR; - unsigned char *pabyRec = - REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); + const unsigned char *pabyRec = + REINTERPRET_CAST(const unsigned char *, psDBF->pszCurrentRecord); /* -------------------------------------------------------------------- */ /* Ensure we have room to extract the target field. */ @@ -993,7 +934,7 @@ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField, } /* -------------------------------------------------------------------- */ - /* Extract the requested field. */ + /* Extract the requested field. */ /* -------------------------------------------------------------------- */ memcpy(psDBF->pszWorkField, REINTERPRET_CAST(const char *, pabyRec) + @@ -1085,7 +1026,6 @@ double SHPAPI_CALL DBFReadDoubleAttribute(DBFHandle psDBF, int iRecord, const char SHPAPI_CALL1(*) DBFReadStringAttribute(DBFHandle psDBF, int iRecord, int iField) - { return STATIC_CAST(const char *, DBFReadAttribute(psDBF, iRecord, iField, 'C')); @@ -1099,12 +1039,40 @@ const char SHPAPI_CALL1(*) const char SHPAPI_CALL1(*) DBFReadLogicalAttribute(DBFHandle psDBF, int iRecord, int iField) - { return STATIC_CAST(const char *, DBFReadAttribute(psDBF, iRecord, iField, 'L')); } +/************************************************************************/ +/* DBFReadDateAttribute() */ +/* */ +/* Read a date attribute. */ +/************************************************************************/ + +SHPDate SHPAPI_CALL DBFReadDateAttribute(DBFHandle psDBF, int iRecord, + int iField) +{ + const char *pdateValue = STATIC_CAST( + const char *, DBFReadAttribute(psDBF, iRecord, iField, 'D')); + + SHPDate date; + + if (pdateValue == SHPLIB_NULLPTR) { + date.year = 0; + date.month = 0; + date.day = 0; + } + else if (3 != sscanf(pdateValue, "%4d%2d%2d", &date.year, &date.month, + &date.day)) { + date.year = 0; + date.month = 0; + date.day = 0; + } + + return date; +} + /************************************************************************/ /* DBFIsValueNULL() */ /* */ @@ -1135,7 +1103,16 @@ static bool DBFIsValueNULL(char chType, const char *pszValue) case 'D': /* NULL date fields have value "00000000" */ - return strncmp(pszValue, "00000000", 8) == 0; + /* Some DBF files have fields filled with spaces */ + /* (trimmed by DBFReadStringAttribute) to indicate null */ + /* values for dates (#4265). */ + /* And others have ' 0': + * https://lists.osgeo.org/pipermail/gdal-dev/2023-November/058010.html + */ + /* And others just empty string: + * https://github.com/OSGeo/gdal/issues/10405 */ + return pszValue[0] == 0 || strncmp(pszValue, "00000000", 8) == 0 || + strcmp(pszValue, " ") == 0 || strcmp(pszValue, "0") == 0; case 'L': /* NULL boolean fields have value "?" */ @@ -1155,7 +1132,8 @@ static bool DBFIsValueNULL(char chType, const char *pszValue) /* Contributed by Jim Matthews. */ /************************************************************************/ -int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle psDBF, int iRecord, int iField) +int SHPAPI_CALL DBFIsAttributeNULL(const DBFHandle psDBF, int iRecord, + int iField) { const char *pszValue = DBFReadStringAttribute(psDBF, iRecord, iField); @@ -1171,8 +1149,7 @@ int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle psDBF, int iRecord, int iField) /* Return the number of fields in this table. */ /************************************************************************/ -int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF) - +int SHPAPI_CALL DBFGetFieldCount(const DBFHandle psDBF) { return (psDBF->nFields); } @@ -1183,8 +1160,7 @@ int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF) /* Return the number of records in this table. */ /************************************************************************/ -int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF) - +int SHPAPI_CALL DBFGetRecordCount(const DBFHandle psDBF) { return (psDBF->nRecords); } @@ -1197,10 +1173,9 @@ int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF) /* bytes long. */ /************************************************************************/ -DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, +DBFFieldType SHPAPI_CALL DBFGetFieldInfo(const DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals) - { if (iField < 0 || iField >= psDBF->nFields) return (FTInvalid); @@ -1230,10 +1205,9 @@ DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, else if (psDBF->pachFieldType[iField] == 'N' || psDBF->pachFieldType[iField] == 'F') { - if (psDBF->panFieldDecimals[iField] > 0) { - /* || psDBF->panFieldSize[iField] >= 10 ) */ /* GDAL bug #809 */ + if (psDBF->panFieldDecimals[iField] > 0 || + psDBF->panFieldSize[iField] >= 10) return (FTDouble); - } else return (FTInteger); } @@ -1244,15 +1218,15 @@ DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, /************************************************************************/ /* DBFWriteAttribute() */ -/* */ -/* Write an attribute record to the file. */ +/* */ +/* Write an attribute record to the file. */ /************************************************************************/ static bool DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, void *pValue) { /* -------------------------------------------------------------------- */ - /* Is this a valid record? */ + /* Is this a valid record? */ /* -------------------------------------------------------------------- */ if (hEntity < 0 || hEntity > psDBF->nRecords) return false; @@ -1333,9 +1307,13 @@ static bool DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, case 'L': if (psDBF->panFieldSize[iField] >= 1 && (*STATIC_CAST(char *, pValue) == 'F' || - *STATIC_CAST(char *, pValue) == 'T')) + *STATIC_CAST(char *, pValue) == 'T')) { *(pabyRec + psDBF->panFieldOffset[iField]) = *STATIC_CAST(char *, pValue); + } + else { + nRetResult = false; + } break; default: { @@ -1370,10 +1348,10 @@ static bool DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, /************************************************************************/ int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, - int iField, void *pValue) + int iField, const void *pValue) { /* -------------------------------------------------------------------- */ - /* Is this a valid record? */ + /* Is this a valid record? */ /* -------------------------------------------------------------------- */ if (hEntity < 0 || hEntity > psDBF->nRecords) return (FALSE); @@ -1402,24 +1380,29 @@ int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, if (!DBFLoadRecord(psDBF, hEntity)) return FALSE; - unsigned char *pabyRec = - REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); + if (iField >= 0) { + unsigned char *pabyRec = + REINTERPRET_CAST(unsigned char *, psDBF->pszCurrentRecord); - /* -------------------------------------------------------------------- */ - /* Assign all the record fields. */ - /* -------------------------------------------------------------------- */ - int j; - if (STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))) > - psDBF->panFieldSize[iField]) - j = psDBF->panFieldSize[iField]; - else { - memset(pabyRec + psDBF->panFieldOffset[iField], ' ', - psDBF->panFieldSize[iField]); - j = STATIC_CAST(int, strlen(STATIC_CAST(char *, pValue))); - } + /* -------------------------------------------------------------------- + */ + /* Assign all the record fields. */ + /* -------------------------------------------------------------------- + */ + int j; + if (STATIC_CAST(int, strlen(STATIC_CAST(const char *, pValue))) > + psDBF->panFieldSize[iField]) + j = psDBF->panFieldSize[iField]; + else { + memset(pabyRec + psDBF->panFieldOffset[iField], ' ', + psDBF->panFieldSize[iField]); + j = STATIC_CAST(int, strlen(STATIC_CAST(const char *, pValue))); + } - strncpy(REINTERPRET_CAST(char *, pabyRec + psDBF->panFieldOffset[iField]), + memcpy( + REINTERPRET_CAST(char *, pabyRec + psDBF->panFieldOffset[iField]), STATIC_CAST(const char *, pValue), j); + } psDBF->bCurrentRecordModified = TRUE; psDBF->bUpdated = TRUE; @@ -1443,7 +1426,7 @@ int SHPAPI_CALL DBFWriteDoubleAttribute(DBFHandle psDBF, int iRecord, /************************************************************************/ /* DBFWriteIntegerAttribute() */ /* */ -/* Write a integer attribute. */ +/* Write an integer attribute. */ /************************************************************************/ int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle psDBF, int iRecord, @@ -1463,7 +1446,6 @@ int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle psDBF, int iRecord, int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle psDBF, int iRecord, int iField, const char *pszValue) - { return ( DBFWriteAttribute(psDBF, iRecord, iField, @@ -1473,11 +1455,10 @@ int SHPAPI_CALL DBFWriteStringAttribute(DBFHandle psDBF, int iRecord, /************************************************************************/ /* DBFWriteNULLAttribute() */ /* */ -/* Write a string attribute. */ +/* Write a NULL attribute. */ /************************************************************************/ int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle psDBF, int iRecord, int iField) - { return (DBFWriteAttribute(psDBF, iRecord, iField, SHPLIB_NULLPTR)); } @@ -1490,23 +1471,47 @@ int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle psDBF, int iRecord, int iField) int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle psDBF, int iRecord, int iField, const char lValue) - { return ( DBFWriteAttribute(psDBF, iRecord, iField, STATIC_CAST(void *, CONST_CAST(char *, &lValue)))); } +/************************************************************************/ +/* DBFWriteDateAttribute() */ +/* */ +/* Write a date attribute. */ +/************************************************************************/ + +int SHPAPI_CALL DBFWriteDateAttribute(DBFHandle psDBF, int iRecord, int iField, + const SHPDate *lValue) +{ + if (SHPLIB_NULLPTR == lValue) + return false; + /* check for supported digit range, but do not check for valid date */ + if (lValue->year < 0 || lValue->year > 9999) + return false; + if (lValue->month < 0 || lValue->month > 99) + return false; + if (lValue->day < 0 || lValue->day > 99) + return false; + char dateValue[9]; /* "yyyyMMdd\0" */ + snprintf(dateValue, sizeof(dateValue), "%04d%02d%02d", lValue->year, + lValue->month, lValue->day); + return (DBFWriteAttributeDirectly(psDBF, iRecord, iField, dateValue)); +} + /************************************************************************/ /* DBFWriteTuple() */ -/* */ -/* Write an attribute record to the file. */ +/* */ +/* Write an attribute record to the file. */ /************************************************************************/ -int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void *pRawTuple) +int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, + const void *pRawTuple) { /* -------------------------------------------------------------------- */ - /* Is this a valid record? */ + /* Is this a valid record? */ /* -------------------------------------------------------------------- */ if (hEntity < 0 || hEntity > psDBF->nRecords) return (FALSE); @@ -1554,7 +1559,6 @@ int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void *pRawTuple) /************************************************************************/ const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity) - { if (hEntity < 0 || hEntity >= psDBF->nRecords) return SHPLIB_NULLPTR; @@ -1566,14 +1570,17 @@ const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity) } /************************************************************************/ -/* DBFCloneEmpty() */ +/* DBFCloneEmpty() */ /* */ -/* Read one of the attribute fields of a record. */ +/* Create a new .dbf file with same code page and field */ +/* definitions as the given handle. */ /************************************************************************/ -DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename) +DBFHandle SHPAPI_CALL DBFCloneEmpty(const DBFHandle psDBF, + const char *pszFilename) { - DBFHandle newDBF = DBFCreateEx(pszFilename, psDBF->pszCodePage); + DBFHandle newDBF = + DBFCreateLL(pszFilename, psDBF->pszCodePage, &psDBF->sHooks); if (newDBF == SHPLIB_NULLPTR) return SHPLIB_NULLPTR; @@ -1629,8 +1636,7 @@ DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename) /* 'M' (Memo: 10 digits .DBT block ptr) */ /************************************************************************/ -char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle psDBF, int iField) - +char SHPAPI_CALL DBFGetNativeFieldType(const DBFHandle psDBF, int iField) { if (iField >= 0 && iField < psDBF->nFields) return psDBF->pachFieldType[iField]; @@ -1646,7 +1652,8 @@ char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle psDBF, int iField) /* Contributed by Jim Matthews. */ /************************************************************************/ -int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName) +int SHPAPI_CALL DBFGetFieldIndex(const DBFHandle psDBF, + const char *pszFieldName) { char name[XBASE_FLDNAME_LEN_READ + 1]; @@ -1665,7 +1672,7 @@ int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName) /* it returns FALSE. */ /************************************************************************/ -int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape) +int SHPAPI_CALL DBFIsRecordDeleted(const DBFHandle psDBF, int iShape) { /* -------------------------------------------------------------------- */ /* Verify selection. */ @@ -1674,7 +1681,7 @@ int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape) return TRUE; /* -------------------------------------------------------------------- */ - /* Have we read the record? */ + /* Have we read the record? */ /* -------------------------------------------------------------------- */ if (!DBFLoadRecord(psDBF, iShape)) return FALSE; @@ -1727,7 +1734,7 @@ int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape, /* DBFGetCodePage */ /************************************************************************/ -const char SHPAPI_CALL1(*) DBFGetCodePage(DBFHandle psDBF) +const char SHPAPI_CALL1(*) DBFGetCodePage(const DBFHandle psDBF) { if (psDBF == SHPLIB_NULLPTR) return SHPLIB_NULLPTR; @@ -1768,17 +1775,16 @@ int SHPAPI_CALL DBFDeleteField(DBFHandle psDBF, int iField) psDBF->nFields--; psDBF->panFieldOffset = STATIC_CAST( - int *, SfRealloc(psDBF->panFieldOffset, sizeof(int) * psDBF->nFields)); + int *, realloc(psDBF->panFieldOffset, sizeof(int) * psDBF->nFields)); psDBF->panFieldSize = STATIC_CAST( - int *, SfRealloc(psDBF->panFieldSize, sizeof(int) * psDBF->nFields)); + int *, realloc(psDBF->panFieldSize, sizeof(int) * psDBF->nFields)); - psDBF->panFieldDecimals = - STATIC_CAST(int *, SfRealloc(psDBF->panFieldDecimals, - sizeof(int) * psDBF->nFields)); + psDBF->panFieldDecimals = STATIC_CAST( + int *, realloc(psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields)); psDBF->pachFieldType = STATIC_CAST( - char *, SfRealloc(psDBF->pachFieldType, sizeof(char) * psDBF->nFields)); + char *, realloc(psDBF->pachFieldType, sizeof(char) * psDBF->nFields)); /* update header information */ psDBF->nHeaderLength -= XBASE_FLDHDR_SZ; @@ -1790,11 +1796,11 @@ int SHPAPI_CALL DBFDeleteField(DBFHandle psDBF, int iField) sizeof(char) * (psDBF->nFields - iField) * XBASE_FLDHDR_SZ); psDBF->pszHeader = STATIC_CAST( - char *, SfRealloc(psDBF->pszHeader, psDBF->nFields * XBASE_FLDHDR_SZ)); + char *, realloc(psDBF->pszHeader, psDBF->nFields * XBASE_FLDHDR_SZ)); /* update size of current record appropriately */ psDBF->pszCurrentRecord = STATIC_CAST( - char *, SfRealloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); + char *, realloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); /* we're done if we're dealing with not yet created .dbf */ if (psDBF->bNoHeader && psDBF->nRecords == 0) @@ -1866,7 +1872,7 @@ int SHPAPI_CALL DBFDeleteField(DBFHandle psDBF, int iField) /* code of DBFReorderFields. */ /************************************************************************/ -int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, int *panMap) +int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, const int *panMap) { if (psDBF->nFields == 0) return TRUE; @@ -1878,13 +1884,13 @@ int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, int *panMap) /* a simple malloc() would be enough, but calloc() helps clang static * analyzer */ int *panFieldOffsetNew = - STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); + STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int))); int *panFieldSizeNew = - STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); + STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int))); int *panFieldDecimalsNew = - STATIC_CAST(int *, calloc(sizeof(int), psDBF->nFields)); + STATIC_CAST(int *, calloc(psDBF->nFields, sizeof(int))); char *pachFieldTypeNew = - STATIC_CAST(char *, calloc(sizeof(char), psDBF->nFields)); + STATIC_CAST(char *, calloc(psDBF->nFields, sizeof(char))); char *pszHeaderNew = STATIC_CAST( char *, malloc(sizeof(char) * XBASE_FLDHDR_SZ * psDBF->nFields)); @@ -2050,7 +2056,7 @@ int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField, psDBF->nRecordLength += nWidth - nOldWidth; psDBF->pszCurrentRecord = STATIC_CAST( - char *, SfRealloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); + char *, realloc(psDBF->pszCurrentRecord, psDBF->nRecordLength)); } /* we're done if we're dealing with not yet created .dbf */ @@ -2069,7 +2075,6 @@ int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField, char *pszOldField = STATIC_CAST(char *, malloc(sizeof(char) * (nOldWidth + 1))); - /* cppcheck-suppress uninitdata */ pszOldField[nOldWidth] = 0; /* move records to their new positions */ @@ -2139,7 +2144,6 @@ int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField, char *pszOldField = STATIC_CAST(char *, malloc(sizeof(char) * (nOldWidth + 1))); - /* cppcheck-suppress uninitdata */ pszOldField[nOldWidth] = 0; /* move records to their new positions */ diff --git a/lib/external/shapelib/safileio.c b/lib/external/shapelib/safileio.c index 3377642e4d4..e13f1f29acf 100644 --- a/lib/external/shapelib/safileio.c +++ b/lib/external/shapelib/safileio.c @@ -1,5 +1,4 @@ /****************************************************************************** - * $Id: safileio.c,v 1.6 2018-06-15 19:56:32 erouault Exp $ * * Project: Shapelib * Purpose: Default implementation of file io based on stdio. @@ -8,74 +7,19 @@ ****************************************************************************** * Copyright (c) 2007, Frank Warmerdam * - * This software is available under the following "MIT Style" license, - * or at the option of the licensee under the LGPL (see COPYING). This - * option is discussed in more detail in shapelib.html. - * - * -- - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later ****************************************************************************** * - * $Log: safileio.c,v $ - * Revision 1.6 2018-06-15 19:56:32 erouault - * * safileio.c: remove duplicate test. Patch by Jaroslav Fojtik. - * Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2744 - * - * Revision 1.5 2016-12-05 12:44:05 erouault - * * Major overhaul of Makefile build system to use autoconf/automake. - * - * * Warning fixes in contrib/ - * - * Revision 1.4 2008-01-16 20:05:14 bram - * Add file hooks that accept UTF-8 encoded filenames on some platforms. Use - *SASetupUtf8Hooks tosetup the hooks and check SHPAPI_UTF8_HOOKS for its - *availability. Currently, this is only available on the Windows platform that - *decodes the UTF-8 filenames to wide character strings and feeds them to - *_wfopen and _wremove. - * - * Revision 1.3 2007/12/18 18:28:11 bram - * - create hook for client specific atof (bugzilla ticket 1615) - * - check for NULL handle before closing cpCPG file, and close after reading. - * - * Revision 1.2 2007/12/15 20:25:30 bram - * dbfopen.c now reads the Code Page information from the DBF file, and exports - * this information as a string through the DBFGetCodePage function. This is - * either the number from the LDID header field ("LDID/") or as the - * content of an accompanying .CPG file. When creating a DBF file, the code can - * be set using DBFCreateEx. - * - * Revision 1.1 2007/12/06 06:56:41 fwarmerdam - * new - * */ #include "shapefil.h" +#include #include #include -#include +#include #include #include -#include - -SHP_CVSID("$Id: safileio.c,v 1.6 2018-06-15 19:56:32 erouault Exp $") #ifdef SHPAPI_UTF8_HOOKS #ifdef SHPAPI_WINDOWS @@ -86,102 +30,64 @@ SHP_CVSID("$Id: safileio.c,v 1.6 2018-06-15 19:56:32 erouault Exp $") #endif #endif -/************************************************************************/ -/* SADFOpen() */ -/************************************************************************/ - -SAFile SADFOpen(const char *pszFilename, const char *pszAccess) - +static SAFile SADFOpen(const char *pszFilename, const char *pszAccess, + void *pvUserData) { + (void)pvUserData; return (SAFile)fopen(pszFilename, pszAccess); } -/************************************************************************/ -/* SADFRead() */ -/************************************************************************/ - -SAOffset SADFRead(void *p, SAOffset size, SAOffset nmemb, SAFile file) - +static SAOffset SADFRead(void *p, SAOffset size, SAOffset nmemb, SAFile file) { return (SAOffset)fread(p, (size_t)size, (size_t)nmemb, (FILE *)file); } -/************************************************************************/ -/* SADFWrite() */ -/************************************************************************/ - -SAOffset SADFWrite(void *p, SAOffset size, SAOffset nmemb, SAFile file) - +static SAOffset SADFWrite(const void *p, SAOffset size, SAOffset nmemb, + SAFile file) { return (SAOffset)fwrite(p, (size_t)size, (size_t)nmemb, (FILE *)file); } -/************************************************************************/ -/* SADFSeek() */ -/************************************************************************/ - -SAOffset SADFSeek(SAFile file, SAOffset offset, int whence) - +static SAOffset SADFSeek(SAFile file, SAOffset offset, int whence) { +#if defined(_MSC_VER) && _MSC_VER >= 1400 + return (SAOffset)_fseeki64((FILE *)file, (__int64)offset, whence); +#else return (SAOffset)fseek((FILE *)file, (long)offset, whence); +#endif } -/************************************************************************/ -/* SADFTell() */ -/************************************************************************/ - -SAOffset SADFTell(SAFile file) - +static SAOffset SADFTell(SAFile file) { +#if defined(_MSC_VER) && _MSC_VER >= 1400 + return (SAOffset)_ftelli64((FILE *)file); +#else return (SAOffset)ftell((FILE *)file); +#endif } -/************************************************************************/ -/* SADFFlush() */ -/************************************************************************/ - -int SADFFlush(SAFile file) - +static int SADFFlush(SAFile file) { return fflush((FILE *)file); } -/************************************************************************/ -/* SADFClose() */ -/************************************************************************/ - -int SADFClose(SAFile file) - +static int SADFClose(SAFile file) { return fclose((FILE *)file); } -/************************************************************************/ -/* SADFClose() */ -/************************************************************************/ - -int SADRemove(const char *filename) - +static int SADRemove(const char *filename, void *pvUserData) { + (void)pvUserData; return remove(filename); } -/************************************************************************/ -/* SADError() */ -/************************************************************************/ - -void SADError(const char *message) - +static void SADError(const char *message) { fprintf(stderr, "%s\n", message); } -/************************************************************************/ -/* SASetupDefaultHooks() */ -/************************************************************************/ - void SASetupDefaultHooks(SAHooks *psHooks) - { psHooks->FOpen = SADFOpen; psHooks->FRead = SADFRead; @@ -194,25 +100,20 @@ void SASetupDefaultHooks(SAHooks *psHooks) psHooks->Error = SADError; psHooks->Atof = atof; + psHooks->pvUserData = NULL; } #ifdef SHPAPI_WINDOWS -/************************************************************************/ -/* Utf8ToWideChar */ -/************************************************************************/ - -const wchar_t *Utf8ToWideChar(const char *pszFilename) +static wchar_t *Utf8ToWideChar(const char *pszFilename) { - int nMulti, nWide; - wchar_t *pwszFileName; - - nMulti = strlen(pszFilename) + 1; - nWide = MultiByteToWideChar(CP_UTF8, 0, pszFilename, nMulti, 0, 0); + const int nMulti = (int)strlen(pszFilename) + 1; + const int nWide = + MultiByteToWideChar(CP_UTF8, 0, pszFilename, nMulti, 0, 0); if (nWide == 0) { return NULL; } - pwszFileName = (wchar_t *)malloc(nWide * sizeof(wchar_t)); + wchar_t *pwszFileName = (wchar_t *)malloc(nWide * sizeof(wchar_t)); if (pwszFileName == NULL) { return NULL; } @@ -228,51 +129,44 @@ const wchar_t *Utf8ToWideChar(const char *pszFilename) /* SAUtf8WFOpen */ /************************************************************************/ -SAFile SAUtf8WFOpen(const char *pszFilename, const char *pszAccess) +static SAFile SAUtf8WFOpen(const char *pszFilename, const char *pszAccess, + void *pvUserData) { + (void)pvUserData; SAFile file = NULL; - const wchar_t *pwszFileName, *pwszAccess; - pwszFileName = Utf8ToWideChar(pszFilename); - pwszAccess = Utf8ToWideChar(pszAccess); + wchar_t *pwszFileName = Utf8ToWideChar(pszFilename); + wchar_t *pwszAccess = Utf8ToWideChar(pszAccess); if (pwszFileName != NULL && pwszAccess != NULL) { file = (SAFile)_wfopen(pwszFileName, pwszAccess); } - free((wchar_t *)pwszFileName); - free((wchar_t *)pwszAccess); + free(pwszFileName); + free(pwszAccess); return file; } -/************************************************************************/ -/* SAUtf8WRemove() */ -/************************************************************************/ - -int SAUtf8WRemove(const char *pszFilename) +static int SAUtf8WRemove(const char *pszFilename, void *pvUserData) { - const wchar_t *pwszFileName = Utf8ToWideChar(pszFilename); + (void)pvUserData; + wchar_t *pwszFileName = Utf8ToWideChar(pszFilename); int rc = -1; if (pwszFileName != NULL) { rc = _wremove(pwszFileName); } - free((wchar_t *)pwszFileName); + free(pwszFileName); return rc; } #endif #ifdef SHPAPI_UTF8_HOOKS - -/************************************************************************/ -/* SASetupUtf8Hooks() */ -/************************************************************************/ +#ifndef SHPAPI_WINDOWS +#error "no implementations of UTF-8 hooks available for this platform" +#endif void SASetupUtf8Hooks(SAHooks *psHooks) { -#ifdef SHPAPI_WINDOWS psHooks->FOpen = SAUtf8WFOpen; psHooks->Remove = SAUtf8WRemove; -#else -#error "no implementations of UTF-8 hooks available for this platform" -#endif psHooks->FRead = SADFRead; psHooks->FWrite = SADFWrite; psHooks->FSeek = SADFSeek; @@ -283,5 +177,4 @@ void SASetupUtf8Hooks(SAHooks *psHooks) psHooks->Error = SADError; psHooks->Atof = atof; } - #endif diff --git a/lib/external/shapelib/shapefil.h b/lib/external/shapelib/shapefil.h index cd4ef54aa56..c11632fa6ba 100644 --- a/lib/external/shapelib/shapefil.h +++ b/lib/external/shapelib/shapefil.h @@ -2,7 +2,6 @@ #define SHAPEFILE_H_INCLUDED /****************************************************************************** - * $Id$ * * Project: Shapelib * Purpose: Primary include file for Shapelib. @@ -12,29 +11,7 @@ * Copyright (c) 1999, Frank Warmerdam * Copyright (c) 2012-2016, Even Rouault * - * This software is available under the following "MIT Style" license, - * or at the option of the licensee under the LGPL (see COPYING). This - * option is discussed in more detail in shapelib.html. - * - * -- - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later ****************************************************************************** * */ @@ -49,6 +26,26 @@ extern "C" { #endif +/************************************************************************/ +/* Version related macros (added in 1.6.0) */ +/************************************************************************/ + +#define SHAPELIB_VERSION_MAJOR 1 +#define SHAPELIB_VERSION_MINOR 6 +#define SHAPELIB_VERSION_MICRO 0 + +#define SHAPELIB_MAKE_VERSION_NUMBER(major, minor, micro) \ + ((major) * 10000 + (minor) * 100 + (micro)) + +#define SHAPELIB_VERSION_NUMBER \ + SHAPELIB_MAKE_VERSION_NUMBER(SHAPELIB_VERSION_MAJOR, \ + SHAPELIB_VERSION_MINOR, \ + SHAPELIB_VERSION_MICRO) + +#define SHAPELIB_AT_LEAST(major, minor, micro) \ + (SHAPELIB_VERSION_NUMBER >= \ + SHAPELIB_MAKE_VERSION_NUMBER(major, minor, micro)) + /************************************************************************/ /* Configuration options. */ /************************************************************************/ @@ -73,7 +70,7 @@ extern "C" { /* various calling conventions on the Shapelib API. */ /* */ /* To force __stdcall conventions (needed to call Shapelib */ -/* from Visual Basic and/or Dephi I believe) the makefile could */ +/* from Visual Basic and/or Delphi I believe) the makefile could */ /* be modified to define: */ /* */ /* /DSHPAPI_CALL=__stdcall */ @@ -113,31 +110,11 @@ extern "C" { #define SHPAPI_CALL1(x) x SHPAPI_CALL #endif -/* -------------------------------------------------------------------- */ -/* Macros for controlling CVSID and ensuring they don't appear */ -/* as unreferenced variables resulting in lots of warnings. */ -/* -------------------------------------------------------------------- */ -#ifndef DISABLE_CVSID -#if defined(__GNUC__) && __GNUC__ >= 4 -#define SHP_CVSID(string) \ - static const char cpl_cvsid[] __attribute__((used)) = string; -#else -#define SHP_CVSID(string) \ - static const char cpl_cvsid[] = string; \ - static const char *cvsid_aw() \ - { \ - return (cvsid_aw() ? NULL : cpl_cvsid); \ - } -#endif -#else -#define SHP_CVSID(string) -#endif - /* -------------------------------------------------------------------- */ /* On some platforms, additional file IO hooks are defined that */ /* UTF-8 encoded filenames Unicode filenames */ /* -------------------------------------------------------------------- */ -#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +#if defined(_WIN32) #define SHPAPI_WINDOWS #define SHPAPI_UTF8_HOOKS #endif @@ -148,21 +125,27 @@ extern "C" { typedef int *SAFile; #ifndef SAOffset +#if defined(_MSC_VER) && _MSC_VER >= 1400 +typedef unsigned __int64 SAOffset; +#else typedef unsigned long SAOffset; #endif +#endif typedef struct { - SAFile (*FOpen)(const char *filename, const char *access); + SAFile (*FOpen)(const char *filename, const char *access, void *pvUserData); SAOffset (*FRead)(void *p, SAOffset size, SAOffset nmemb, SAFile file); - SAOffset (*FWrite)(void *p, SAOffset size, SAOffset nmemb, SAFile file); + SAOffset (*FWrite)(const void *p, SAOffset size, SAOffset nmemb, + SAFile file); SAOffset (*FSeek)(SAFile file, SAOffset offset, int whence); SAOffset (*FTell)(SAFile file); int (*FFlush)(SAFile file); int (*FClose)(SAFile file); - int (*Remove)(const char *filename); + int (*Remove)(const char *filename, void *pvUserData); void (*Error)(const char *message); double (*Atof)(const char *str); + void *pvUserData; } SAHooks; void SHPAPI_CALL SASetupDefaultHooks(SAHooks *psHooks); @@ -206,6 +189,12 @@ typedef struct { typedef SHPInfo *SHPHandle; +typedef struct { + int year; + int month; + int day; +} SHPDate; + /* -------------------------------------------------------------------- */ /* Shape types (nSHPType) */ /* -------------------------------------------------------------------- */ @@ -277,13 +266,13 @@ struct tagSHPObject { /* will be NULL as it is not necessary to keep the SHX file open */ SHPHandle SHPAPI_CALL SHPOpen(const char *pszShapeFile, const char *pszAccess); SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszShapeFile, const char *pszAccess, - SAHooks *psHooks); + const SAHooks *psHooks); SHPHandle SHPAPI_CALL SHPOpenLLEx(const char *pszShapeFile, - const char *pszAccess, SAHooks *psHooks, + const char *pszAccess, const SAHooks *psHooks, int bRestoreSHX); int SHPAPI_CALL SHPRestoreSHX(const char *pszShapeFile, const char *pszAccess, - SAHooks *psHooks); + const SAHooks *psHooks); /* If setting bFastMode = TRUE, the content of SHPReadObject() is owned by the * SHPHandle. */ @@ -296,12 +285,14 @@ void SHPAPI_CALL SHPSetFastModeReadObject(SHPHandle hSHP, int bFastMode); SHPHandle SHPAPI_CALL SHPCreate(const char *pszShapeFile, int nShapeType); SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszShapeFile, int nShapeType, - SAHooks *psHooks); -void SHPAPI_CALL SHPGetInfo(SHPHandle hSHP, int *pnEntities, int *pnShapeType, - double *padfMinBound, double *padfMaxBound); + const SAHooks *psHooks); +void SHPAPI_CALL SHPGetInfo(const SHPHandle hSHP, int *pnEntities, + int *pnShapeType, double *padfMinBound, + double *padfMaxBound); -SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle hSHP, int iShape); -int SHPAPI_CALL SHPWriteObject(SHPHandle hSHP, int iShape, SHPObject *psObject); +SHPObject SHPAPI_CALL1(*) SHPReadObject(const SHPHandle hSHP, int iShape); +int SHPAPI_CALL SHPWriteObject(SHPHandle hSHP, int iShape, + const SHPObject *psObject); void SHPAPI_CALL SHPDestroyObject(SHPObject *psObject); void SHPAPI_CALL SHPComputeExtents(SHPObject *psObject); @@ -314,7 +305,7 @@ SHPObject SHPAPI_CALL1(*) SHPCreateSimpleObject(int nSHPType, int nVertices, const double *padfX, const double *padfY, const double *padfZ); -int SHPAPI_CALL SHPRewindObject(SHPHandle hSHP, SHPObject *psObject); +int SHPAPI_CALL SHPRewindObject(const SHPHandle hSHP, SHPObject *psObject); void SHPAPI_CALL SHPClose(SHPHandle hSHP); void SHPAPI_CALL SHPWriteHeader(SHPHandle hSHP); @@ -360,21 +351,20 @@ typedef struct { SHPTree SHPAPI_CALL1(*) SHPCreateTree(SHPHandle hSHP, int nDimension, int nMaxDepth, - double *padfBoundsMin, double *padfBoundsMax); + const double *padfBoundsMin, const double *padfBoundsMax); void SHPAPI_CALL SHPDestroyTree(SHPTree *hTree); int SHPAPI_CALL SHPWriteTree(SHPTree *hTree, const char *pszFilename); int SHPAPI_CALL SHPTreeAddShapeId(SHPTree *hTree, SHPObject *psObject); -int SHPAPI_CALL SHPTreeRemoveShapeId(SHPTree *hTree, int nShapeId); void SHPAPI_CALL SHPTreeTrimExtraNodes(SHPTree *hTree); int SHPAPI_CALL1(*) - SHPTreeFindLikelyShapes(SHPTree *hTree, double *padfBoundsMin, + SHPTreeFindLikelyShapes(const SHPTree *hTree, double *padfBoundsMin, double *padfBoundsMax, int *); -int SHPAPI_CALL SHPCheckBoundsOverlap(double *, double *, double *, double *, - int); +int SHPAPI_CALL SHPCheckBoundsOverlap(const double *, const double *, + const double *, const double *, int); int SHPAPI_CALL1(*) SHPSearchDiskTree(FILE *fp, double *padfBoundsMin, double *padfBoundsMax, int *pnShapeCount); @@ -382,16 +372,17 @@ int SHPAPI_CALL1(*) SHPSearchDiskTree(FILE *fp, double *padfBoundsMin, typedef struct SHPDiskTreeInfo *SHPTreeDiskHandle; SHPTreeDiskHandle SHPAPI_CALL SHPOpenDiskTree(const char *pszQIXFilename, - SAHooks *psHooks); + const SAHooks *psHooks); void SHPAPI_CALL SHPCloseDiskTree(SHPTreeDiskHandle hDiskTree); int SHPAPI_CALL1(*) - SHPSearchDiskTreeEx(SHPTreeDiskHandle hDiskTree, double *padfBoundsMin, - double *padfBoundsMax, int *pnShapeCount); + SHPSearchDiskTreeEx(const SHPTreeDiskHandle hDiskTree, + double *padfBoundsMin, double *padfBoundsMax, + int *pnShapeCount); int SHPAPI_CALL SHPWriteTreeLL(SHPTree *hTree, const char *pszFilename, - SAHooks *psHooks); + const SAHooks *psHooks); /* -------------------------------------------------------------------- */ /* SBN Search API */ @@ -400,16 +391,16 @@ int SHPAPI_CALL SHPWriteTreeLL(SHPTree *hTree, const char *pszFilename, typedef struct SBNSearchInfo *SBNSearchHandle; SBNSearchHandle SHPAPI_CALL SBNOpenDiskTree(const char *pszSBNFilename, - SAHooks *psHooks); + const SAHooks *psHooks); void SHPAPI_CALL SBNCloseDiskTree(SBNSearchHandle hSBN); int SHPAPI_CALL1(*) - SBNSearchDiskTree(SBNSearchHandle hSBN, double *padfBoundsMin, - double *padfBoundsMax, int *pnShapeCount); + SBNSearchDiskTree(const SBNSearchHandle hSBN, const double *padfBoundsMin, + const double *padfBoundsMax, int *pnShapeCount); int SHPAPI_CALL1(*) - SBNSearchDiskTreeInteger(SBNSearchHandle hSBN, int bMinX, int bMinY, + SBNSearchDiskTreeInteger(const SBNSearchHandle hSBN, int bMinX, int bMinY, int bMaxX, int bMaxY, int *pnShapeCount); void SHPAPI_CALL SBNSearchFreeIds(int *panShapeId); @@ -485,15 +476,16 @@ typedef enum { DBFHandle SHPAPI_CALL DBFOpen(const char *pszDBFFile, const char *pszAccess); DBFHandle SHPAPI_CALL DBFOpenLL(const char *pszDBFFile, const char *pszAccess, - SAHooks *psHooks); + const SAHooks *psHooks); DBFHandle SHPAPI_CALL DBFCreate(const char *pszDBFFile); DBFHandle SHPAPI_CALL DBFCreateEx(const char *pszDBFFile, const char *pszCodePage); DBFHandle SHPAPI_CALL DBFCreateLL(const char *pszDBFFile, - const char *pszCodePage, SAHooks *psHooks); + const char *pszCodePage, + const SAHooks *psHooks); -int SHPAPI_CALL DBFGetFieldCount(DBFHandle psDBF); -int SHPAPI_CALL DBFGetRecordCount(DBFHandle psDBF); +int SHPAPI_CALL DBFGetFieldCount(const DBFHandle psDBF); +int SHPAPI_CALL DBFGetRecordCount(const DBFHandle psDBF); int SHPAPI_CALL DBFAddField(DBFHandle hDBF, const char *pszFieldName, DBFFieldType eType, int nWidth, int nDecimals); @@ -502,17 +494,18 @@ int SHPAPI_CALL DBFAddNativeFieldType(DBFHandle hDBF, const char *pszFieldName, int SHPAPI_CALL DBFDeleteField(DBFHandle hDBF, int iField); -int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, int *panMap); +int SHPAPI_CALL DBFReorderFields(DBFHandle psDBF, const int *panMap); int SHPAPI_CALL DBFAlterFieldDefn(DBFHandle psDBF, int iField, const char *pszFieldName, char chType, int nWidth, int nDecimals); -DBFFieldType SHPAPI_CALL DBFGetFieldInfo(DBFHandle psDBF, int iField, +DBFFieldType SHPAPI_CALL DBFGetFieldInfo(const DBFHandle psDBF, int iField, char *pszFieldName, int *pnWidth, int *pnDecimals); -int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName); +int SHPAPI_CALL DBFGetFieldIndex(const DBFHandle psDBF, + const char *pszFieldName); int SHPAPI_CALL DBFReadIntegerAttribute(DBFHandle hDBF, int iShape, int iField); double SHPAPI_CALL DBFReadDoubleAttribute(DBFHandle hDBF, int iShape, @@ -521,7 +514,10 @@ const char SHPAPI_CALL1(*) DBFReadStringAttribute(DBFHandle hDBF, int iShape, int iField); const char SHPAPI_CALL1(*) DBFReadLogicalAttribute(DBFHandle hDBF, int iShape, int iField); -int SHPAPI_CALL DBFIsAttributeNULL(DBFHandle hDBF, int iShape, int iField); +SHPDate SHPAPI_CALL DBFReadDateAttribute(DBFHandle hDBF, int iShape, + int iField); +int SHPAPI_CALL DBFIsAttributeNULL(const DBFHandle hDBF, int iShape, + int iField); int SHPAPI_CALL DBFWriteIntegerAttribute(DBFHandle hDBF, int iShape, int iField, int nFieldValue); @@ -533,22 +529,26 @@ int SHPAPI_CALL DBFWriteNULLAttribute(DBFHandle hDBF, int iShape, int iField); int SHPAPI_CALL DBFWriteLogicalAttribute(DBFHandle hDBF, int iShape, int iField, const char lFieldValue); +int SHPAPI_CALL DBFWriteDateAttribute(DBFHandle hDBF, int iShape, int iField, + const SHPDate *dateFieldValue); int SHPAPI_CALL DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, - int iField, void *pValue); + int iField, const void *pValue); const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity); -int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void *pRawTuple); +int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, + const void *pRawTuple); -int SHPAPI_CALL DBFIsRecordDeleted(DBFHandle psDBF, int iShape); +int SHPAPI_CALL DBFIsRecordDeleted(const DBFHandle psDBF, int iShape); int SHPAPI_CALL DBFMarkRecordDeleted(DBFHandle psDBF, int iShape, int bIsDeleted); -DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char *pszFilename); +DBFHandle SHPAPI_CALL DBFCloneEmpty(const DBFHandle psDBF, + const char *pszFilename); void SHPAPI_CALL DBFClose(DBFHandle hDBF); void SHPAPI_CALL DBFUpdateHeader(DBFHandle hDBF); -char SHPAPI_CALL DBFGetNativeFieldType(DBFHandle hDBF, int iField); +char SHPAPI_CALL DBFGetNativeFieldType(const DBFHandle hDBF, int iField); -const char SHPAPI_CALL1(*) DBFGetCodePage(DBFHandle psDBF); +const char SHPAPI_CALL1(*) DBFGetCodePage(const DBFHandle psDBF); void SHPAPI_CALL DBFSetLastModifiedDate(DBFHandle psDBF, int nYYSince1900, int nMM, int nDD); diff --git a/lib/external/shapelib/shapefil_private.h b/lib/external/shapelib/shapefil_private.h new file mode 100644 index 00000000000..1bed49e7cce --- /dev/null +++ b/lib/external/shapelib/shapefil_private.h @@ -0,0 +1,115 @@ +#ifndef SHAPEFILE_PRIVATE_H_INCLUDED +#define SHAPEFILE_PRIVATE_H_INCLUDED + +/****************************************************************************** + * + * Project: Shapelib + * Purpose: Private include file for Shapelib. + * Author: Frank Warmerdam, warmerdam@pobox.com + * + ****************************************************************************** + * Copyright (c) 1999, Frank Warmerdam + * Copyright (c) 2012-2016, Even Rouault + * + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later + ****************************************************************************** + * + */ + +#ifdef __cplusplus +#define STATIC_CAST(type, x) static_cast(x) +#define REINTERPRET_CAST(type, x) reinterpret_cast(x) +#define CONST_CAST(type, x) const_cast(x) +#define SHPLIB_NULLPTR nullptr +#else +#define STATIC_CAST(type, x) ((type)(x)) +#define REINTERPRET_CAST(type, x) ((type)(x)) +#define CONST_CAST(type, x) ((type)(x)) +#define SHPLIB_NULLPTR NULL +#endif + +#if !defined(SHP_BIG_ENDIAN) +#if defined(CPL_MSB) +#define SHP_BIG_ENDIAN 1 +#elif (defined(__GNUC__) && __GNUC__ >= 5) || \ + (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 4 && \ + __GNUC_MINOR__ >= 6) +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define SHP_BIG_ENDIAN 1 +#endif +#elif defined(__GLIBC__) +#if __BYTE_ORDER == __BIG_ENDIAN +#define SHP_BIG_ENDIAN 1 +#endif +#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +#define SHP_BIG_ENDIAN 1 +#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) +#elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || \ + defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || \ + defined(_MIPSEB) || defined(_POWER) || defined(__s390__) +#define SHP_BIG_ENDIAN 1 +#endif +#endif + +#include "shapefil.h" +#include +#include + +/************************************************************************/ +/* Little endian <==> big endian byte swap macros. */ +/************************************************************************/ + +#if (defined(__GNUC__) && __GNUC__ >= 5) || \ + (defined(__GNUC__) && defined(__GNUC_MINOR__) && __GNUC__ == 4 && \ + __GNUC_MINOR__ >= 8) +#define _SHP_SWAP32(x) \ + STATIC_CAST(uint32_t, __builtin_bswap32(STATIC_CAST(uint32_t, x))) +#define _SHP_SWAP64(x) \ + STATIC_CAST(uint64_t, __builtin_bswap64(STATIC_CAST(uint64_t, x))) +#elif defined(_MSC_VER) +#define _SHP_SWAP32(x) \ + STATIC_CAST(uint32_t, _byteswap_ulong(STATIC_CAST(uint32_t, x))) +#define _SHP_SWAP64(x) \ + STATIC_CAST(uint64_t, _byteswap_uint64(STATIC_CAST(uint64_t, x))) +#else +#define _SHP_SWAP32(x) \ + STATIC_CAST(uint32_t, \ + ((STATIC_CAST(uint32_t, x) & 0x000000ffU) << 24) | \ + ((STATIC_CAST(uint32_t, x) & 0x0000ff00U) << 8) | \ + ((STATIC_CAST(uint32_t, x) & 0x00ff0000U) >> 8) | \ + ((STATIC_CAST(uint32_t, x) & 0xff000000U) >> 24)) +#define _SHP_SWAP64(x) \ + ((STATIC_CAST(uint64_t, _SHP_SWAP32(STATIC_CAST(uint32_t, x))) << 32) | \ + (STATIC_CAST(uint64_t, _SHP_SWAP32(STATIC_CAST( \ + uint32_t, STATIC_CAST(uint64_t, x) >> 32))))) + +#endif + +/* in-place uint32_t* swap */ +#define SHP_SWAP32(p) \ + *REINTERPRET_CAST(uint32_t *, p) = \ + _SHP_SWAP32(*REINTERPRET_CAST(uint32_t *, p)) +/* in-place uint64_t* swap */ +#define SHP_SWAP64(p) \ + *REINTERPRET_CAST(uint64_t *, p) = \ + _SHP_SWAP64(*REINTERPRET_CAST(uint64_t *, p)) +/* in-place double* swap */ +#define SHP_SWAPDOUBLE(x) \ + do { \ + uint64_t _n64; \ + void *_lx = x; \ + memcpy(&_n64, _lx, 8); \ + _n64 = _SHP_SWAP64(_n64); \ + memcpy(_lx, &_n64, 8); \ + } while (0) +/* copy double* swap*/ +#define SHP_SWAPDOUBLE_CPY(dst, src) \ + do { \ + uint64_t _n64; \ + const void *_ls = src; \ + void *_ld = dst; \ + memcpy(&_n64, _ls, 8); \ + _n64 = _SHP_SWAP64(_n64); \ + memcpy(_ld, &_n64, 8); \ + } while (0) +#endif /* ndef SHAPEFILE_PRIVATE_H_INCLUDED */ diff --git a/lib/external/shapelib/shpopen.c b/lib/external/shapelib/shpopen.c index e63cf768d25..b2eeb3614fb 100644 --- a/lib/external/shapelib/shpopen.c +++ b/lib/external/shapelib/shpopen.c @@ -8,52 +8,21 @@ * Copyright (c) 1999, 2001, Frank Warmerdam * Copyright (c) 2011-2019, Even Rouault * - * This software is available under the following "MIT Style" license, - * or at the option of the licensee under the LGPL (see COPYING). This - * option is discussed in more detail in shapelib.html. - * - * -- - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. + * SPDX-License-Identifier: MIT OR LGPL-2.0-or-later ******************************************************************************/ -#include "shapefil.h" +#include "shapefil_private.h" #include #include #include #include #include +#include #include #include #include -SHP_CVSID("$Id$") - -typedef unsigned char uchar; - -#if UINT_MAX == 65535 -typedef unsigned long int32; -#else -typedef unsigned int int32; -#endif - #ifndef FALSE #define FALSE 0 #define TRUE 1 @@ -70,73 +39,18 @@ typedef unsigned int int32; #if _MSC_VER < 1900 #define snprintf _snprintf #endif -#elif defined(WIN32) || defined(_WIN32) +#elif defined(_WIN32) #ifndef snprintf #define snprintf _snprintf #endif #endif #endif -#ifndef CPL_UNUSED -#if defined(__GNUC__) && __GNUC__ >= 4 -#define CPL_UNUSED __attribute((__unused__)) -#else -#define CPL_UNUSED -#endif -#endif - -#if defined(CPL_LSB) -#define bBigEndian false -#elif defined(CPL_MSB) -#define bBigEndian true -#else -static bool bBigEndian; -#endif - -#ifdef __cplusplus -#define STATIC_CAST(type, x) static_cast(x) -#define SHPLIB_NULLPTR nullptr -#else -#define STATIC_CAST(type, x) ((type)(x)) -#define SHPLIB_NULLPTR NULL -#endif - -/************************************************************************/ -/* SwapWord() */ -/* */ -/* Swap a 2, 4 or 8 byte word. */ -/************************************************************************/ - -static void SwapWord(int length, void *wordP) -{ - for (int i = 0; i < length / 2; i++) { - const uchar temp = STATIC_CAST(uchar *, wordP)[i]; - STATIC_CAST(uchar *, wordP) - [i] = STATIC_CAST(uchar *, wordP)[length - i - 1]; - STATIC_CAST(uchar *, wordP)[length - i - 1] = temp; - } -} - -/************************************************************************/ -/* SfRealloc() */ -/* */ -/* A realloc cover function that will access a NULL pointer as */ -/* a valid input. */ -/************************************************************************/ - -static void *SfRealloc(void *pMem, int nNewSize) -{ - if (pMem == SHPLIB_NULLPTR) - return malloc(nNewSize); - else - return realloc(pMem, nNewSize); -} - /************************************************************************/ /* SHPWriteHeader() */ /* */ -/* Write out a header for the .shp and .shx files as well as the */ -/* contents of the index (.shx) file. */ +/* Write out a header for the .shp and .shx files as well as the */ +/* contents of the index (.shx) file. */ /************************************************************************/ void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP) @@ -150,64 +64,73 @@ void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP) /* Prepare header block for .shp file. */ /* -------------------------------------------------------------------- */ - uchar abyHeader[100] = {0}; + unsigned char abyHeader[100] = {0}; abyHeader[2] = 0x27; /* magic cookie */ abyHeader[3] = 0x0a; - int32 i32 = psSHP->nFileSize / 2; /* file size */ + uint32_t i32 = psSHP->nFileSize / 2; /* file size */ ByteCopy(&i32, abyHeader + 24, 4); - if (!bBigEndian) - SwapWord(4, abyHeader + 24); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(abyHeader + 24); +#endif i32 = 1000; /* version */ ByteCopy(&i32, abyHeader + 28, 4); - if (bBigEndian) - SwapWord(4, abyHeader + 28); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(abyHeader + 28); +#endif i32 = psSHP->nShapeType; /* shape type */ ByteCopy(&i32, abyHeader + 32, 4); - if (bBigEndian) - SwapWord(4, abyHeader + 32); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(abyHeader + 32); +#endif double dValue = psSHP->adBoundsMin[0]; /* set bounds */ ByteCopy(&dValue, abyHeader + 36, 8); - if (bBigEndian) - SwapWord(8, abyHeader + 36); - +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(abyHeader + 36); +#endif dValue = psSHP->adBoundsMin[1]; ByteCopy(&dValue, abyHeader + 44, 8); - if (bBigEndian) - SwapWord(8, abyHeader + 44); - +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(abyHeader + 44); +#endif dValue = psSHP->adBoundsMax[0]; ByteCopy(&dValue, abyHeader + 52, 8); - if (bBigEndian) - SwapWord(8, abyHeader + 52); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(abyHeader + 52); +#endif dValue = psSHP->adBoundsMax[1]; ByteCopy(&dValue, abyHeader + 60, 8); - if (bBigEndian) - SwapWord(8, abyHeader + 60); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(abyHeader + 60); +#endif dValue = psSHP->adBoundsMin[2]; /* z */ ByteCopy(&dValue, abyHeader + 68, 8); - if (bBigEndian) - SwapWord(8, abyHeader + 68); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(abyHeader + 68); +#endif dValue = psSHP->adBoundsMax[2]; ByteCopy(&dValue, abyHeader + 76, 8); - if (bBigEndian) - SwapWord(8, abyHeader + 76); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(abyHeader + 76); +#endif dValue = psSHP->adBoundsMin[3]; /* m */ ByteCopy(&dValue, abyHeader + 84, 8); - if (bBigEndian) - SwapWord(8, abyHeader + 84); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(abyHeader + 84); +#endif dValue = psSHP->adBoundsMax[3]; ByteCopy(&dValue, abyHeader + 92, 8); - if (bBigEndian) - SwapWord(8, abyHeader + 92); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(abyHeader + 92); +#endif /* -------------------------------------------------------------------- */ /* Write .shp file header. */ @@ -226,10 +149,11 @@ void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP) /* -------------------------------------------------------------------- */ /* Prepare, and write .shx file header. */ /* -------------------------------------------------------------------- */ - i32 = (psSHP->nRecords * 2 * sizeof(int32) + 100) / 2; /* file size */ + i32 = (psSHP->nRecords * 2 * sizeof(uint32_t) + 100) / 2; /* file size */ ByteCopy(&i32, abyHeader + 24, 4); - if (!bBigEndian) - SwapWord(4, abyHeader + 24); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(abyHeader + 24); +#endif if (psSHP->sHooks.FSeek(psSHP->fpSHX, 0, 0) != 0 || psSHP->sHooks.FWrite(abyHeader, 100, 1, psSHP->fpSHX) != 1) { @@ -246,8 +170,8 @@ void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP) /* -------------------------------------------------------------------- */ /* Write out the .shx contents. */ /* -------------------------------------------------------------------- */ - int32 *panSHX = - STATIC_CAST(int32 *, malloc(sizeof(int32) * 2 * psSHP->nRecords)); + uint32_t *panSHX = + STATIC_CAST(uint32_t *, malloc(sizeof(uint32_t) * 2 * psSHP->nRecords)); if (panSHX == SHPLIB_NULLPTR) { psSHP->sHooks.Error("Failure allocatin panSHX"); return; @@ -256,13 +180,13 @@ void SHPAPI_CALL SHPWriteHeader(SHPHandle psSHP) for (int i = 0; i < psSHP->nRecords; i++) { panSHX[i * 2] = psSHP->panRecOffset[i] / 2; panSHX[i * 2 + 1] = psSHP->panRecSize[i] / 2; - if (!bBigEndian) - SwapWord(4, panSHX + i * 2); - if (!bBigEndian) - SwapWord(4, panSHX + i * 2 + 1); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(panSHX + i * 2); + SHP_SWAP32(panSHX + i * 2 + 1); +#endif } - if (STATIC_CAST(int, psSHP->sHooks.FWrite(panSHX, sizeof(int32) * 2, + if (STATIC_CAST(int, psSHP->sHooks.FWrite(panSHX, sizeof(uint32_t) * 2, psSHP->nRecords, psSHP->fpSHX)) != psSHP->nRecords) { char szErrorMsg[200]; @@ -319,7 +243,7 @@ static int SHPGetLenWithoutExtension(const char *pszBasename) /************************************************************************/ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, - SAHooks *psHooks) + const SAHooks *psHooks) { /* -------------------------------------------------------------------- */ /* Ensure the access string is one of the legal ones. We */ @@ -336,23 +260,10 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, pszAccess = "rb"; } -/* -------------------------------------------------------------------- */ -/* Establish the byte order on this machine. */ -/* -------------------------------------------------------------------- */ -#if !defined(bBigEndian) - { - int i = 1; - if (*((uchar *)&i) == 1) - bBigEndian = false; - else - bBigEndian = true; - } -#endif - /* -------------------------------------------------------------------- */ /* Initialize the info structure. */ /* -------------------------------------------------------------------- */ - SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(sizeof(SHPInfo), 1)); + SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(1, sizeof(SHPInfo))); psSHP->bUpdated = FALSE; memcpy(&(psSHP->sHooks), psHooks, sizeof(SAHooks)); @@ -365,18 +276,21 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); memcpy(pszFullname, pszLayer, nLenWithoutExtension); memcpy(pszFullname + nLenWithoutExtension, ".shp", 5); - psSHP->fpSHP = psSHP->sHooks.FOpen(pszFullname, pszAccess); + psSHP->fpSHP = + psSHP->sHooks.FOpen(pszFullname, pszAccess, psSHP->sHooks.pvUserData); if (psSHP->fpSHP == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".SHP", 5); - psSHP->fpSHP = psSHP->sHooks.FOpen(pszFullname, pszAccess); + psSHP->fpSHP = psSHP->sHooks.FOpen(pszFullname, pszAccess, + psSHP->sHooks.pvUserData); } if (psSHP->fpSHP == SHPLIB_NULLPTR) { const size_t nMessageLen = strlen(pszFullname) * 2 + 256; char *pszMessage = STATIC_CAST(char *, malloc(nMessageLen)); pszFullname[nLenWithoutExtension] = 0; - snprintf(pszMessage, nMessageLen, "Unable to open %s.shp or %s.SHP.", - pszFullname, pszFullname); + snprintf(pszMessage, nMessageLen, + "Unable to open %s.shp or %s.SHP in %s mode.", pszFullname, + pszFullname, pszAccess); psHooks->Error(pszMessage); free(pszMessage); @@ -387,10 +301,12 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, } memcpy(pszFullname + nLenWithoutExtension, ".shx", 5); - psSHP->fpSHX = psSHP->sHooks.FOpen(pszFullname, pszAccess); + psSHP->fpSHX = + psSHP->sHooks.FOpen(pszFullname, pszAccess, psSHP->sHooks.pvUserData); if (psSHP->fpSHX == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".SHX", 5); - psSHP->fpSHX = psSHP->sHooks.FOpen(pszFullname, pszAccess); + psSHP->fpSHX = psSHP->sHooks.FOpen(pszFullname, pszAccess, + psSHP->sHooks.pvUserData); } if (psSHP->fpSHX == SHPLIB_NULLPTR) { @@ -416,7 +332,7 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, /* -------------------------------------------------------------------- */ /* Read the file size from the SHP file. */ /* -------------------------------------------------------------------- */ - uchar *pabyBuf = STATIC_CAST(uchar *, malloc(100)); + unsigned char *pabyBuf = STATIC_CAST(unsigned char *, malloc(100)); if (psSHP->sHooks.FRead(pabyBuf, 100, 1, psSHP->fpSHP) != 1) { psSHP->sHooks.Error(".shp file is unreadable, or corrupt."); psSHP->sHooks.FClose(psSHP->fpSHP); @@ -489,43 +405,51 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, /* -------------------------------------------------------------------- */ double dValue; - if (bBigEndian) - SwapWord(8, pabyBuf + 36); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyBuf + 36); +#endif memcpy(&dValue, pabyBuf + 36, 8); psSHP->adBoundsMin[0] = dValue; - if (bBigEndian) - SwapWord(8, pabyBuf + 44); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyBuf + 44); +#endif memcpy(&dValue, pabyBuf + 44, 8); psSHP->adBoundsMin[1] = dValue; - if (bBigEndian) - SwapWord(8, pabyBuf + 52); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyBuf + 52); +#endif memcpy(&dValue, pabyBuf + 52, 8); psSHP->adBoundsMax[0] = dValue; - if (bBigEndian) - SwapWord(8, pabyBuf + 60); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyBuf + 60); +#endif memcpy(&dValue, pabyBuf + 60, 8); psSHP->adBoundsMax[1] = dValue; - if (bBigEndian) - SwapWord(8, pabyBuf + 68); /* z */ +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyBuf + 68); /* z */ +#endif memcpy(&dValue, pabyBuf + 68, 8); psSHP->adBoundsMin[2] = dValue; - if (bBigEndian) - SwapWord(8, pabyBuf + 76); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyBuf + 76); +#endif memcpy(&dValue, pabyBuf + 76, 8); psSHP->adBoundsMax[2] = dValue; - if (bBigEndian) - SwapWord(8, pabyBuf + 84); /* z */ +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyBuf + 84); /* z */ +#endif memcpy(&dValue, pabyBuf + 84, 8); psSHP->adBoundsMin[3] = dValue; - if (bBigEndian) - SwapWord(8, pabyBuf + 92); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyBuf + 92); +#endif memcpy(&dValue, pabyBuf + 92, 8); psSHP->adBoundsMax[3] = dValue; @@ -546,7 +470,8 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, if (bLazySHXLoading) pabyBuf = SHPLIB_NULLPTR; else - pabyBuf = STATIC_CAST(uchar *, malloc(8 * MAX(1, psSHP->nRecords))); + pabyBuf = + STATIC_CAST(unsigned char *, malloc(8 * MAX(1, psSHP->nRecords))); if (psSHP->panRecOffset == SHPLIB_NULLPTR || psSHP->panRecSize == SHPLIB_NULLPTR || @@ -612,13 +537,15 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, for (int i = 0; i < psSHP->nRecords; i++) { unsigned int nOffset; memcpy(&nOffset, pabyBuf + i * 8, 4); - if (!bBigEndian) - SwapWord(4, &nOffset); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nOffset); +#endif unsigned int nLength; memcpy(&nLength, pabyBuf + i * 8 + 4, 4); - if (!bBigEndian) - SwapWord(4, &nLength); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nLength); +#endif if (nOffset > STATIC_CAST(unsigned int, INT_MAX)) { char str[128]; @@ -657,7 +584,7 @@ SHPHandle SHPAPI_CALL SHPOpenLL(const char *pszLayer, const char *pszAccess, /************************************************************************/ SHPHandle SHPAPI_CALL SHPOpenLLEx(const char *pszLayer, const char *pszAccess, - SAHooks *psHooks, int bRestoreSHX) + const SAHooks *psHooks, int bRestoreSHX) { if (!bRestoreSHX) return SHPOpenLL(pszLayer, pszAccess, psHooks); @@ -678,7 +605,7 @@ SHPHandle SHPAPI_CALL SHPOpenLLEx(const char *pszLayer, const char *pszAccess, /************************************************************************/ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, - SAHooks *psHooks) + const SAHooks *psHooks) { /* -------------------------------------------------------------------- */ /* Ensure the access string is one of the legal ones. We */ @@ -693,19 +620,6 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, pszAccess = "rb"; } -/* -------------------------------------------------------------------- */ -/* Establish the byte order on this machine. */ -/* -------------------------------------------------------------------- */ -#if !defined(bBigEndian) - { - int i = 1; - if (*((uchar *)&i) == 1) - bBigEndian = false; - else - bBigEndian = true; - } -#endif - /* -------------------------------------------------------------------- */ /* Open the .shp file. Note that files pulled from */ /* a PC to Unix with upper case filenames won't work! */ @@ -714,10 +628,10 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); memcpy(pszFullname, pszLayer, nLenWithoutExtension); memcpy(pszFullname + nLenWithoutExtension, ".shp", 5); - SAFile fpSHP = psHooks->FOpen(pszFullname, pszAccess); + SAFile fpSHP = psHooks->FOpen(pszFullname, pszAccess, psHooks->pvUserData); if (fpSHP == SHPLIB_NULLPTR) { memcpy(pszFullname + nLenWithoutExtension, ".SHP", 5); - fpSHP = psHooks->FOpen(pszFullname, pszAccess); + fpSHP = psHooks->FOpen(pszFullname, pszAccess, psHooks->pvUserData); } if (fpSHP == SHPLIB_NULLPTR) { @@ -738,7 +652,7 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, /* -------------------------------------------------------------------- */ /* Read the file size from the SHP file. */ /* -------------------------------------------------------------------- */ - uchar *pabyBuf = STATIC_CAST(uchar *, malloc(100)); + unsigned char *pabyBuf = STATIC_CAST(unsigned char *, malloc(100)); if (psHooks->FRead(pabyBuf, 100, 1, fpSHP) != 1) { psHooks->Error(".shp file is unreadable, or corrupt."); psHooks->FClose(fpSHP); @@ -759,7 +673,8 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, memcpy(pszFullname + nLenWithoutExtension, ".shx", 5); const char pszSHXAccess[] = "w+b"; - SAFile fpSHX = psHooks->FOpen(pszFullname, pszSHXAccess); + SAFile fpSHX = + psHooks->FOpen(pszFullname, pszSHXAccess, psHooks->pvUserData); if (fpSHX == SHPLIB_NULLPTR) { size_t nMessageLen = strlen(pszFullname) * 2 + 256; char *pszMessage = STATIC_CAST(char *, malloc(nMessageLen)); @@ -789,25 +704,70 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, // unsigned int nCurrentRecordOffset = 0; unsigned int nCurrentSHPOffset = 100; unsigned int nRealSHXContentSize = 100; - unsigned int niRecord = 0; - unsigned int nRecordLength = 0; + int nRetCode = TRUE; unsigned int nRecordOffset = 50; - char abyReadRecord[8]; while (nCurrentSHPOffset < nSHPFilesize) { + unsigned int niRecord = 0; + unsigned int nRecordLength = 0; + int nSHPType; + if (psHooks->FRead(&niRecord, 4, 1, fpSHP) == 1 && - psHooks->FRead(&nRecordLength, 4, 1, fpSHP) == 1) { - if (!bBigEndian) - SwapWord(4, &nRecordOffset); - memcpy(abyReadRecord, &nRecordOffset, 4); + psHooks->FRead(&nRecordLength, 4, 1, fpSHP) == 1 && + psHooks->FRead(&nSHPType, 4, 1, fpSHP) == 1) { + char abyReadRecord[8]; + unsigned int nRecordOffsetBE = nRecordOffset; + +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nRecordOffsetBE); +#endif + memcpy(abyReadRecord, &nRecordOffsetBE, 4); memcpy(abyReadRecord + 4, &nRecordLength, 4); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nRecordLength); +#endif +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nSHPType); +#endif + + // Sanity check on record length + if (nRecordLength < 1 || + nRecordLength > (nSHPFilesize - (nCurrentSHPOffset + 8)) / 2) { + char szErrorMsg[200]; + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Error parsing .shp to restore .shx. " + "Invalid record length = %u at record starting at " + "offset %u", + nRecordLength, nCurrentSHPOffset); + psHooks->Error(szErrorMsg); + + nRetCode = FALSE; + break; + } + + // Sanity check on record type + if (nSHPType != SHPT_NULL && nSHPType != SHPT_POINT && + nSHPType != SHPT_ARC && nSHPType != SHPT_POLYGON && + nSHPType != SHPT_MULTIPOINT && nSHPType != SHPT_POINTZ && + nSHPType != SHPT_ARCZ && nSHPType != SHPT_POLYGONZ && + nSHPType != SHPT_MULTIPOINTZ && nSHPType != SHPT_POINTM && + nSHPType != SHPT_ARCM && nSHPType != SHPT_POLYGONM && + nSHPType != SHPT_MULTIPOINTM && nSHPType != SHPT_MULTIPATCH) { + char szErrorMsg[200]; + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Error parsing .shp to restore .shx. " + "Invalid shape type = %d at record starting at " + "offset %u", + nSHPType, nCurrentSHPOffset); + psHooks->Error(szErrorMsg); + + nRetCode = FALSE; + break; + } + psHooks->FWrite(abyReadRecord, 8, 1, fpSHX); - if (!bBigEndian) - SwapWord(4, &nRecordOffset); - if (!bBigEndian) - SwapWord(4, &nRecordLength); nRecordOffset += nRecordLength + 4; // nCurrentRecordOffset += 8; nCurrentSHPOffset += 8 + nRecordLength * 2; @@ -816,21 +776,30 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, nRealSHXContentSize += 8; } else { - psHooks->Error("Error parsing .shp to restore .shx"); - - psHooks->FClose(fpSHX); - psHooks->FClose(fpSHP); - - free(pabySHXHeader); - free(pszFullname); + char szErrorMsg[200]; + snprintf(szErrorMsg, sizeof(szErrorMsg), + "Error parsing .shp to restore .shx. " + "Cannot read first bytes of record starting at " + "offset %u", + nCurrentSHPOffset); + psHooks->Error(szErrorMsg); - return (0); + nRetCode = FALSE; + break; } } + if (nRetCode && nCurrentSHPOffset != nSHPFilesize) { + psHooks->Error("Error parsing .shp to restore .shx. " + "Not expected number of bytes"); + + nRetCode = FALSE; + } nRealSHXContentSize /= 2; // Bytes counted -> WORDs - if (!bBigEndian) - SwapWord(4, &nRealSHXContentSize); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nRealSHXContentSize); +#endif + psHooks->FSeek(fpSHX, 24, 0); psHooks->FWrite(&nRealSHXContentSize, 4, 1, fpSHX); @@ -840,13 +809,13 @@ int SHPAPI_CALL SHPRestoreSHX(const char *pszLayer, const char *pszAccess, free(pszFullname); free(pabySHXHeader); - return (1); + return nRetCode; } /************************************************************************/ /* SHPClose() */ -/* */ -/* Close the .shp and .shx files. */ +/* */ +/* Close the .shp and .shx files. */ /************************************************************************/ void SHPAPI_CALL SHPClose(SHPHandle psSHP) @@ -855,7 +824,7 @@ void SHPAPI_CALL SHPClose(SHPHandle psSHP) return; /* -------------------------------------------------------------------- */ - /* Update the header if we have modified anything. */ + /* Update the header if we have modified anything. */ /* -------------------------------------------------------------------- */ if (psSHP->bUpdated) SHPWriteHeader(psSHP); @@ -914,8 +883,9 @@ void SHPAPI_CALL SHPSetFastModeReadObject(SHPHandle hSHP, int bFastMode) /* Fetch general information about the shape file. */ /************************************************************************/ -void SHPAPI_CALL SHPGetInfo(SHPHandle psSHP, int *pnEntities, int *pnShapeType, - double *padfMinBound, double *padfMaxBound) +void SHPAPI_CALL SHPGetInfo(const SHPHandle psSHP, int *pnEntities, + int *pnShapeType, double *padfMinBound, + double *padfMaxBound) { if (psSHP == SHPLIB_NULLPTR) return; @@ -958,21 +928,8 @@ SHPHandle SHPAPI_CALL SHPCreate(const char *pszLayer, int nShapeType) /************************************************************************/ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, - SAHooks *psHooks) + const SAHooks *psHooks) { -/* -------------------------------------------------------------------- */ -/* Establish the byte order on this system. */ -/* -------------------------------------------------------------------- */ -#if !defined(bBigEndian) - { - int i = 1; - if (*((uchar *)&i) == 1) - bBigEndian = false; - else - bBigEndian = true; - } -#endif - /* -------------------------------------------------------------------- */ /* Open the two files so we can write their headers. */ /* -------------------------------------------------------------------- */ @@ -980,7 +937,7 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, char *pszFullname = STATIC_CAST(char *, malloc(nLenWithoutExtension + 5)); memcpy(pszFullname, pszLayer, nLenWithoutExtension); memcpy(pszFullname + nLenWithoutExtension, ".shp", 5); - SAFile fpSHP = psHooks->FOpen(pszFullname, "wb"); + SAFile fpSHP = psHooks->FOpen(pszFullname, "w+b", psHooks->pvUserData); if (fpSHP == SHPLIB_NULLPTR) { char szErrorMsg[200]; snprintf(szErrorMsg, sizeof(szErrorMsg), "Failed to create file %s: %s", @@ -988,11 +945,11 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, psHooks->Error(szErrorMsg); free(pszFullname); - return NULL; + return SHPLIB_NULLPTR; } memcpy(pszFullname + nLenWithoutExtension, ".shx", 5); - SAFile fpSHX = psHooks->FOpen(pszFullname, "wb"); + SAFile fpSHX = psHooks->FOpen(pszFullname, "w+b", psHooks->pvUserData); if (fpSHX == SHPLIB_NULLPTR) { char szErrorMsg[200]; snprintf(szErrorMsg, sizeof(szErrorMsg), "Failed to create file %s: %s", @@ -1001,7 +958,7 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, free(pszFullname); psHooks->FClose(fpSHP); - return NULL; + return SHPLIB_NULLPTR; } free(pszFullname); @@ -1010,26 +967,29 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, /* -------------------------------------------------------------------- */ /* Prepare header block for .shp file. */ /* -------------------------------------------------------------------- */ - uchar abyHeader[100]; + unsigned char abyHeader[100]; memset(abyHeader, 0, sizeof(abyHeader)); abyHeader[2] = 0x27; /* magic cookie */ abyHeader[3] = 0x0a; - int32 i32 = 50; /* file size */ + uint32_t i32 = 50; /* file size */ ByteCopy(&i32, abyHeader + 24, 4); - if (!bBigEndian) - SwapWord(4, abyHeader + 24); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(abyHeader + 24); +#endif i32 = 1000; /* version */ ByteCopy(&i32, abyHeader + 28, 4); - if (bBigEndian) - SwapWord(4, abyHeader + 28); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(abyHeader + 28); +#endif i32 = nShapeType; /* shape type */ ByteCopy(&i32, abyHeader + 32, 4); - if (bBigEndian) - SwapWord(4, abyHeader + 32); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(abyHeader + 32); +#endif double dValue = 0.0; /* set bounds */ ByteCopy(&dValue, abyHeader + 36, 8); @@ -1051,7 +1011,7 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, free(pszFullname); psHooks->FClose(fpSHP); psHooks->FClose(fpSHX); - return NULL; + return SHPLIB_NULLPTR; } /* -------------------------------------------------------------------- */ @@ -1059,8 +1019,9 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, /* -------------------------------------------------------------------- */ i32 = 50; /* file size */ ByteCopy(&i32, abyHeader + 24, 4); - if (!bBigEndian) - SwapWord(4, abyHeader + 24); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(abyHeader + 24); +#endif if (psHooks->FWrite(abyHeader, 100, 1, fpSHX) != 1) { char szErrorMsg[200]; @@ -1073,16 +1034,37 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, free(pszFullname); psHooks->FClose(fpSHP); psHooks->FClose(fpSHX); - return NULL; + return SHPLIB_NULLPTR; } - /* -------------------------------------------------------------------- */ - /* Close the files, and then open them as regular existing files. */ - /* -------------------------------------------------------------------- */ - psHooks->FClose(fpSHP); - psHooks->FClose(fpSHX); + SHPHandle psSHP = STATIC_CAST(SHPHandle, calloc(1, sizeof(SHPInfo))); - return (SHPOpenLL(pszLayer, "r+b", psHooks)); + psSHP->bUpdated = FALSE; + memcpy(&(psSHP->sHooks), psHooks, sizeof(SAHooks)); + + psSHP->fpSHP = fpSHP; + psSHP->fpSHX = fpSHX; + psSHP->nShapeType = nShapeType; + psSHP->nFileSize = 100; + psSHP->panRecOffset = + STATIC_CAST(unsigned int *, malloc(sizeof(unsigned int))); + psSHP->panRecSize = + STATIC_CAST(unsigned int *, malloc(sizeof(unsigned int))); + + if (psSHP->panRecOffset == SHPLIB_NULLPTR || + psSHP->panRecSize == SHPLIB_NULLPTR) { + psSHP->sHooks.Error("Not enough memory to allocate requested memory"); + psSHP->sHooks.FClose(psSHP->fpSHP); + psSHP->sHooks.FClose(psSHP->fpSHX); + if (psSHP->panRecOffset) + free(psSHP->panRecOffset); + if (psSHP->panRecSize) + free(psSHP->panRecSize); + free(psSHP); + return SHPLIB_NULLPTR; + } + + return psSHP; } /************************************************************************/ @@ -1092,19 +1074,19 @@ SHPHandle SHPAPI_CALL SHPCreateLL(const char *pszLayer, int nShapeType, /* indicated location in the record. */ /************************************************************************/ -static void _SHPSetBounds(uchar *pabyRec, SHPObject *psShape) +static void _SHPSetBounds(unsigned char *pabyRec, const SHPObject *psShape) { ByteCopy(&(psShape->dfXMin), pabyRec + 0, 8); ByteCopy(&(psShape->dfYMin), pabyRec + 8, 8); ByteCopy(&(psShape->dfXMax), pabyRec + 16, 8); ByteCopy(&(psShape->dfYMax), pabyRec + 24, 8); - if (bBigEndian) { - SwapWord(8, pabyRec + 0); - SwapWord(8, pabyRec + 8); - SwapWord(8, pabyRec + 16); - SwapWord(8, pabyRec + 24); - } +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + 0); + SHP_SWAP64(pabyRec + 8); + SHP_SWAP64(pabyRec + 16); + SHP_SWAP64(pabyRec + 24); +#endif } /************************************************************************/ @@ -1159,7 +1141,7 @@ SHPObject SHPAPI_CALL1(*) psObject->bMeasureIsUsed = FALSE; /* -------------------------------------------------------------------- */ - /* Establish whether this shape type has M, and Z values. */ + /* Establish whether this shape type has M, and Z values. */ /* -------------------------------------------------------------------- */ bool bHasM; bool bHasZ; @@ -1191,7 +1173,7 @@ SHPObject SHPAPI_CALL1(*) psObject->nParts = MAX(1, nParts); psObject->panPartStart = - STATIC_CAST(int *, calloc(sizeof(int), psObject->nParts)); + STATIC_CAST(int *, calloc(psObject->nParts, sizeof(int))); psObject->panPartType = STATIC_CAST(int *, malloc(sizeof(int) * psObject->nParts)); @@ -1208,8 +1190,7 @@ SHPObject SHPAPI_CALL1(*) psObject->panPartType[i] = SHPP_RING; } - if (psObject->panPartStart[0] != 0) - psObject->panPartStart[0] = 0; + psObject->panPartStart[0] = 0; } /* -------------------------------------------------------------------- */ @@ -1219,16 +1200,16 @@ SHPObject SHPAPI_CALL1(*) const size_t nSize = sizeof(double) * nVertices; psObject->padfX = STATIC_CAST(double *, padfX ? malloc(nSize) - : calloc(sizeof(double), nVertices)); + : calloc(nVertices, sizeof(double))); psObject->padfY = STATIC_CAST(double *, padfY ? malloc(nSize) - : calloc(sizeof(double), nVertices)); + : calloc(nVertices, sizeof(double))); psObject->padfZ = STATIC_CAST( double *, - padfZ &&bHasZ ? malloc(nSize) : calloc(sizeof(double), nVertices)); + padfZ &&bHasZ ? malloc(nSize) : calloc(nVertices, sizeof(double))); psObject->padfM = STATIC_CAST( double *, - padfM &&bHasM ? malloc(nSize) : calloc(sizeof(double), nVertices)); + padfM &&bHasM ? malloc(nSize) : calloc(nVertices, sizeof(double))); if (padfX != SHPLIB_NULLPTR) memcpy(psObject->padfX, padfX, nSize); if (padfY != SHPLIB_NULLPTR) @@ -1273,7 +1254,7 @@ SHPObject SHPAPI_CALL1(*) /************************************************************************/ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, - SHPObject *psObject) + const SHPObject *psObject) { psSHP->bUpdated = TRUE; @@ -1298,22 +1279,32 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, /* Add the new entity to the in memory index. */ /* -------------------------------------------------------------------- */ if (nShapeId == -1 && psSHP->nRecords + 1 > psSHP->nMaxRecords) { + /* This cannot overflow given that we check that the file size does + * not grow over 4 GB, and the minimum size of a record is 12 bytes, + * hence the maximm value for nMaxRecords is 357,913,941 + */ int nNewMaxRecords = psSHP->nMaxRecords + psSHP->nMaxRecords / 3 + 100; unsigned int *panRecOffsetNew; unsigned int *panRecSizeNew; panRecOffsetNew = STATIC_CAST( - unsigned int *, SfRealloc(psSHP->panRecOffset, - sizeof(unsigned int) * nNewMaxRecords)); - if (panRecOffsetNew == SHPLIB_NULLPTR) + unsigned int *, realloc(psSHP->panRecOffset, + sizeof(unsigned int) * nNewMaxRecords)); + if (panRecOffsetNew == SHPLIB_NULLPTR) { + psSHP->sHooks.Error("Failed to write shape object. " + "Memory allocation error."); return -1; + } psSHP->panRecOffset = panRecOffsetNew; panRecSizeNew = STATIC_CAST( - unsigned int *, SfRealloc(psSHP->panRecSize, - sizeof(unsigned int) * nNewMaxRecords)); - if (panRecSizeNew == SHPLIB_NULLPTR) + unsigned int *, + realloc(psSHP->panRecSize, sizeof(unsigned int) * nNewMaxRecords)); + if (panRecSizeNew == SHPLIB_NULLPTR) { + psSHP->sHooks.Error("Failed to write shape object. " + "Memory allocation error."); return -1; + } psSHP->panRecSize = panRecSizeNew; psSHP->nMaxRecords = nNewMaxRecords; @@ -1322,14 +1313,28 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, /* -------------------------------------------------------------------- */ /* Initialize record. */ /* -------------------------------------------------------------------- */ - uchar *pabyRec = - STATIC_CAST(uchar *, malloc(psObject->nVertices * 4 * sizeof(double) + - psObject->nParts * 8 + 128)); - if (pabyRec == SHPLIB_NULLPTR) + + /* The following computation cannot overflow on 32-bit platforms given that + * the user had to allocate arrays of at least that size. */ + size_t nRecMaxSize = + psObject->nVertices * 4 * sizeof(double) + psObject->nParts * 8; + /* But the following test could trigger on 64-bit platforms on huge + * geometries. */ + const unsigned nExtraSpaceForGeomHeader = 128; + if (nRecMaxSize > UINT_MAX - nExtraSpaceForGeomHeader) { + psSHP->sHooks.Error("Failed to write shape object. Too big geometry."); return -1; + } + nRecMaxSize += nExtraSpaceForGeomHeader; + unsigned char *pabyRec = STATIC_CAST(unsigned char *, malloc(nRecMaxSize)); + if (pabyRec == SHPLIB_NULLPTR) { + psSHP->sHooks.Error("Failed to write shape object. " + "Memory allocation error."); + return -1; + } /* -------------------------------------------------------------------- */ - /* Extract vertices for a Polygon or Arc. */ + /* Extract vertices for a Polygon or Arc. */ /* -------------------------------------------------------------------- */ unsigned int nRecordSize = 0; const bool bFirstFeature = psSHP->nRecords == 0; @@ -1339,15 +1344,15 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, psObject->nSHPType == SHPT_POLYGONM || psObject->nSHPType == SHPT_ARC || psObject->nSHPType == SHPT_ARCZ || psObject->nSHPType == SHPT_ARCM || psObject->nSHPType == SHPT_MULTIPATCH) { - int32 nPoints = psObject->nVertices; - int32 nParts = psObject->nParts; + uint32_t nPoints = psObject->nVertices; + uint32_t nParts = psObject->nParts; _SHPSetBounds(pabyRec + 12, psObject); - if (bBigEndian) - SwapWord(4, &nPoints); - if (bBigEndian) - SwapWord(4, &nParts); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nPoints); + SHP_SWAP32(&nParts); +#endif ByteCopy(&nPoints, pabyRec + 40 + 8, 4); ByteCopy(&nParts, pabyRec + 36 + 8, 4); @@ -1360,8 +1365,9 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, ByteCopy(psObject->panPartStart, pabyRec + 44 + 8, 4 * psObject->nParts); for (int i = 0; i < psObject->nParts; i++) { - if (bBigEndian) - SwapWord(4, pabyRec + 44 + 8 + 4 * i); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(pabyRec + 44 + 8 + 4 * i); +#endif nRecordSize += 4; } @@ -1372,8 +1378,9 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, memcpy(pabyRec + nRecordSize, psObject->panPartType, 4 * psObject->nParts); for (int i = 0; i < psObject->nParts; i++) { - if (bBigEndian) - SwapWord(4, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(pabyRec + nRecordSize); +#endif nRecordSize += 4; } } @@ -1385,11 +1392,10 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, ByteCopy(psObject->padfX + i, pabyRec + nRecordSize, 8); ByteCopy(psObject->padfY + i, pabyRec + nRecordSize + 8, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); - - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize + 8); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); + SHP_SWAP64(pabyRec + nRecordSize + 8); +#endif nRecordSize += 2 * 8; } @@ -1401,19 +1407,22 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, psObject->nSHPType == SHPT_ARCZ || psObject->nSHPType == SHPT_MULTIPATCH) { ByteCopy(&(psObject->dfZMin), pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; ByteCopy(&(psObject->dfZMax), pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; for (int i = 0; i < psObject->nVertices; i++) { ByteCopy(psObject->padfZ + i, pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; } } @@ -1430,65 +1439,72 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, || psObject->nSHPType == SHPT_POLYGONZ || psObject->nSHPType == SHPT_ARCZ)) { ByteCopy(&(psObject->dfMMin), pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; ByteCopy(&(psObject->dfMMax), pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; for (int i = 0; i < psObject->nVertices; i++) { ByteCopy(psObject->padfM + i, pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; } } } /* -------------------------------------------------------------------- */ - /* Extract vertices for a MultiPoint. */ + /* Extract vertices for a MultiPoint. */ /* -------------------------------------------------------------------- */ else if (psObject->nSHPType == SHPT_MULTIPOINT || psObject->nSHPType == SHPT_MULTIPOINTZ || psObject->nSHPType == SHPT_MULTIPOINTM) { - int32 nPoints = psObject->nVertices; + uint32_t nPoints = psObject->nVertices; _SHPSetBounds(pabyRec + 12, psObject); - if (bBigEndian) - SwapWord(4, &nPoints); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nPoints); +#endif ByteCopy(&nPoints, pabyRec + 44, 4); for (int i = 0; i < psObject->nVertices; i++) { ByteCopy(psObject->padfX + i, pabyRec + 48 + i * 16, 8); ByteCopy(psObject->padfY + i, pabyRec + 48 + i * 16 + 8, 8); - if (bBigEndian) - SwapWord(8, pabyRec + 48 + i * 16); - if (bBigEndian) - SwapWord(8, pabyRec + 48 + i * 16 + 8); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + 48 + i * 16); + SHP_SWAP64(pabyRec + 48 + i * 16 + 8); +#endif } nRecordSize = 48 + 16 * psObject->nVertices; if (psObject->nSHPType == SHPT_MULTIPOINTZ) { ByteCopy(&(psObject->dfZMin), pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; ByteCopy(&(psObject->dfZMax), pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; for (int i = 0; i < psObject->nVertices; i++) { ByteCopy(psObject->padfZ + i, pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; } } @@ -1497,26 +1513,29 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, (psObject->nSHPType == SHPT_MULTIPOINTZ || psObject->nSHPType == SHPT_MULTIPOINTM)) { ByteCopy(&(psObject->dfMMin), pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; ByteCopy(&(psObject->dfMMax), pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; for (int i = 0; i < psObject->nVertices; i++) { ByteCopy(psObject->padfM + i, pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; } } } /* -------------------------------------------------------------------- */ - /* Write point. */ + /* Write point. */ /* -------------------------------------------------------------------- */ else if (psObject->nSHPType == SHPT_POINT || psObject->nSHPType == SHPT_POINTZ || @@ -1524,25 +1543,27 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, ByteCopy(psObject->padfX, pabyRec + 12, 8); ByteCopy(psObject->padfY, pabyRec + 20, 8); - if (bBigEndian) - SwapWord(8, pabyRec + 12); - if (bBigEndian) - SwapWord(8, pabyRec + 20); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + 12); + SHP_SWAP64(pabyRec + 20); +#endif nRecordSize = 28; if (psObject->nSHPType == SHPT_POINTZ) { ByteCopy(psObject->padfZ, pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; } if (psObject->bMeasureIsUsed && (psObject->nSHPType == SHPT_POINTZ || psObject->nSHPType == SHPT_POINTM)) { ByteCopy(psObject->padfM, pabyRec + nRecordSize, 8); - if (bBigEndian) - SwapWord(8, pabyRec + nRecordSize); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP64(pabyRec + nRecordSize); +#endif nRecordSize += 8; } } @@ -1598,20 +1619,23 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, /* -------------------------------------------------------------------- */ /* Set the shape type, record number, and record size. */ /* -------------------------------------------------------------------- */ - int32 i32 = + uint32_t i32 = (nShapeId < 0) ? psSHP->nRecords + 1 : nShapeId + 1; /* record # */ - if (!bBigEndian) - SwapWord(4, &i32); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&i32); +#endif ByteCopy(&i32, pabyRec, 4); i32 = (nRecordSize - 8) / 2; /* record size */ - if (!bBigEndian) - SwapWord(4, &i32); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&i32); +#endif ByteCopy(&i32, pabyRec + 4, 4); i32 = psObject->nSHPType; /* shape type */ - if (bBigEndian) - SwapWord(4, &i32); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&i32); +#endif ByteCopy(&i32, pabyRec + 8, 4); /* -------------------------------------------------------------------- */ @@ -1666,7 +1690,7 @@ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, psSHP->panRecSize[nShapeId] = nRecordSize - 8; /* -------------------------------------------------------------------- */ - /* Expand file wide bounds based on this shape. */ + /* Expand file wide bounds based on this shape. */ /* -------------------------------------------------------------------- */ if (bFirstFeature) { if (psObject->nSHPType == SHPT_NULL || psObject->nVertices == 0) { @@ -1754,11 +1778,11 @@ static unsigned char *SHPReallocObjectBufIfNecessary(SHPHandle psSHP, /************************************************************************/ /* SHPReadObject() */ /* */ -/* Read the vertices, parts, and other non-attribute information */ -/* for one shape. */ +/* Read the vertices, parts, and other non-attribute information */ +/* for one shape. */ /************************************************************************/ -SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) +SHPObject SHPAPI_CALL1(*) SHPReadObject(const SHPHandle psSHP, int hEntity) { /* -------------------------------------------------------------------- */ /* Validate the record/entity number. */ @@ -1786,10 +1810,10 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) psSHP->sHooks.Error(str); return SHPLIB_NULLPTR; } - if (!bBigEndian) - SwapWord(4, &nOffset); - if (!bBigEndian) - SwapWord(4, &nLength); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nOffset); + SHP_SWAP32(&nLength); +#endif if (nOffset > STATIC_CAST(unsigned int, INT_MAX)) { char str[128]; @@ -1859,8 +1883,8 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) } } - uchar *pabyRecNew = - STATIC_CAST(uchar *, SfRealloc(psSHP->pabyRec, nNewBufSize)); + unsigned char *pabyRecNew = + STATIC_CAST(unsigned char *, realloc(psSHP->pabyRec, nNewBufSize)); if (pabyRecNew == SHPLIB_NULLPTR) { char szErrorMsg[160]; snprintf(szErrorMsg, sizeof(szErrorMsg), @@ -1919,8 +1943,9 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* Do a sanity check */ int nSHPContentLength; memcpy(&nSHPContentLength, psSHP->pabyRec + 4, 4); - if (!bBigEndian) - SwapWord(4, &(nSHPContentLength)); +#if !defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&(nSHPContentLength)); +#endif if (nSHPContentLength < 0 || nSHPContentLength > INT_MAX / 2 - 4 || 2 * nSHPContentLength + 8 != nBytesRead) { char str[128]; @@ -1962,11 +1987,12 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) int nSHPType; memcpy(&nSHPType, psSHP->pabyRec + 8, 4); - if (bBigEndian) - SwapWord(4, &(nSHPType)); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&(nSHPType)); +#endif /* -------------------------------------------------------------------- */ - /* Allocate and minimally initialize the object. */ + /* Allocate and minimally initialize the object. */ /* -------------------------------------------------------------------- */ SHPObject *psShape; if (psSHP->bFastModeReadObject) { @@ -1988,7 +2014,7 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) psShape->bFastModeReadObject = psSHP->bFastModeReadObject; /* ==================================================================== */ - /* Extract vertices for a Polygon or Arc. */ + /* Extract vertices for a Polygon or Arc. */ /* ==================================================================== */ if (psShape->nSHPType == SHPT_POLYGON || psShape->nSHPType == SHPT_ARC || psShape->nSHPType == SHPT_POLYGONZ || @@ -2007,22 +2033,20 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) } /* -------------------------------------------------------------------- */ - /* Get the X/Y bounds. */ + /* Get the X/Y bounds. */ /* -------------------------------------------------------------------- */ - memcpy(&(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8); - memcpy(&(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8); - memcpy(&(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8); - memcpy(&(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8); - - if (bBigEndian) - SwapWord(8, &(psShape->dfXMin)); - if (bBigEndian) - SwapWord(8, &(psShape->dfYMin)); - if (bBigEndian) - SwapWord(8, &(psShape->dfXMax)); - if (bBigEndian) - SwapWord(8, &(psShape->dfYMax)); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(&psShape->dfXMin, psSHP->pabyRec + 8 + 4); + SHP_SWAPDOUBLE_CPY(&psShape->dfYMin, psSHP->pabyRec + 8 + 12); + SHP_SWAPDOUBLE_CPY(&psShape->dfXMax, psSHP->pabyRec + 8 + 20); + SHP_SWAPDOUBLE_CPY(&psShape->dfYMax, psSHP->pabyRec + 8 + 28); +#else + memcpy(&psShape->dfXMin, psSHP->pabyRec + 8 + 4, 8); + memcpy(&psShape->dfYMin, psSHP->pabyRec + 8 + 12, 8); + memcpy(&psShape->dfXMax, psSHP->pabyRec + 8 + 20, 8); + memcpy(&psShape->dfYMax, psSHP->pabyRec + 8 + 28, 8); +#endif /* -------------------------------------------------------------------- */ @@ -2030,15 +2054,15 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* to proper size. */ /* -------------------------------------------------------------------- */ - int32 nPoints; + uint32_t nPoints; memcpy(&nPoints, psSHP->pabyRec + 40 + 8, 4); - int32 nParts; + uint32_t nParts; memcpy(&nParts, psSHP->pabyRec + 36 + 8, 4); - if (bBigEndian) - SwapWord(4, &nPoints); - if (bBigEndian) - SwapWord(4, &nParts); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nPoints); + SHP_SWAP32(&nParts); +#endif /* nPoints and nParts are unsigned */ if (/* nPoints < 0 || nParts < 0 || */ @@ -2121,7 +2145,7 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) return SHPLIB_NULLPTR; } - for (int i = 0; STATIC_CAST(int32, i) < nParts; i++) + for (int i = 0; STATIC_CAST(uint32_t, i) < nParts; i++) psShape->panPartType[i] = SHPP_RING; /* -------------------------------------------------------------------- @@ -2130,9 +2154,10 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* -------------------------------------------------------------------- */ memcpy(psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts); - for (int i = 0; STATIC_CAST(int32, i) < nParts; i++) { - if (bBigEndian) - SwapWord(4, psShape->panPartStart + i); + for (int i = 0; STATIC_CAST(uint32_t, i) < nParts; i++) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(psShape->panPartStart + i); +#endif /* We check that the offset is inside the vertex array */ if (psShape->panPartStart[i] < 0 || @@ -2174,9 +2199,10 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) */ if (psShape->nSHPType == SHPT_MULTIPATCH) { memcpy(psShape->panPartType, psSHP->pabyRec + nOffset, 4 * nParts); - for (int i = 0; STATIC_CAST(int32, i) < nParts; i++) { - if (bBigEndian) - SwapWord(4, psShape->panPartType + i); + for (int i = 0; STATIC_CAST(uint32_t, i) < nParts; i++) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(psShape->panPartType + i); +#endif } nOffset += 4 * nParts; @@ -2187,16 +2213,17 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* Copy out the vertices from the record. */ /* -------------------------------------------------------------------- */ - for (int i = 0; STATIC_CAST(int32, i) < nPoints; i++) { + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfX + i, + psSHP->pabyRec + nOffset + i * 16); + SHP_SWAPDOUBLE_CPY(psShape->padfY + i, + psSHP->pabyRec + nOffset + i * 16 + 8); +#else memcpy(psShape->padfX + i, psSHP->pabyRec + nOffset + i * 16, 8); - memcpy(psShape->padfY + i, psSHP->pabyRec + nOffset + i * 16 + 8, 8); - - if (bBigEndian) - SwapWord(8, psShape->padfX + i); - if (bBigEndian) - SwapWord(8, psShape->padfY + i); +#endif } nOffset += 16 * nPoints; @@ -2209,19 +2236,23 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) if (psShape->nSHPType == SHPT_POLYGONZ || psShape->nSHPType == SHPT_ARCZ || psShape->nSHPType == SHPT_MULTIPATCH) { - memcpy(&(psShape->dfZMin), psSHP->pabyRec + nOffset, 8); - memcpy(&(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(&psShape->dfZMin, psSHP->pabyRec + nOffset); + SHP_SWAPDOUBLE_CPY(&psShape->dfZMax, psSHP->pabyRec + nOffset + 8); +#else + memcpy(&psShape->dfZMin, psSHP->pabyRec + nOffset, 8); + memcpy(&psShape->dfZMax, psSHP->pabyRec + nOffset + 8, 8); - if (bBigEndian) - SwapWord(8, &(psShape->dfZMin)); - if (bBigEndian) - SwapWord(8, &(psShape->dfZMax)); +#endif - for (int i = 0; STATIC_CAST(int32, i) < nPoints; i++) { + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfZ + i, + psSHP->pabyRec + nOffset + 16 + i * 8); +#else memcpy(psShape->padfZ + i, psSHP->pabyRec + nOffset + 16 + i * 8, 8); - if (bBigEndian) - SwapWord(8, psShape->padfZ + i); +#endif } nOffset += 16 + 8 * nPoints; @@ -2239,19 +2270,22 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* -------------------------------------------------------------------- */ if (nEntitySize >= STATIC_CAST(int, nOffset + 16 + 8 * nPoints)) { - memcpy(&(psShape->dfMMin), psSHP->pabyRec + nOffset, 8); - memcpy(&(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8); - - if (bBigEndian) - SwapWord(8, &(psShape->dfMMin)); - if (bBigEndian) - SwapWord(8, &(psShape->dfMMax)); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(&psShape->dfMMin, psSHP->pabyRec + nOffset); + SHP_SWAPDOUBLE_CPY(&psShape->dfMMax, psSHP->pabyRec + nOffset + 8); +#else + memcpy(&psShape->dfMMin, psSHP->pabyRec + nOffset, 8); + memcpy(&psShape->dfMMax, psSHP->pabyRec + nOffset + 8, 8); +#endif - for (int i = 0; STATIC_CAST(int32, i) < nPoints; i++) { + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfM + i, + psSHP->pabyRec + nOffset + 16 + i * 8); +#else memcpy(psShape->padfM + i, psSHP->pabyRec + nOffset + 16 + i * 8, 8); - if (bBigEndian) - SwapWord(8, psShape->padfM + i); +#endif } psShape->bMeasureIsUsed = TRUE; } @@ -2261,7 +2295,7 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) } /* ==================================================================== */ - /* Extract vertices for a MultiPoint. */ + /* Extract vertices for a MultiPoint. */ /* ==================================================================== */ else if (psShape->nSHPType == SHPT_MULTIPOINT || psShape->nSHPType == SHPT_MULTIPOINTM || @@ -2276,11 +2310,12 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } - int32 nPoints; + uint32_t nPoints; memcpy(&nPoints, psSHP->pabyRec + 44, 4); - if (bBigEndian) - SwapWord(4, &nPoints); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAP32(&nPoints); +#endif /* nPoints is unsigned */ if (/* nPoints < 0 || */ nPoints > 50 * 1000 * 1000) { @@ -2346,36 +2381,36 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) return SHPLIB_NULLPTR; } - for (int i = 0; STATIC_CAST(int32, i) < nPoints; i++) { + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfX + i, + psSHP->pabyRec + 48 + 16 * i); + SHP_SWAPDOUBLE_CPY(psShape->padfY + i, + psSHP->pabyRec + 48 + 16 * i + 8); +#else memcpy(psShape->padfX + i, psSHP->pabyRec + 48 + 16 * i, 8); memcpy(psShape->padfY + i, psSHP->pabyRec + 48 + 16 * i + 8, 8); - - if (bBigEndian) - SwapWord(8, psShape->padfX + i); - if (bBigEndian) - SwapWord(8, psShape->padfY + i); +#endif } int nOffset = 48 + 16 * nPoints; /* -------------------------------------------------------------------- */ - /* Get the X/Y bounds. */ + /* Get the X/Y bounds. */ /* -------------------------------------------------------------------- */ - memcpy(&(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8); - memcpy(&(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8); - memcpy(&(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8); - memcpy(&(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8); - - if (bBigEndian) - SwapWord(8, &(psShape->dfXMin)); - if (bBigEndian) - SwapWord(8, &(psShape->dfYMin)); - if (bBigEndian) - SwapWord(8, &(psShape->dfXMax)); - if (bBigEndian) - SwapWord(8, &(psShape->dfYMax)); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(&psShape->dfXMin, psSHP->pabyRec + 8 + 4); + SHP_SWAPDOUBLE_CPY(&psShape->dfYMin, psSHP->pabyRec + 8 + 12); + SHP_SWAPDOUBLE_CPY(&psShape->dfXMax, psSHP->pabyRec + 8 + 20); + SHP_SWAPDOUBLE_CPY(&psShape->dfYMax, psSHP->pabyRec + 8 + 28); +#else + memcpy(&psShape->dfXMin, psSHP->pabyRec + 8 + 4, 8); + memcpy(&psShape->dfYMin, psSHP->pabyRec + 8 + 12, 8); + memcpy(&psShape->dfXMax, psSHP->pabyRec + 8 + 20, 8); + memcpy(&psShape->dfYMax, psSHP->pabyRec + 8 + 28, 8); +#endif /* -------------------------------------------------------------------- */ @@ -2383,19 +2418,22 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* -------------------------------------------------------------------- */ if (psShape->nSHPType == SHPT_MULTIPOINTZ) { - memcpy(&(psShape->dfZMin), psSHP->pabyRec + nOffset, 8); - memcpy(&(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8); - - if (bBigEndian) - SwapWord(8, &(psShape->dfZMin)); - if (bBigEndian) - SwapWord(8, &(psShape->dfZMax)); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(&psShape->dfZMin, psSHP->pabyRec + nOffset); + SHP_SWAPDOUBLE_CPY(&psShape->dfZMax, psSHP->pabyRec + nOffset + 8); +#else + memcpy(&psShape->dfZMin, psSHP->pabyRec + nOffset, 8); + memcpy(&psShape->dfZMax, psSHP->pabyRec + nOffset + 8, 8); +#endif - for (int i = 0; STATIC_CAST(int32, i) < nPoints; i++) { + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfZ + i, + psSHP->pabyRec + nOffset + 16 + i * 8); +#else memcpy(psShape->padfZ + i, psSHP->pabyRec + nOffset + 16 + i * 8, 8); - if (bBigEndian) - SwapWord(8, psShape->padfZ + i); +#endif } nOffset += 16 + 8 * nPoints; @@ -2412,19 +2450,22 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* -------------------------------------------------------------------- */ if (nEntitySize >= STATIC_CAST(int, nOffset + 16 + 8 * nPoints)) { - memcpy(&(psShape->dfMMin), psSHP->pabyRec + nOffset, 8); - memcpy(&(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8); - - if (bBigEndian) - SwapWord(8, &(psShape->dfMMin)); - if (bBigEndian) - SwapWord(8, &(psShape->dfMMax)); +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(&psShape->dfMMin, psSHP->pabyRec + nOffset); + SHP_SWAPDOUBLE_CPY(&psShape->dfMMax, psSHP->pabyRec + nOffset + 8); +#else + memcpy(&psShape->dfMMin, psSHP->pabyRec + nOffset, 8); + memcpy(&psShape->dfMMax, psSHP->pabyRec + nOffset + 8, 8); +#endif - for (int i = 0; STATIC_CAST(int32, i) < nPoints; i++) { + for (int i = 0; STATIC_CAST(uint32_t, i) < nPoints; i++) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfM + i, + psSHP->pabyRec + nOffset + 16 + i * 8); +#else memcpy(psShape->padfM + i, psSHP->pabyRec + nOffset + 16 + i * 8, 8); - if (bBigEndian) - SwapWord(8, psShape->padfM + i); +#endif } psShape->bMeasureIsUsed = TRUE; } @@ -2465,13 +2506,13 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) SHPDestroyObject(psShape); return SHPLIB_NULLPTR; } +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfX, psSHP->pabyRec + 12); + SHP_SWAPDOUBLE_CPY(psShape->padfY, psSHP->pabyRec + 20); +#else memcpy(psShape->padfX, psSHP->pabyRec + 12, 8); memcpy(psShape->padfY, psSHP->pabyRec + 20, 8); - - if (bBigEndian) - SwapWord(8, psShape->padfX); - if (bBigEndian) - SwapWord(8, psShape->padfY); +#endif int nOffset = 20 + 8; @@ -2481,10 +2522,11 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* -------------------------------------------------------------------- */ if (psShape->nSHPType == SHPT_POINTZ) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfZ, psSHP->pabyRec + nOffset); +#else memcpy(psShape->padfZ, psSHP->pabyRec + nOffset, 8); - - if (bBigEndian) - SwapWord(8, psShape->padfZ); +#endif nOffset += 8; } @@ -2498,10 +2540,11 @@ SHPObject SHPAPI_CALL1(*) SHPReadObject(SHPHandle psSHP, int hEntity) /* -------------------------------------------------------------------- */ if (nEntitySize >= nOffset + 8) { +#if defined(SHP_BIG_ENDIAN) + SHP_SWAPDOUBLE_CPY(psShape->padfM, psSHP->pabyRec + nOffset); +#else memcpy(psShape->padfM, psSHP->pabyRec + nOffset, 8); - - if (bBigEndian) - SwapWord(8, psShape->padfM); +#endif psShape->bMeasureIsUsed = TRUE; } @@ -2739,8 +2782,9 @@ static int SHPRewindIsInnerRing(const SHPObject *psObject, int iOpRing, /* specification. */ /************************************************************************/ -int SHPAPI_CALL SHPRewindObject(CPL_UNUSED SHPHandle hSHP, SHPObject *psObject) +int SHPAPI_CALL SHPRewindObject(const SHPHandle hSHP, SHPObject *psObject) { + (void)hSHP; /* -------------------------------------------------------------------- */ /* Do nothing if this is not a polygon object. */ /* -------------------------------------------------------------------- */ diff --git a/lib/gis/copy_dir.c b/lib/gis/copy_dir.c index 226e25a5a39..8babbc2e964 100644 --- a/lib/gis/copy_dir.c +++ b/lib/gis/copy_dir.c @@ -141,8 +141,10 @@ int G_recursive_copy(const char *src, const char *dst) sprintf(path, "%s/%s", src, dp->d_name); sprintf(path2, "%s/%s", dst, dp->d_name); - if (G_recursive_copy(path, path2) != 0) + if (G_recursive_copy(path, path2) != 0) { + closedir(dirp); return 1; + } } closedir(dirp); diff --git a/lib/gis/getl.c b/lib/gis/getl.c index 7daae816a70..34df9b04ad0 100644 --- a/lib/gis/getl.c +++ b/lib/gis/getl.c @@ -19,8 +19,7 @@ * \brief Gets a line of text from a file * * This routine runs fgets() to fetch a line of text from a file - * (advancing file pointer) and removes trailing newline. fgets() does - * not recognize '\\r' as an EOL and will read past * it. + * (advancing file pointer) and removes trailing newline. * * \param buf string buffer to receive read data * \param n maximum number of bytes to read @@ -28,23 +27,18 @@ * * \return 1 on success * \return 0 EOF + * + * \see G_getl2() */ int G_getl(char *buf, int n, FILE *fd) { - if (!fgets(buf, n, fd)) - return 0; - - for (; *buf && *buf != '\n'; buf++) - ; - *buf = 0; - - return 1; + return G_getl2(buf, n, fd); } /*! * \brief Gets a line of text from a file of any pedigree * - * This routine is like G_getl() but is more portable. It supports + * This routine supports * text files created on various platforms (UNIX, MacOS9, DOS), * i.e. \\n (\\012), \\r (\\015), and * \\r\\n (\\015\\012) style newlines. diff --git a/lib/gis/gislib.dox b/lib/gis/gislib.dox index fbe1df178e6..852159228cb 100644 --- a/lib/gis/gislib.dox +++ b/lib/gis/gislib.dox @@ -1179,6 +1179,14 @@ The next routines replaces character(s) from string. Replace all occurrences of character in string with new. + - G_str_to_sql() + +Make string SQL compliant. + + - G_str_replace() + +Replace all occurrences of old_str in buffer with new_str. + This next routine copies a string to allocated memory. - G_store() @@ -1186,6 +1194,14 @@ This next routine copies a string to allocated memory. This routine allocates enough memory to hold the string, and returns a pointer to the allocated memory. + - G_store_lower() + +Copy string to allocated memory and convert copied string to lower case. + + - G_store_upper() + +Copy string to allocated memory and convert copied string to upper case. + The next 2 routines convert between upper and lower case. - G_tolcase() @@ -1203,12 +1219,6 @@ equivalent. This routine remove trailing zeros from decimal number for example: 23.45000 would come back as 23.45. - - G_index() - - - G_rindex() - -Get position of delimiter. - - G_strcasecmp() - G_strncasecmp() @@ -1220,11 +1230,24 @@ String compare ignoring case (upper or lower). Return a pointer to the first occurrence of subString in mainString, or NULL if no occurrences are found. - - G_strdup() + - G_str_concat() + +Concatenation of a list of strings, separated by a given character. + + - G_tokenize() + - G_tokenize2() + +Tokenize string. Create array of strings from an input string split up with +given delimiter characters. + + - G_strlcat() + +Size-bounded string concatenation (wrapper function to strlcat()). + + - G_strlcpy() + +Size-bounded string copying (wrapper function to strlcpy()). -Returns a pointer to a string that is a duplicate of the string given -to G_strdup. The duplicate is created using malloc. If unable to -allocate the required space, NULL is returned. \section Enhanced_UNIX_Routines Enhanced UNIX Routines diff --git a/lib/gis/strlcat.c b/lib/gis/strlcat.c new file mode 100644 index 00000000000..635ffbdedb8 --- /dev/null +++ b/lib/gis/strlcat.c @@ -0,0 +1,92 @@ +/*! + * \file lib/gis/strlcat.c + * + * \brief GIS Library - GRASS implementation of strlcat(). + * + * If available, G_strlcat() calls system strlcat(), otherwise it uses + * implementation by Todd C. Miller of OpenBSD. + * + * Addition to GRASS GIS by Nicklas Larsson, 2024 + * + * Original OpenBSD implementation notes: + * + * Copyright (c) 1998, 2015 Todd C. Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +static size_t G__strlcat(char *restrict dst, const char *restrict src, + size_t dsize); + +/** + * \brief Size-bounded string concatenation + * + * Appends string src to the end of dst. It will append at most + * dstsize - strlen(dst) - 1 characters. It will then NUL-terminate, unless + * dstsize is 0 or the original dst string was longer than dstsize (in practice + * this should not happen as it means that either dstsize is incorrect or that + * dst is not a proper string). + * + * If the src and dst strings overlap, the behavior is undefined. + * This function is a safer alternative to strncat. + * + * \param[out] dst Pointer to the destination buffer. Must be a NUL-terminated + * C string. + * \param[in] src Pointer to the source string, which will be appended. Must + * be a NUL-terminated C string. + * \param[in] dsize The size of the destination buffer. + * + * \return The total length of the string src, which was attempted to be + * created (the initial length of dst plus the length of src, not + * including the terminating NUL character). If the return value + * is >= dsize, truncation occurred. + */ +size_t G_strlcat(char *dst, const char *src, size_t dsize) +{ +#ifdef HAVE_STRLCAT + return strlcat(dst, src, dsize); +#else + return G__strlcat(dst, src, dsize); +#endif +} + +static size_t G__strlcat(char *restrict dst, const char *restrict src, + size_t dsize) +{ + const char *odst = dst; + const char *osrc = src; + size_t n = dsize; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end. */ + while (n-- != 0 && *dst != '\0') + dst++; + dlen = dst - odst; + n = dsize - dlen; + + if (n-- == 0) + return (dlen + strlen(src)); + while (*src != '\0') { + if (n != 0) { + *dst++ = *src; + n--; + } + src++; + } + *dst = '\0'; + + return (dlen + (src - osrc)); /* count does not include NUL */ +} diff --git a/lib/gis/strlcpy.c b/lib/gis/strlcpy.c index 5c0601391f5..a2d6e8918e7 100644 --- a/lib/gis/strlcpy.c +++ b/lib/gis/strlcpy.c @@ -22,6 +22,9 @@ #include +static size_t G__strlcpy(char *restrict dst, const char *restrict src, + size_t dsize); + /** * \brief Safe string copy function. * @@ -46,12 +49,18 @@ * \warning The src string must be a valid NUL-terminated C string. Passing an * unterminated string may result in buffer overrun. */ - -size_t G_strlcpy(char *restrict dst, const char *restrict src, size_t dsize) +size_t G_strlcpy(char *dst, const char *src, size_t dsize) { #ifdef HAVE_STRLCPY return strlcpy(dst, src, dsize); #else + return G__strlcpy(dst, src, dsize); +#endif +} + +static size_t G__strlcpy(char *restrict dst, const char *restrict src, + size_t dsize) +{ const char *osrc = src; size_t nleft = dsize; @@ -72,5 +81,4 @@ size_t G_strlcpy(char *restrict dst, const char *restrict src, size_t dsize) } return (src - osrc - 1); /* count does not include NUL */ -#endif } diff --git a/lib/gis/testsuite/test_gis_lib_getl.py b/lib/gis/testsuite/test_gis_lib_getl.py new file mode 100644 index 00000000000..72e8992ad39 --- /dev/null +++ b/lib/gis/testsuite/test_gis_lib_getl.py @@ -0,0 +1,80 @@ +"""Test of gis library line reading functions + +@author Vaclav Petras +""" + +import ctypes +import pathlib +import unittest + +import grass.lib.gis as libgis +from grass.gunittest.case import TestCase +from grass.gunittest.main import test + + +class TestNewlinesWithGetlFunctions(TestCase): + """Test C functions G_getl() and G_getl2() from gis library""" + + @classmethod + def setUpClass(cls): + cls.libc = ctypes.cdll.LoadLibrary(ctypes.util.find_library("c")) + cls.libc.fopen.restype = ctypes.POINTER(libgis.FILE) + cls.libc.fopen.argtypes = [ctypes.c_char_p, ctypes.c_char_p] + cls.file_path = pathlib.Path("test.txt") + + def tearDown(self): + self.file_path.unlink() + + def read_lines_and_assert(self, get_line_function, newline): + """Write and read lines and then assert they are as expected""" + lines = ["Line 1", "Line 2", "Line 3"] + with open(self.file_path, mode="w", newline=newline) as stream: + for line in lines: + # Python text newline here. + # The specific newline is added by the stream. + stream.write(f"{line}\n") + + file_ptr = self.libc.fopen(str(self.file_path).encode("utf-8"), b"r") + if not file_ptr: + raise FileNotFoundError(f"Could not open file: {self.file_path}") + + try: + buffer_size = 50 + buffer = ctypes.create_string_buffer(buffer_size) + + for line in lines: + get_line_function(buffer, ctypes.sizeof(buffer), file_ptr) + result = buffer.value.decode("utf-8") if buffer else None + self.assertEqual(line, result) + finally: + self.libc.fclose(file_ptr) + + def test_getl_lf(self): + r"""Check G_getl() with LF (\n)""" + self.read_lines_and_assert(libgis.G_getl, "\n") + + @unittest.expectedFailure + def test_getl_cr(self): + r"""Check G_getl() with CR (\r)""" + self.read_lines_and_assert(libgis.G_getl, "\r") + + def test_getl_crlf(self): + r"""Check G_getl() with CRLF (\r\n)""" + self.read_lines_and_assert(libgis.G_getl, "\r\n") + + def test_getl2_lf(self): + r"""Check G_getl2() with LF (\n)""" + self.read_lines_and_assert(libgis.G_getl2, "\n") + + @unittest.expectedFailure + def test_getl2_cr(self): + r"""Check G_getl2() with CR (\r)""" + self.read_lines_and_assert(libgis.G_getl2, "\r") + + def test_getl2_crlf(self): + r"""Check G_getl2() with CRLF (\r\n)""" + self.read_lines_and_assert(libgis.G_getl2, "\r\n") + + +if __name__ == "__main__": + test() diff --git a/lib/gis/testsuite/test_parser_json.py b/lib/gis/testsuite/test_parser_json.py index 918fb453d04..74ff9673c7f 100644 --- a/lib/gis/testsuite/test_parser_json.py +++ b/lib/gis/testsuite/test_parser_json.py @@ -10,11 +10,14 @@ import subprocess from grass.gunittest.case import TestCase +from grass.gunittest.utils import xfail_windows from grass.script import decode import json class TestParserJson(TestCase): + + @xfail_windows def test_r_slope_aspect_json(self): args = [ "r.slope.aspect", @@ -58,6 +61,7 @@ def test_r_slope_aspect_json(self): self.assertEqual(json_code["inputs"], inputs) self.assertEqual(json_code["outputs"], outputs) + @xfail_windows def test_v_out_ascii(self): args = [ "v.out.ascii", @@ -91,6 +95,7 @@ def test_v_out_ascii(self): self.assertEqual(json_code["inputs"], inputs) self.assertEqual(json_code["outputs"], outputs) + @xfail_windows def test_v_info(self): args = ["v.info", "map=hospitals@PERMANENT", "-c", "--json"] diff --git a/lib/gmath/ATLAS_wrapper_blas_level_1.c b/lib/gmath/CBLAS_wrapper_blas_level_1.c similarity index 80% rename from lib/gmath/ATLAS_wrapper_blas_level_1.c rename to lib/gmath/CBLAS_wrapper_blas_level_1.c index 24390a61dfb..556f1654b46 100644 --- a/lib/gmath/ATLAS_wrapper_blas_level_1.c +++ b/lib/gmath/CBLAS_wrapper_blas_level_1.c @@ -21,15 +21,19 @@ #include #include -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) +#if defined(HAVE_CBLAS_ATLAS_H) +#include +#else #include #endif +#endif /* HAVE_LIBBLAS */ /*! * \brief Compute the dot product of vector x and y - * using the ATLAS routine cblas_ddot + * using the CBLAS routine cblas_ddot * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_x_dot_y, the OpenMP multi threaded * grass implementatiom * @@ -41,7 +45,7 @@ * */ double G_math_ddot(double *x, double *y, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_ddot(rows, x, 1, y, 1); #else double val; @@ -53,9 +57,9 @@ double G_math_ddot(double *x, double *y, int rows) /*! * \brief Compute the dot product of vector x and y - * using the ATLAS routine cblas_sdsdot + * using the CBLAS routine cblas_sdsdot * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_x_dot_y, the OpenMP multi threaded * grass implementatiom * @@ -68,7 +72,7 @@ double G_math_ddot(double *x, double *y, int rows) * */ float G_math_sdsdot(float *x, float *y, float a, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_sdsdot(rows, a, x, 1, y, 1); #else float val; @@ -80,9 +84,9 @@ float G_math_sdsdot(float *x, float *y, float a, int rows) /*! * \brief Compute the euclidean norm of vector x - * using the ATLAS routine cblas_dnrm2 + * using the CBLAS routine cblas_dnrm2 * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_d_euclid_norm, the OpenMP multi threaded * grass implementatiom * @@ -93,7 +97,7 @@ float G_math_sdsdot(float *x, float *y, float a, int rows) * */ double G_math_dnrm2(double *x, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_dnrm2(rows, x, 1); #else double val; @@ -105,9 +109,9 @@ double G_math_dnrm2(double *x, int rows) /*! * \brief Compute the absolute sum norm of vector x - * using the ATLAS routine cblas_dasum + * using the CBLAS routine cblas_dasum * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_d_asum_norm, the OpenMP multi threaded * grass implementatiom * @@ -118,7 +122,7 @@ double G_math_dnrm2(double *x, int rows) * */ double G_math_dasum(double *x, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_dasum(rows, x, 1); #else double val; @@ -130,9 +134,9 @@ double G_math_dasum(double *x, int rows) /*! * \brief Compute the maximum norm of vector x - * using the ATLAS routine cblas_idamax + * using the CBLAS routine cblas_idamax * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_d_max_norm, the OpenMP multi threaded * grass implementatiom * @@ -143,7 +147,7 @@ double G_math_dasum(double *x, int rows) * */ double G_math_idamax(double *x, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_idamax(rows, x, 1); #else double val; @@ -155,9 +159,9 @@ double G_math_idamax(double *x, int rows) /*! * \brief Scale vector x with scalar a - * using the ATLAS routine cblas_dscal + * using the CBLAS routine cblas_dscal * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_d_ax_by, the OpenMP multi threaded * grass implementatiom * @@ -169,7 +173,7 @@ double G_math_idamax(double *x, int rows) * */ void G_math_dscal(double *x, double a, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) cblas_dscal(rows, a, x, 1); #else G_math_d_ax_by(x, x, x, a, 0.0, rows); @@ -181,7 +185,7 @@ void G_math_dscal(double *x, double a, int rows) /*! * \brief Copy vector x to vector y * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_d_copy * * \param x (double *) @@ -192,7 +196,7 @@ void G_math_dscal(double *x, double a, int rows) * */ void G_math_dcopy(double *x, double *y, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) cblas_dcopy(rows, x, 1, y, 1); #else G_math_d_copy(x, y, rows); @@ -206,7 +210,7 @@ void G_math_dcopy(double *x, double *y, int rows) * * \f[ {\bf z} = a{\bf x} + {\bf y} \f] * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_d_ax_by, the * grass implementatiom @@ -220,7 +224,7 @@ void G_math_dcopy(double *x, double *y, int rows) * */ void G_math_daxpy(double *x, double *y, double a, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) cblas_daxpy(rows, a, x, 1, y, 1); #else G_math_d_ax_by(x, y, y, a, 1.0, rows); @@ -231,15 +235,15 @@ void G_math_daxpy(double *x, double *y, double a, int rows) /****************************************************************** */ -/********* F L O A T / S I N G L E P E P R E C I S I O N ******** */ +/********* F L O A T / S I N G L E P R E C I S I O N ********* */ /****************************************************************** */ /*! * \brief Compute the dot product of vector x and y - * using the ATLAS routine cblas_sdot + * using the CBLAS routine cblas_sdot * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_x_dot_y, the OpenMP multi threaded * grass implementatiom * @@ -251,7 +255,7 @@ void G_math_daxpy(double *x, double *y, double a, int rows) * */ float G_math_sdot(float *x, float *y, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_sdot(rows, x, 1, y, 1); #else float val; @@ -263,9 +267,9 @@ float G_math_sdot(float *x, float *y, int rows) /*! * \brief Compute the euclidean norm of vector x - * using the ATLAS routine cblas_dnrm2 + * using the CBLAS routine cblas_dnrm2 * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_euclid_norm, the OpenMP multi threaded * grass implementatiom * @@ -276,7 +280,7 @@ float G_math_sdot(float *x, float *y, int rows) * */ float G_math_snrm2(float *x, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_snrm2(rows, x, 1); #else float val; @@ -288,9 +292,9 @@ float G_math_snrm2(float *x, int rows) /*! * \brief Compute the absolute sum norm of vector x - * using the ATLAS routine cblas_dasum + * using the CBLAS routine cblas_dasum * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_asum_norm, the OpenMP multi threaded * grass implementatiom * @@ -301,7 +305,7 @@ float G_math_snrm2(float *x, int rows) * */ float G_math_sasum(float *x, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_sasum(rows, x, 1); #else float val; @@ -313,9 +317,9 @@ float G_math_sasum(float *x, int rows) /*! * \brief Compute the maximum norm of vector x - * using the ATLAS routine cblas_idamax + * using the CBLAS routine cblas_idamax * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_max_norm, the OpenMP multi threaded * grass implementatiom * @@ -326,7 +330,7 @@ float G_math_sasum(float *x, int rows) * */ float G_math_isamax(float *x, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) return cblas_isamax(rows, x, 1); #else float val; @@ -338,9 +342,9 @@ float G_math_isamax(float *x, int rows) /*! * \brief Scale vector x with scalar a - * using the ATLAS routine cblas_dscal + * using the CBLAS routine cblas_dscal * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_ax_by, the OpenMP multi threaded * grass implementatiom * @@ -352,7 +356,7 @@ float G_math_isamax(float *x, int rows) * */ void G_math_sscal(float *x, float a, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) cblas_sscal(rows, a, x, 1); #else G_math_f_ax_by(x, x, x, a, 0.0, rows); @@ -364,7 +368,7 @@ void G_math_sscal(float *x, float a, int rows) /*! * \brief Copy vector x to vector y * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_copy, the * grass implementatiom * @@ -376,7 +380,7 @@ void G_math_sscal(float *x, float a, int rows) * */ void G_math_scopy(float *x, float *y, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) cblas_scopy(rows, x, 1, y, 1); #else G_math_f_copy(x, y, rows); @@ -390,7 +394,7 @@ void G_math_scopy(float *x, float *y, int rows) * * \f[ {\bf z} = a{\bf x} + {\bf y} \f] * - * If grass was not compiled with ATLAS support + * If grass was not compiled with CBLAS support * it will call #G_math_f_ax_by, the * grass implementatiom @@ -404,7 +408,7 @@ void G_math_scopy(float *x, float *y, int rows) * */ void G_math_saxpy(float *x, float *y, float a, int rows) { -#if defined(HAVE_ATLAS) +#if defined(HAVE_LIBBLAS) cblas_saxpy(rows, a, x, 1, y, 1); #else G_math_f_ax_by(x, y, y, a, 1.0, rows); diff --git a/lib/gmath/Makefile b/lib/gmath/Makefile index 0fd6e14f55d..2927d32dec6 100644 --- a/lib/gmath/Makefile +++ b/lib/gmath/Makefile @@ -1,7 +1,7 @@ MODULE_TOPDIR = ../.. EXTRA_LIBS = $(OPENMP_LIBPATH) $(OPENMP_LIB) -EXTRA_INC = $(OPENMP_INCPATH) +EXTRA_INC = $(OPENMP_INCPATH) $(BLASINC) $(LAPACKINC) EXTRA_CFLAGS = $(FFTWINC) $(OPENMP_CFLAGS) LIB = GMATH diff --git a/lib/gmath/gmathlib.dox b/lib/gmath/gmathlib.dox index a404595de04..77b516b8ebd 100644 --- a/lib/gmath/gmathlib.dox +++ b/lib/gmath/gmathlib.dox @@ -464,8 +464,8 @@ implemented.

    Getting BLAS/LAPACK (one package) if not already provided by the system: -
    http://www.netlib.org/lapack/ -
    http://netlib.bell-labs.com/netlib/master/readme.html +
    https://www.netlib.org/lapack/ +
    https://netlib.bell-labs.com/netlib/master/readme.html

    Pre-compiled binaries of LAPACK/BLAS are provided on many Linux diff --git a/lib/gmath/la.c b/lib/gmath/la.c index 5c0e59cb862..5696a174bda 100644 --- a/lib/gmath/la.c +++ b/lib/gmath/la.c @@ -22,14 +22,21 @@ ******************************************************************************/ -#include /* needed here for ifdef/else */ +#include + +#if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) + +#include +#include #include #include -#include -#include - -#if defined(HAVE_LIBLAPACK) && defined(HAVE_LIBBLAS) +#include +#if defined(HAVE_CBLAS_ATLAS_H) +#include +#else +#include +#endif // HAVE_CBLAS_ATLAS_H #include #include @@ -66,7 +73,7 @@ mat_struct *G_matrix_init(int rows, int cols, int ldim) tmp_arry->type = MATRIX_; tmp_arry->v_indx = -1; - tmp_arry->vals = (doublereal *)G_calloc(ldim * cols, sizeof(doublereal)); + tmp_arry->vals = (double *)G_calloc(ldim * cols, sizeof(double)); tmp_arry->is_init = 1; return tmp_arry; @@ -86,7 +93,7 @@ int G_matrix_zero(mat_struct *A) if (!A->vals) return 0; - memset(A->vals, 0, (A->ldim * A->cols) * sizeof(doublereal)); + memset(A->vals, 0, (A->ldim * A->cols) * sizeof(double)); return 1; } @@ -119,7 +126,7 @@ int G_matrix_set(mat_struct *A, int rows, int cols, int ldim) A->type = MATRIX_; A->v_indx = -1; - A->vals = (doublereal *)G_calloc(ldim * cols, sizeof(doublereal)); + A->vals = (double *)G_calloc(ldim * cols, sizeof(double)); A->is_init = 1; return 0; @@ -150,7 +157,8 @@ mat_struct *G_matrix_copy(const mat_struct *A) return NULL; } - memcpy(&B->vals[0], &A->vals[0], A->cols * A->ldim * sizeof(doublereal)); + memcpy(&B->vals[0], &A->vals[0], + (size_t)A->cols * A->ldim * sizeof(double)); return B; } @@ -225,7 +233,7 @@ mat_struct *G_matrix_scalar_mul(double scalar, mat_struct *matrix, for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { - doublereal value = scalar * G_matrix_get_element(matrix, i, j); + double value = scalar * G_matrix_get_element(matrix, i, j); G_matrix_set_element(out, i, j, value); } @@ -328,8 +336,6 @@ mat_struct *G__matrix_add(mat_struct *mt1, mat_struct *mt2, const double c1, return mt3; } -#if defined(HAVE_LIBBLAS) - /*! * \fn mat_struct *G_matrix_product (mat_struct *mt1, mat_struct *mt2) * @@ -346,9 +352,8 @@ mat_struct *G__matrix_add(mat_struct *mt1, mat_struct *mt2, const double c1, mat_struct *G_matrix_product(mat_struct *mt1, mat_struct *mt2) { mat_struct *mt3; - doublereal unity = 1, zero = 0; - integer rows, cols, interdim, lda, ldb; - integer1 no_trans = 'n'; + double unity = 1., zero = 0.; + int rows, cols, interdim, lda, ldb; if (!((mt1->is_init) || (mt2->is_init))) { G_warning(_("One or both input matrices uninitialised")); @@ -367,23 +372,19 @@ mat_struct *G_matrix_product(mat_struct *mt1, mat_struct *mt2) /* Call the driver */ - rows = (integer)mt1->rows; - interdim = (integer)mt1->cols; - cols = (integer)mt2->cols; + rows = (int)mt1->rows; + interdim = (int)mt1->cols; + cols = (int)mt2->cols; - lda = (integer)mt1->ldim; - ldb = (integer)mt2->ldim; + lda = (int)mt1->ldim; + ldb = (int)mt2->ldim; - f77_dgemm(&no_trans, &no_trans, &rows, &cols, &interdim, &unity, mt1->vals, - &lda, mt2->vals, &ldb, &zero, mt3->vals, &lda); + cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, rows, cols, interdim, + unity, mt1->vals, lda, mt2->vals, ldb, zero, mt3->vals, lda); return mt3; } -#else /* defined(HAVE_LIBBLAS) */ -#warning G_matrix_product() not compiled; requires BLAS library -#endif /* defined(HAVE_LIBBLAS) */ - /*! * \fn mat_struct *G_matrix_transpose (mat_struct *mt) * @@ -401,7 +402,7 @@ mat_struct *G_matrix_transpose(mat_struct *mt) { mat_struct *mt1; int ldim, ldo; - doublereal *dbo, *dbt, *dbx, *dby; + double *dbo, *dbt, *dbx, *dby; int cnt, cnt2; /* Word align the workspace blocks */ @@ -438,8 +439,6 @@ mat_struct *G_matrix_transpose(mat_struct *mt) return mt1; } -#if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) - /*! * \fn int G_matrix_LU_solve (const mat_struct *mt1, mat_struct **xmat0, * const mat_struct *bmat, mat_type mtype) @@ -509,20 +508,20 @@ int G_matrix_LU_solve(const mat_struct *mt1, mat_struct **xmat0, switch (mtype) { case NONSYM: { - integer *perm, res_info; - integer num_eqns, nrhs, lda, ldb; + int *perm, res_info; + int num_eqns, nrhs, lda, ldb; - perm = (integer *)G_malloc(wmat->rows * sizeof(integer)); + perm = (int *)G_malloc(wmat->rows * sizeof(int)); /* Set fields to pass to fortran routine */ - num_eqns = (integer)mt1->rows; - nrhs = (integer)wmat->cols; - lda = (integer)mt1->ldim; - ldb = (integer)wmat->ldim; + num_eqns = (int)mt1->rows; + nrhs = (int)wmat->cols; + lda = (int)mt1->ldim; + ldb = (int)wmat->ldim; /* Call LA driver */ - f77_dgesv(&num_eqns, &nrhs, mtx->vals, &lda, perm, wmat->vals, &ldb, - &res_info); + res_info = LAPACKE_dgesv(LAPACK_COL_MAJOR, num_eqns, nrhs, mtx->vals, + lda, perm, wmat->vals, ldb); /* Copy the results from the modified data matrix, taking account of pivot permutations ??? @@ -545,7 +544,7 @@ int G_matrix_LU_solve(const mat_struct *mt1, mat_struct **xmat0, */ memcpy(xmat->vals, wmat->vals, - wmat->cols * wmat->ldim * sizeof(doublereal)); + (size_t)wmat->cols * wmat->ldim * sizeof(double)); /* Free temp arrays */ G_free(perm); @@ -574,12 +573,6 @@ int G_matrix_LU_solve(const mat_struct *mt1, mat_struct **xmat0, return 0; } -#else /* defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) */ -#warning G_matrix_LU_solve() not compiled; requires BLAS and LAPACK libraries -#endif /* defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) */ - -#if defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) - /*! * \fn mat_struct *G_matrix_inverse (mat_struct *mt) * @@ -635,10 +628,6 @@ mat_struct *G_matrix_inverse(mat_struct *mt) } } -#else /* defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) */ -#warning G_matrix_inverse() not compiled; requires BLAS and LAPACK libraries -#endif /* defined(HAVE_LIBBLAS) && defined(HAVE_LIBLAPACK) */ - /*! * \fn void G_matrix_free (mat_struct *mt) * @@ -672,14 +661,14 @@ void G_matrix_free(mat_struct *mt) void G_matrix_print(mat_struct *mt) { int i, j; - char buf[64], numbuf[64]; + char buf[2048], numbuf[64]; for (i = 0; i < mt->rows; i++) { - strcpy(buf, ""); + G_strlcpy(buf, "", sizeof(buf)); for (j = 0; j < mt->cols; j++) { - - sprintf(numbuf, "%14.6f", G_matrix_get_element(mt, i, j)); + snprintf(numbuf, sizeof(numbuf), "%14.6f", + G_matrix_get_element(mt, i, j)); strcat(buf, numbuf); if (j < mt->cols - 1) strcat(buf, ", "); @@ -720,7 +709,7 @@ int G_matrix_set_element(mat_struct *mt, int rowval, int colval, double val) return -1; } - mt->vals[rowval + colval * mt->ldim] = (doublereal)val; + mt->vals[rowval + colval * mt->ldim] = (double)val; return 0; } @@ -918,7 +907,7 @@ int G_matvect_retrieve_matrix(vec_struct *vc) vec_struct *G_matvect_product(mat_struct *A, vec_struct *b, vec_struct *out) { unsigned int i, m, n, j; - register doublereal sum; + register double sum; /* G_message("A=%d,%d,%d", A->cols, A->rows, A->ldim); */ /* G_message("B=%d,%d,%d", b->cols, b->rows, b->ldim); */ @@ -997,8 +986,7 @@ vec_struct *G_vector_init(int cells, int ldim, vtype vt) tmp_arry->v_indx = 0; - tmp_arry->vals = - (doublereal *)G_calloc(ldim * tmp_arry->cols, sizeof(doublereal)); + tmp_arry->vals = (double *)G_calloc(ldim * tmp_arry->cols, sizeof(double)); tmp_arry->is_init = 1; return tmp_arry; @@ -1144,14 +1132,12 @@ int G_vector_set(vec_struct *A, int cells, int ldim, vtype vt, int vindx) else A->v_indx = vindx; - A->vals = (doublereal *)G_calloc(ldim * A->cols, sizeof(doublereal)); + A->vals = (double *)G_calloc(ldim * A->cols, sizeof(double)); A->is_init = 1; return 0; } -#if defined(HAVE_LIBBLAS) - /*! * \fn double G_vector_norm_euclid (vec_struct *vc) * @@ -1166,22 +1152,22 @@ int G_vector_set(vec_struct *A, int cells, int ldim, vtype vt, int vindx) double G_vector_norm_euclid(vec_struct *vc) { - integer incr, Nval; - doublereal *startpt; + int incr, Nval; + double *startpt; if (!vc->is_init) G_fatal_error(_("Matrix is not initialised")); if (vc->type == ROWVEC_) { - Nval = (integer)vc->cols; - incr = (integer)vc->ldim; + Nval = (int)vc->cols; + incr = (int)vc->ldim; if (vc->v_indx < 0) startpt = vc->vals; else startpt = vc->vals + vc->v_indx; } else { - Nval = (integer)vc->rows; + Nval = (int)vc->rows; incr = 1; if (vc->v_indx < 0) startpt = vc->vals; @@ -1190,13 +1176,9 @@ double G_vector_norm_euclid(vec_struct *vc) } /* Call the BLAS routine dnrm2_() */ - return (double)f77_dnrm2(&Nval, startpt, &incr); + return cblas_dnrm2(Nval, startpt, incr); } -#else /* defined(HAVE_LIBBLAS) */ -#warning G_vector_norm_euclid() not compiled; requires BLAS library -#endif /* defined(HAVE_LIBBLAS) */ - /*! * \fn double G_vector_norm_maxval (vec_struct *vc, int vflag) * @@ -1216,7 +1198,7 @@ double G_vector_norm_euclid(vec_struct *vc) double G_vector_norm_maxval(vec_struct *vc, int vflag) { - doublereal xval, *startpt, *curpt; + double xval, *startpt, *curpt; double cellval; int ncells, incr; @@ -1224,15 +1206,15 @@ double G_vector_norm_maxval(vec_struct *vc, int vflag) G_fatal_error(_("Matrix is not initialised")); if (vc->type == ROWVEC_) { - ncells = (integer)vc->cols; - incr = (integer)vc->ldim; + ncells = (int)vc->cols; + incr = (int)vc->ldim; if (vc->v_indx < 0) startpt = vc->vals; else startpt = vc->vals + vc->v_indx; } else { - ncells = (integer)vc->rows; + ncells = (int)vc->rows; incr = 1; if (vc->v_indx < 0) startpt = vc->vals; @@ -1360,9 +1342,6 @@ vec_struct *G_vector_product(vec_struct *v1, vec_struct *v2, vec_struct *out) return NULL; } -#if defined(HAVE_LAPACK) && defined(HAVE_LIBBLAS) - f77_dhad(v1->cols, 1.0, v1->vals, 1, v2->vals, 1, 0.0, out->vals, 1.0); -#else idx1 = (v1->v_indx > 0) ? v1->v_indx : 0; idx2 = (v2->v_indx > 0) ? v2->v_indx : 0; idx0 = (out->v_indx > 0) ? out->v_indx : 0; @@ -1379,7 +1358,6 @@ vec_struct *G_vector_product(vec_struct *v1, vec_struct *v2, vec_struct *out) G_matrix_get_element(v1, i, idx1) * G_matrix_get_element(v2, i, idx2)); } -#endif return out; } @@ -1399,7 +1377,7 @@ vec_struct *G_vector_copy(const vec_struct *vc1, int comp_flag) { vec_struct *tmp_arry; int incr1, incr2; - doublereal *startpt1, *startpt2, *curpt1, *curpt2; + double *startpt1, *startpt2, *curpt1, *curpt2; int cnt; if (!vc1->is_init) { @@ -1441,8 +1419,8 @@ vec_struct *G_vector_copy(const vec_struct *vc1, int comp_flag) return NULL; } - tmp_arry->vals = (doublereal *)G_calloc(tmp_arry->ldim * tmp_arry->cols, - sizeof(doublereal)); + tmp_arry->vals = + (double *)G_calloc(tmp_arry->ldim * tmp_arry->cols, sizeof(double)); if (comp_flag == DO_COMPACT) { if (tmp_arry->type == ROWVEC_) { startpt1 = tmp_arry->vals; @@ -1482,7 +1460,7 @@ vec_struct *G_vector_copy(const vec_struct *vc1, int comp_flag) } while (cnt > 0) { - memcpy(curpt1, curpt2, sizeof(doublereal)); + memcpy(curpt1, curpt2, sizeof(double)); curpt1 += incr1; curpt2 += incr2; cnt--; @@ -1633,7 +1611,7 @@ int G_matrix_eigen_sort(vec_struct *d, mat_struct *m) } /* sort the combined matrix */ - qsort(tmp.vals, tmp.cols, tmp.ldim * sizeof(doublereal), egcmp); + qsort(tmp.vals, tmp.cols, tmp.ldim * sizeof(double), egcmp); /* split tmp into m and d */ for (i = 0; i < m->cols; i++) { @@ -1652,8 +1630,8 @@ int G_matrix_eigen_sort(vec_struct *d, mat_struct *m) static int egcmp(const void *pa, const void *pb) { - double a = *(doublereal *const)pa; - double b = *(doublereal *const)pb; + double a = *(double *const)pa; + double b = *(double *const)pb; if (a > b) return 1; @@ -1663,4 +1641,6 @@ static int egcmp(const void *pa, const void *pb) return 0; } -#endif /* HAVE_BLAS && HAVE_LAPACK && HAVE_G2C */ +#endif // HAVE_LIBLAPACK HAVE_LIBBLAS + +typedef int suppress_empty_translation_unit_compiler_warning; diff --git a/lib/imagery/testsuite/test_imagery_sigfile.py b/lib/imagery/testsuite/test_imagery_sigfile.py index 104cd5a59b4..731ef047063 100644 --- a/lib/imagery/testsuite/test_imagery_sigfile.py +++ b/lib/imagery/testsuite/test_imagery_sigfile.py @@ -9,10 +9,10 @@ for details """ -import os import stat import ctypes import shutil +from pathlib import Path from grass.gunittest.case import TestCase from grass.gunittest.main import test @@ -80,7 +80,7 @@ def test_roundtrip_signature_v1_norgb_one_label(self): # Write signatures to file p_new_sigfile = I_fopen_signature_file_new(self.sig_name) - sig_stat = os.stat(f"{self.sig_dir}/sig") + sig_stat = Path(self.sig_dir, "sig").stat() self.assertTrue(stat.S_ISREG(sig_stat.st_mode)) I_write_signatures(p_new_sigfile, ctypes.byref(So)) self.libc.fclose(p_new_sigfile) @@ -136,7 +136,7 @@ def test_broken_signature_v1_norgb(self): # Write signatures to file p_new_sigfile = I_fopen_signature_file_new(self.sig_name) - sig_stat = os.stat(f"{self.sig_dir}/sig") + sig_stat = Path(self.sig_dir, "sig").stat() self.assertTrue(stat.S_ISREG(sig_stat.st_mode)) I_write_signatures(p_new_sigfile, ctypes.byref(So)) self.libc.fclose(p_new_sigfile) @@ -188,7 +188,7 @@ def test_roundtrip_signature_v1_norgb_two_labelss(self): # Write signatures to file p_new_sigfile = I_fopen_signature_file_new(self.sig_name) - sig_stat = os.stat(f"{self.sig_dir}/sig") + sig_stat = Path(self.sig_dir, "sig").stat() self.assertTrue(stat.S_ISREG(sig_stat.st_mode)) I_write_signatures(p_new_sigfile, ctypes.byref(So)) self.libc.fclose(p_new_sigfile) @@ -277,7 +277,7 @@ def test_roundtrip_signature_v2_norgb_two_labels_oclass(self): # Write signatures to file p_new_sigfile = I_fopen_signature_file_new(self.sig_name) - sig_stat = os.stat(f"{self.sig_dir}/sig") + sig_stat = Path(self.sig_dir, "sig").stat() self.assertTrue(stat.S_ISREG(sig_stat.st_mode)) I_write_signatures(p_new_sigfile, ctypes.byref(So)) self.libc.fclose(p_new_sigfile) @@ -349,9 +349,12 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): cls.del_temp_region() - cls.runModule("g.remove", flags="f", type="raster", name=cls.map1) - cls.runModule("g.remove", flags="f", type="raster", name=cls.map2) - cls.runModule("g.remove", flags="f", type="raster", name=cls.map3) + cls.runModule( + "g.remove", + flags="f", + type="raster", + name=(cls.map1, cls.map2, cls.map3), + ) def test_symmetric_complete_difference(self): # Prepare imagery group reference struct diff --git a/lib/imagery/testsuite/test_imagery_signature_management.py b/lib/imagery/testsuite/test_imagery_signature_management.py index 7b1dc8bdc57..42c55c45123 100644 --- a/lib/imagery/testsuite/test_imagery_signature_management.py +++ b/lib/imagery/testsuite/test_imagery_signature_management.py @@ -15,6 +15,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows from grass.script.core import tempname import grass.script as gs @@ -44,16 +45,19 @@ class GetSignaturesDirTestCase(TestCase): + @xfail_windows def test_get_sig(self): cdir = ctypes.create_string_buffer(GNAME_MAX) I_get_signatures_dir(cdir, I_SIGFILE_TYPE_SIG) self.assertEqual(utils.decode(cdir.value), f"signatures{HOST_DIRSEP}sig") + @xfail_windows def test_get_sigset(self): cdir = ctypes.create_string_buffer(GNAME_MAX) I_get_signatures_dir(cdir, I_SIGFILE_TYPE_SIGSET) self.assertEqual(utils.decode(cdir.value), f"signatures{HOST_DIRSEP}sigset") + @xfail_windows def test_get_libsvm(self): elem = ctypes.create_string_buffer(GNAME_MAX) I_get_signatures_dir(elem, I_SIGFILE_TYPE_LIBSVM) diff --git a/lib/imagery/testsuite/test_imagery_sigsetfile.py b/lib/imagery/testsuite/test_imagery_sigsetfile.py index b8bcb566520..80be7c0d3a5 100644 --- a/lib/imagery/testsuite/test_imagery_sigsetfile.py +++ b/lib/imagery/testsuite/test_imagery_sigsetfile.py @@ -9,10 +9,10 @@ for details """ -import os import stat import ctypes import shutil +from pathlib import Path from grass.gunittest.case import TestCase from grass.gunittest.main import test @@ -84,7 +84,7 @@ def test_roundtrip_sigset_v1_one_label(self): # Write signatures to file p_new_sigfile = I_fopen_sigset_file_new(self.sig_name) - sig_stat = os.stat(f"{self.sig_dir}/sig") + sig_stat = Path(self.sig_dir, "sig").stat() self.assertTrue(stat.S_ISREG(sig_stat.st_mode)) I_WriteSigSet(p_new_sigfile, ctypes.byref(So)) self.libc.fclose(p_new_sigfile) @@ -139,7 +139,7 @@ def test_read_fail_sigset_v1_one_label(self): # Write signatures to file p_new_sigfile = I_fopen_sigset_file_new(self.sig_name) - sig_stat = os.stat(f"{self.sig_dir}/sig") + sig_stat = Path(self.sig_dir, "sig").stat() self.assertTrue(stat.S_ISREG(sig_stat.st_mode)) I_WriteSigSet(p_new_sigfile, ctypes.byref(So)) self.libc.fclose(p_new_sigfile) @@ -183,7 +183,7 @@ def test_roundtrip_sigset_v1_two_labels(self): # Write signatures to file p_new_sigfile = I_fopen_sigset_file_new(self.sig_name) - sig_stat = os.stat(f"{self.sig_dir}/sig") + sig_stat = Path(self.sig_dir, "sig").stat() self.assertTrue(stat.S_ISREG(sig_stat.st_mode)) I_WriteSigSet(p_new_sigfile, ctypes.byref(So)) self.libc.fclose(p_new_sigfile) @@ -242,9 +242,12 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): cls.del_temp_region() - cls.runModule("g.remove", flags="f", type="raster", name=cls.map1) - cls.runModule("g.remove", flags="f", type="raster", name=cls.map2) - cls.runModule("g.remove", flags="f", type="raster", name=cls.map3) + cls.runModule( + "g.remove", + flags="f", + type="raster", + name=(cls.map1, cls.map2, cls.map3), + ) def test_symmetric_complete_difference(self): # Prepare imagery group reference struct diff --git a/lib/init/grass.py b/lib/init/grass.py index 82c1ee4a812..505d48dadae 100755 --- a/lib/init/grass.py +++ b/lib/init/grass.py @@ -125,7 +125,7 @@ def clean_env(): write_gisrc(env_new, gisrc) -def is_debug(): +def is_debug() -> bool: """Returns True if we are in debug mode For debug messages use ``debug()``. @@ -133,13 +133,8 @@ def is_debug(): global _DEBUG if _DEBUG is not None: return _DEBUG - _DEBUG = os.getenv("GRASS_DEBUG") # translate to bool (no or empty variable means false) - if _DEBUG: - _DEBUG = True - else: - _DEBUG = False - return _DEBUG + return bool(os.getenv("GRASS_DEBUG")) def debug(msg): @@ -400,7 +395,7 @@ def create_grass_config_dir(): os.makedirs(directory) except OSError as e: # Can happen as a race condition - if not e.errno == errno.EEXIST or not os.path.isdir(directory): + if e.errno != errno.EEXIST or not os.path.isdir(directory): fatal( _( "Failed to create configuration directory '{}' with error: {}" @@ -484,7 +479,7 @@ def create_gisrc(tmpdir, gisrcrc): if "UNKNOWN" in s: try_remove(gisrcrc) s = None - except: + except Exception: s = None # Copy the global grassrc file to the session grassrc file @@ -496,7 +491,7 @@ def create_gisrc(tmpdir, gisrcrc): def read_gisrc(filename): kv = {} try: - f = open(filename, "r") + f = open(filename) except OSError: return kv @@ -522,7 +517,7 @@ def write_gisrcrc(gisrcrc, gisrc, skip_variable=None): """Reads gisrc file and write to gisrcrc""" debug("Reading %s" % gisrc) number = 0 - with open(gisrc, "r") as f: + with open(gisrc) as f: lines = f.readlines() for line in lines: if skip_variable in line: @@ -535,7 +530,7 @@ def write_gisrcrc(gisrcrc, gisrc, skip_variable=None): def read_env_file(path): kv = {} - f = open(path, "r") + f = open(path) for line in f: k, v = line.split(":", 1) kv[k.strip()] = v.strip() @@ -553,10 +548,7 @@ def write_gisrc(kv, filename, append=False): def add_mapset_to_gisrc(gisrc, grassdb, location, mapset): - if os.access(gisrc, os.R_OK): - kv = read_gisrc(gisrc) - else: - kv = {} + kv = read_gisrc(gisrc) if os.access(gisrc, os.R_OK) else {} kv["GISDBASE"] = grassdb kv["LOCATION_NAME"] = location kv["MAPSET"] = mapset @@ -564,10 +556,7 @@ def add_mapset_to_gisrc(gisrc, grassdb, location, mapset): def add_last_mapset_to_gisrc(gisrc, last_mapset_path): - if os.access(gisrc, os.R_OK): - kv = read_gisrc(gisrc) - else: - kv = {} + kv = read_gisrc(gisrc) if os.access(gisrc, os.R_OK) else {} kv["LAST_MAPSET_PATH"] = last_mapset_path write_gisrc(kv, gisrc) @@ -620,7 +609,7 @@ def create_initial_gisrc(filename): LOCATION_NAME: MAPSET: """ - % os.getcwd() + % Path.cwd() ) writefile(filename, s) @@ -737,22 +726,21 @@ def cannot_create_location_reason(gisdbase, location): " the project <{location}>" " already exists." ).format(**locals()) - elif os.path.isfile(path): + if os.path.isfile(path): return _( "Unable to create new project <{location}> because <{path}> is a file." ).format(**locals()) - elif os.path.isdir(path): + if os.path.isdir(path): return _( "Unable to create new project <{location}> because" " the directory <{path}>" " already exists." ).format(**locals()) - else: - return _( - "Unable to create new project in" - " the directory <{path}>" - " for an unknown reason." - ).format(**locals()) + return _( + "Unable to create new project in" + " the directory <{path}>" + " for an unknown reason." + ).format(**locals()) def set_mapset( @@ -789,7 +777,7 @@ def set_mapset( # non-empty element as the last element (which is good for both mapset # and location split) if arg == ".": - arg = os.getcwd() + arg = str(Path.cwd()) elif not os.path.isabs(arg): arg = os.path.abspath(arg) if arg.endswith(os.path.sep): @@ -1057,9 +1045,7 @@ def load_env(grass_env_file): v = v.strip('"') # we'll keep expand=True to expand $var's inside "value" because # they are within double quotes - elif ( - v.startswith("'") or v.endswith("'") or v.startswith('"') or v.endswith('"') - ): + elif v.startswith(("'", '"')) or v.endswith(("'", '"')): # here, let's try to ignore unmatching single/double quotes, which # might be a multi-line variable or just a user error debug("Ignoring multi-line environmental variable {0}".format(k)) @@ -1100,7 +1086,7 @@ def set_language(grass_config_dir): # Override value is stored in wxGUI preferences file. try: - with open(os.path.join(grass_config_dir, "wx.json"), "r") as json_file: + with open(os.path.join(grass_config_dir, "wx.json")) as json_file: try: language = json.load(json_file)["language"]["locale"]["lc_all"] except KeyError: @@ -1162,7 +1148,7 @@ def set_language(grass_config_dir): encoding = "UTF-8" normalized = locale.normalize("%s.%s" % (language, encoding)) locale.setlocale(locale.LC_ALL, normalized) - except locale.Error as e: + except locale.Error: if language == "en": # A workaround for Python Issue30755 # https://bugs.python.org/issue30755 @@ -1188,7 +1174,7 @@ def set_language(grass_config_dir): # See bugs #3441 and #3423 try: locale.setlocale(locale.LC_ALL, "C.UTF-8") - except locale.Error as e: + except locale.Error: # All lost. Setting to C as much as possible. # We can not call locale.normalize on C as it # will transform it to en_US and we already know @@ -1283,64 +1269,6 @@ def set_language(grass_config_dir): gettext.install("grasslibs", gpath("locale")) -def lock_mapset(mapset_path, force_gislock_removal, user): - """Lock the mapset and return name of the lock file - - Behavior on error must be changed somehow; now it fatals but GUI case is - unresolved. - """ - if not os.path.exists(mapset_path): - fatal(_("Path '%s' doesn't exist") % mapset_path) - if not os.access(mapset_path, os.W_OK): - error = _("Path '%s' not accessible.") % mapset_path - stat_info = os.stat(mapset_path) - mapset_uid = stat_info.st_uid - if mapset_uid != os.getuid(): - # GTC %s is mapset's folder path - error = "%s\n%s" % ( - error, - _("You are not the owner of '%s'.") % mapset_path, - ) - fatal(error) - # Check for concurrent use - lockfile = os.path.join(mapset_path, ".gislock") - ret = call([gpath("etc", "lock"), lockfile, "%d" % os.getpid()]) - msg = None - if ret == 2: - if not force_gislock_removal: - msg = _( - "%(user)s is currently running GRASS in selected mapset" - " (file %(file)s found). Concurrent use not allowed.\n" - "You can force launching GRASS using -f flag" - " (note that you need permission for this operation)." - " Have another look in the processor " - "manager just to be sure..." % {"user": user, "file": lockfile} - ) - else: - try_remove(lockfile) - message( - _( - "%(user)s is currently running GRASS in selected mapset" - " (file %(file)s found). Forcing to launch GRASS..." - % {"user": user, "file": lockfile} - ) - ) - elif ret != 0: - msg = ( - _("Unable to properly access '%s'.\nPlease notify system personnel.") - % lockfile - ) - - if msg: - raise Exception(msg) - debug( - "Mapset <{mapset}> locked using '{lockfile}'".format( - mapset=mapset_path, lockfile=lockfile - ) - ) - return lockfile - - # TODO: the gisrcrc here does not make sense, remove it from load_gisrc def unlock_gisrc_mapset(gisrc, gisrcrc): """Unlock mapset from the gisrc file""" @@ -1394,11 +1322,8 @@ def get_shell(): sh = os.path.basename(sh) else: # If SHELL is not set, see if there is Bash and use it. - if shutil.which("bash"): - sh = "bash" - else: - # Fallback to sh if there is no Bash on path. - sh = "sh" + # Fallback to sh if there is no Bash on path. + sh = "bash" if shutil.which("bash") else "sh" # Ensure the variable is set. os.environ["SHELL"] = sh @@ -1479,7 +1404,7 @@ def script_path(batch_job): if script_in_addon_path and os.path.exists(script_in_addon_path): batch_job[0] = script_in_addon_path return script_in_addon_path - elif os.path.exists(batch_job[0]): + if os.path.exists(batch_job[0]): return batch_job[0] try: @@ -1571,7 +1496,7 @@ def say_hello(): revision = linerev.split(" ")[1] sys.stderr.write(" (" + revision + ")") - except: + except Exception: pass @@ -1691,7 +1616,7 @@ def sh_like_startup(location, location_name, grass_env_file, sh): # save command history in mapset dir and remember more # bash history file handled in specific_addition - if not sh == "bash": + if sh != "bash": os.environ["HISTFILE"] = os.path.join(location, sh_history) # instead of changing $HOME, start bash with: @@ -1712,11 +1637,8 @@ def sh_like_startup(location, location_name, grass_env_file, sh): else: f.write("test -r ~/.alias && . ~/.alias\n") - if os.getenv("ISISROOT"): - # GRASS GIS and ISIS blend - grass_name = "ISIS-GRASS" - else: - grass_name = "GRASS" + # GRASS GIS and ISIS blend + grass_name = "GRASS" if not os.getenv("ISISROOT") else "ISIS-GRASS" if sh == "zsh": f.write("setopt PROMPT_SUBST\n") @@ -1728,8 +1650,8 @@ def sh_like_startup(location, location_name, grass_env_file, sh): ) ) + mask2d_test = "r.mask.status -t" # TODO: have a function and/or module to test this - mask2d_test = 'test -f "$MAPSET_PATH/cell/MASK"' mask3d_test = 'test -d "$MAPSET_PATH/grid3/RASTER3D_MASK"' specific_addition = "" @@ -1937,7 +1859,7 @@ def print_params(params): try: revision = linerev.split(" ")[1] sys.stdout.write("%s\n" % revision[1:]) - except: + except Exception: sys.stdout.write("No SVN revision defined\n") elif arg == "version": sys.stdout.write("%s\n" % GRASS_VERSION) @@ -2422,14 +2344,16 @@ def main(): location = mapset_settings.full_mapset + from grass.app.data import lock_mapset, MapsetLockingException + try: # check and create .gislock file lock_mapset( - mapset_settings.full_mapset, - user=user, - force_gislock_removal=params.force_gislock_removal, + mapset_path=mapset_settings.full_mapset, + force_lock_removal=params.force_gislock_removal, + message_callback=message, ) - except Exception as e: + except MapsetLockingException as e: fatal(e.args[0]) sys.exit(_("Exiting...")) diff --git a/lib/init/helptext.html b/lib/init/helptext.html index d988b6b0376..4a14dd52df1 100644 --- a/lib/init/helptext.html +++ b/lib/init/helptext.html @@ -62,7 +62,7 @@

    GRASS started in the default project, now what?

    Creating a New project with the Project Wizard

    If you know the CRS of your data or study area, -you can fill EPSG code +you can fill EPSG code or description and Project Wizard finds appropriate CRS from a predefined list of projections. @@ -97,4 +97,6 @@

    See also

    - List of EPSG codes (Database of worldwide coordinate systems) + List of EPSG codes (Database of worldwide coordinate systems), + CRS Explorer - PROJ codes, and + EPSG Geodetic Parameter Dataset diff --git a/lib/init/testsuite/test_grass_tmp_mapset.py b/lib/init/testsuite/test_grass_tmp_mapset.py index 7a488dadb5f..9379957cd3f 100644 --- a/lib/init/testsuite/test_grass_tmp_mapset.py +++ b/lib/init/testsuite/test_grass_tmp_mapset.py @@ -18,6 +18,7 @@ import os import shutil import subprocess +from grass.gunittest.utils import xfail_windows # Note that unlike rest of GRASS GIS, here we are using unittest package @@ -43,6 +44,7 @@ def tearDown(self): """Deletes the location""" shutil.rmtree(self.location, ignore_errors=True) + @xfail_windows def test_command_runs(self): """Check that correct parameters are accepted""" return_code = subprocess.call( @@ -57,6 +59,7 @@ def test_command_runs(self): ), ) + @xfail_windows def test_command_fails_without_location(self): """Check that the command fails with a nonexistent location""" return_code = subprocess.call( @@ -78,6 +81,7 @@ def test_command_fails_without_location(self): ), ) + @xfail_windows def test_mapset_metadata_correct(self): """Check that metadata is readable and have expected value (XY CRS)""" output = subprocess.check_output( @@ -91,6 +95,7 @@ def test_mapset_metadata_correct(self): ), ) + @xfail_windows def test_mapset_deleted(self): """Check that mapset is deleted at the end of execution""" subprocess.check_call( diff --git a/lib/init/variables.html b/lib/init/variables.html index 6fd10d7f173..5dfd113dd85 100644 --- a/lib/init/variables.html +++ b/lib/init/variables.html @@ -392,7 +392,7 @@

    List of selected (GRASS related) shell environment variables

    TMPDIR, TEMP, TMP
    [Various GRASS GIS commands and wxGUI]
    - + The default wxGUI temporary directory is chosen from a platform-dependent list, but the user can control the selection of this directory by setting one of the TMPDIR, TEMP or TMP diff --git a/lib/lidar/raster.c b/lib/lidar/raster.c index 4d7305c9a9b..ad531865df7 100644 --- a/lib/lidar/raster.c +++ b/lib/lidar/raster.c @@ -3,6 +3,7 @@ #include #include #include +#include /*------------------------------------------------------------------------------------------------*/ void P_Sparse_Points(struct Map_info *Out, struct Cell_head *Elaboration, @@ -187,6 +188,7 @@ void P_Sparse_Points(struct Map_info *Out, struct Cell_head *Elaboration, } /*IF*/} /*FOR*/ db_commit_transaction(driver); + Vect_destroy_line_struct(point); return; } diff --git a/lib/linkm/test/try.c b/lib/linkm/test/try.c index 4f2a431e003..3b71b6f684a 100644 --- a/lib/linkm/test/try.c +++ b/lib/linkm/test/try.c @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) exit(0); } -int add_link_rev(struct link *List, struct link *link) +void add_link_rev(struct link *List, struct link *link) { struct link *p; @@ -70,7 +70,7 @@ int add_link_rev(struct link *List, struct link *link) link->next = p; } -int add_link(struct link *List, struct link *link) +void add_link(struct link *List, struct link *link) { struct link *p; @@ -81,7 +81,7 @@ int add_link(struct link *List, struct link *link) link->next = NULL; } -int dumplist(struct link *List) +void dumplist(struct link *List) { struct link *p; diff --git a/lib/linkm/test/try2.c b/lib/linkm/test/try2.c index ad226826795..7eb153f16f3 100644 --- a/lib/linkm/test/try2.c +++ b/lib/linkm/test/try2.c @@ -63,7 +63,7 @@ int main(int argc, char *argv[]) exit(0); } -int add_link_rev(struct link *List, struct link *link) +void add_link_rev(struct link *List, struct link *link) { struct link *p; @@ -72,7 +72,7 @@ int add_link_rev(struct link *List, struct link *link) link->next = p; } -int add_link(struct link *List, struct link *link) +void add_link(struct link *List, struct link *link) { struct link *p; @@ -83,7 +83,7 @@ int add_link(struct link *List, struct link *link) link->next = NULL; } -int dumplist(struct link *List) +void dumplist(struct link *List) { struct link *p; diff --git a/lib/ogsf/gk.c b/lib/ogsf/gk.c index 3390598960a..b4fea635cc4 100644 --- a/lib/ogsf/gk.c +++ b/lib/ogsf/gk.c @@ -172,8 +172,8 @@ void gk_follow_frames(Viewnode *view, int numsteps, Keylist *keys, int step, GS_get_from(tmp); G_debug(3, "gk_follow_frames():"); - G_debug(3, " MASK: %lx", mask); - G_debug(3, " FROM: %f %f %f", tmp[X], tmp[Y], tmp[Z]); + G_debug(3, " mask: %lx", mask); + G_debug(3, " from: %f %f %f", tmp[X], tmp[Y], tmp[Z]); /* ACS 1 line: was GS_get_focus(tmp); with this kanimator works also for flythrough navigation diff --git a/lib/ogsf/gvd.c b/lib/ogsf/gvd.c index 6a6176526a2..84867123c5e 100644 --- a/lib/ogsf/gvd.c +++ b/lib/ogsf/gvd.c @@ -201,7 +201,7 @@ int gvd_vect(geovect *gv, geosurf *gs, int do_fast) } gsd_endline(); } - /* need to handle MASK! */ + /* need to handle mask! */ else if (src == CONST_ATT) { /* for now - but later, do seg intersect maskedge */ if (gs_point_is_masked(gs, bgn) || diff --git a/lib/ogsf/gvl2.c b/lib/ogsf/gvl2.c index 473d3e9406e..2c861c4b5ad 100644 --- a/lib/ogsf/gvl2.c +++ b/lib/ogsf/gvl2.c @@ -316,10 +316,16 @@ void GVL_get_dims(int id, int *rows, int *cols, int *depths) *rows = gvl->rows; *cols = gvl->cols; *depths = gvl->depths; - } - G_debug(3, "GVL_get_dims() id=%d, rows=%d, cols=%d, depths=%d", - gvl->gvol_id, gvl->rows, gvl->cols, gvl->depths); + G_debug(3, "GVL_get_dims() id=%d, rows=%d, cols=%d, depths=%d", + gvl->gvol_id, gvl->rows, gvl->cols, gvl->depths); + } + else { + G_debug(2, + "GVL_get_dims(): Attempted to access a null volume structure " + "for id=%d", + id); + } return; } diff --git a/lib/raster/mask_info.c b/lib/raster/mask_info.c index 792510879dc..25d61341ebe 100644 --- a/lib/raster/mask_info.c +++ b/lib/raster/mask_info.c @@ -1,30 +1,17 @@ -/* - ************************************************************* - * char * Rast_mask_info () +/** + * \file lib/raster/mask_info.c * - * returns a printable text of mask information + * \brief Raster Library - Get mask information * - ************************************************************ - * Rast__mask_info (name, mapset) + * (C) 1999-2024 by Vaclav Petras and the GRASS Development Team * - * char name[GNAME_MAX], mapset[GMAPSET_MAX]; + * This program is free software under the GNU General Public + * License (>=v2). Read the file COPYING that comes with GRASS + * for details. * - * function: - * determine the status off the automatic masking - * and the name of the cell file which forms the mask - * - * (the mask file is actually MASK in the current mapset, - * but is usually a reclassed cell file, and the reclass - * name and mapset are returned) - * - * returns: - * -1 no masking (name, mapset undefined) - * name, mapset are undefined - * - * 1 mask file present, masking on - * name, mapset hold mask file name, mapset - * - ***************************************************************/ + * \author CERL + * \author Vaclav Petras, NC State University, Center for Geospatial Analytics + */ #include @@ -32,6 +19,15 @@ #include #include +/** + * @brief Get a printable text with information about raster mask + * + * Determines if 2D raster mask is present and returns textual information about + * the mask suitable for end-user display. The resulting text is translated. + * Caller is responsible for freeing the memory of the returned string. + * + * @return New string with textual information + */ char *Rast_mask_info(void) { char text[GNAME_MAX + GMAPSET_MAX + 16]; @@ -53,16 +49,109 @@ char *Rast_mask_info(void) return G_store(text); } +/** + * @brief Retrieves the name of the raster mask to use. + * + * The returned raster map name is fully qualified, i.e., in the form + % "name@mapset". + * + * The mask name is "MASK@", where is the current + * mapset. + * + * The memory for the returned mask name is dynamically allocated using + * G_store(). It is the caller's responsibility to free the memory with + * G_free() when it is no longer needed. + * + * @returns A dynamically allocated string containing the mask name. + */ +char *Rast_mask_name(void) +{ + // Mask name is always "MASK@". + return G_fully_qualified_name("MASK", G_mapset()); +} + +/** + * @brief Get raster mask status information + * + * _is_mask_reclass_ is a pointer to a bool variable which + * will be set to true if mask raster is a reclass and false otherwise. + * + * If you are not interested in the underlying reclassified raster map, + * pass NULL pointers for the three reclass parameters: + * + * ``` + * Rast_mask_status(name, mapset, NULL, NULL, NULL); + * ``` + * + * @param[out] name Name of the raster map used as mask + * @param[out] mapset Name of the mapset the raster is in + * @param[out] is_mask_reclass Will be set to true if mask raster is a reclass + * @param[out] reclass_name Name of the underlying reclassified raster map + * @param[out] reclass_mapset Name of the mapset the reclassified raster is in + * + * @return true if mask is present, false otherwise + */ +bool Rast_mask_status(char *name, char *mapset, bool *is_mask_reclass, + char *reclass_name, char *reclass_mapset) +{ + int present = Rast__mask_info(name, mapset); + + if (is_mask_reclass && reclass_name && reclass_mapset) { + if (present) { + *is_mask_reclass = Rast_is_reclass("MASK", G_mapset(), reclass_name, + reclass_mapset) > 0; + if (*is_mask_reclass) { + // The original mask values were overwritten in the initial + // info call. Put back the original values, so that we can + // report them to the caller. + strcpy(name, "MASK"); + strcpy(mapset, G_mapset()); + } + } + else { + *is_mask_reclass = false; + } + } + + if (present == 1) + return true; + else + return false; +} + +/** + * @brief Get information about the current mask + * + * Determines the status of the automatic masking and the name of the 2D + * raster which forms the mask. Typically, mask is raster called MASK in the + * current mapset, but when used with r.mask, it is usually a reclassed + * raster, and so when a MASK raster is present and it is a reclass raster, + * the name and mapset of the underlying reclassed raster are returned. + * + * The name and mapset is written to the parameter which need to be defined + * with a sufficient size, least as `char name[GNAME_MAX], mapset[GMAPSET_MAX]`. + * + * When the masking is not active, -1 is returned and name and mapset are + * undefined. When the masking is active, 1 is returned and name and mapset + * will hold the name and mapset of the underlying raster. + * + * @param[out] name Name of the raster map used as mask + * @param[out] mapset Name of the map's mapset + * + * @return 1 if mask is present, -1 otherwise + */ int Rast__mask_info(char *name, char *mapset) { char rname[GNAME_MAX], rmapset[GMAPSET_MAX]; - strcpy(name, "MASK"); - strcpy(mapset, G_mapset()); + strcpy(rname, "MASK"); + (void)G_strlcpy(rmapset, G_mapset(), GMAPSET_MAX); - if (!G_find_raster(name, mapset)) + if (!G_find_raster(rname, rmapset)) return -1; + strcpy(name, rname); + strcpy(mapset, rmapset); if (Rast_is_reclass(name, mapset, rname, rmapset) > 0) { strcpy(name, rname); strcpy(mapset, rmapset); @@ -70,3 +159,13 @@ int Rast__mask_info(char *name, char *mapset) return 1; } + +/** + * @brief Check presence of 2D raster mask + * + * @return true if mask is present, false otherwise + */ +bool Rast_mask_is_present(void) +{ + return G_find_raster("MASK", G_mapset()) != NULL; +} diff --git a/lib/vector/Vlib/buffer2.c b/lib/vector/Vlib/buffer2.c index 102b1ca350b..ce628d761ef 100644 --- a/lib/vector/Vlib/buffer2.c +++ b/lib/vector/Vlib/buffer2.c @@ -118,7 +118,7 @@ static void elliptic_tangent(double x, double y, double da, double db, /* * !!! This is not line in GRASS' sense. See - * http://en.wikipedia.org/wiki/Line_%28mathematics%29 + * https://en.wikipedia.org/wiki/Line_%28mathematics%29 */ static void line_coefficients(double x1, double y1, double x2, double y2, double *a, double *b, double *c) diff --git a/lib/vector/Vlib/color_read.c b/lib/vector/Vlib/color_read.c index 0a023a89a7d..4e0b3b04837 100644 --- a/lib/vector/Vlib/color_read.c +++ b/lib/vector/Vlib/color_read.c @@ -49,7 +49,10 @@ int Vect_read_colors(const char *name, const char *mapset, if (colors) Rast_init_colors(colors); - strcpy(xname, name); + if (G_strlcpy(xname, name, sizeof(xname)) >= sizeof(xname)) { + G_warning(_("Vector map name <%s> is too long"), name); + return -1; + } mapset = G_find_vector(xname, mapset); if (!mapset) return -1; @@ -58,12 +61,12 @@ int Vect_read_colors(const char *name, const char *mapset, if (strcmp(mapset, G_mapset()) == 0) { /* look for the regular color table */ - sprintf(buf, "%s/%s", GV_DIRECTORY, name); + (void)snprintf(buf, sizeof(buf), "%s/%s", GV_DIRECTORY, name); ret = Rast__read_colors(buf, GV_COLR_ELEMENT, mapset, colors); } else { /* look for secondary color table in current mapset */ - sprintf(buf, "%s/%s", GV_COLR2_DIRECTORY, mapset); + (void)snprintf(buf, sizeof(buf), "%s/%s", GV_COLR2_DIRECTORY, mapset); ret = Rast__read_colors(buf, name, G_mapset(), colors); } if (ret == -2) diff --git a/lib/vector/Vlib/copy.c b/lib/vector/Vlib/copy.c index bde7e577c8b..779b5ed4a0f 100644 --- a/lib/vector/Vlib/copy.c +++ b/lib/vector/Vlib/copy.c @@ -82,6 +82,8 @@ int Vect_copy_map_lines_field(struct Map_info *In, int field, struct Map_info *Out) { int ret, format, topo; + const char *geometry_type = NULL; + const char *map_name = NULL; if (Vect_level(In) < 1) G_fatal_error( @@ -127,24 +129,30 @@ int Vect_copy_map_lines_field(struct Map_info *In, int field, /* copy features */ ret += copy_lines_2(In, field, topo, Out); - if (topo == TOPO_NONE && + if (topo == TOPO_NONE) { /* check output feature type, centroids can be exported as * points; boundaries as linestrings */ - strcmp(Vect_get_finfo_geometry_type(Out), "polygon") == 0) { - /* copy areas - external formats and simple features access only */ - ret += Vect__copy_areas(In, field, Out); + geometry_type = Vect_get_finfo_geometry_type(Out); + if (geometry_type && strcmp(geometry_type, "polygon") == 0) { + /* copy areas - external formats and simple features access only + */ + ret += Vect__copy_areas(In, field, Out); + } + G_free((void *)geometry_type); } } else { /* -> copy features on level 1 */ - if (topo == TOPO_NONE) + if (topo == TOPO_NONE) { + map_name = Vect_get_full_name(In); G_warning(_("Vector map <%s> not open on topological level. " "Areas will be skipped!"), - Vect_get_full_name(In)); + map_name); + G_free((void *)map_name); + } ret += copy_lines_1(In, field, Out); } - return ret > 0 ? 1 : 0; } @@ -161,6 +169,7 @@ int Vect_copy_map_lines_field(struct Map_info *In, int field, int copy_lines_1(struct Map_info *In, int field, struct Map_info *Out) { int ret, type; + const char *map_name = NULL; struct line_pnts *Points; struct line_cats *Cats; @@ -174,8 +183,9 @@ int copy_lines_1(struct Map_info *In, int field, struct Map_info *Out) while (TRUE) { type = Vect_read_next_line(In, Points, Cats); if (type == -1) { - G_warning(_("Unable to read vector map <%s>"), - Vect_get_full_name(In)); + map_name = Vect_get_full_name(In); + G_warning(_("Unable to read vector map <%s>"), map_name); + G_free((void *)map_name); ret = 1; break; } @@ -193,7 +203,6 @@ int copy_lines_1(struct Map_info *In, int field, struct Map_info *Out) Vect_write_line(Out, type, Points, Cats); } - Vect_destroy_line_struct(Points); Vect_destroy_cats_struct(Cats); @@ -220,6 +229,7 @@ int copy_lines_2(struct Map_info *In, int field, int topo, struct Map_info *Out) struct line_cats *Cats, *CCats; const char *ftype = NULL; + const char *map_name = NULL; Points = Vect_new_line_struct(); CPoints = Vect_new_line_struct(); @@ -251,8 +261,9 @@ int copy_lines_2(struct Map_info *In, int field, int topo, struct Map_info *Out) G_percent(i, nlines, 2); type = Vect_read_line(In, Points, Cats, i); if (type == -1) { - G_warning(_("Unable to read vector map <%s>"), - Vect_get_full_name(In)); + map_name = Vect_get_full_name(In); + G_warning(_("Unable to read vector map <%s>"), map_name); + G_free((void *)map_name); ret = 1; break; /* free allocated space and return */ } @@ -364,7 +375,8 @@ int copy_lines_2(struct Map_info *In, int field, int topo, struct Map_info *Out) if (-1 == Vect_write_line(Out, type, Points, Cats)) { G_warning(_("Writing new feature failed")); - return 1; + ret = 1; + goto free_exit; } } @@ -372,12 +384,13 @@ int copy_lines_2(struct Map_info *In, int field, int topo, struct Map_info *Out) G_important_message( _("%d features without category or from different layer skipped"), nskipped); - +free_exit: Vect_destroy_line_struct(Points); Vect_destroy_line_struct(CPoints); Vect_destroy_line_struct(NPoints); Vect_destroy_cats_struct(Cats); Vect_destroy_cats_struct(CCats); + G_free((void *)ftype); return ret; } @@ -496,6 +509,7 @@ int is_isle(struct Map_info *Map, int area) int Vect__copy_areas(struct Map_info *In, int field, struct Map_info *Out) { int i, area, nareas, cat, isle, nisles, nparts_alloc, nskipped; + int ret = 0; struct line_pnts **Points; struct line_cats *Cats; @@ -567,7 +581,8 @@ int Vect__copy_areas(struct Map_info *In, int field, struct Map_info *Out) if (0 > V2__write_area_sfa(Out, (const struct line_pnts **)Points, nisles + 1, Cats)) { G_warning(_("Writing area %d failed"), area); - return -1; + ret = -1; + goto free_exit; } } #ifdef HAVE_POSTGRES @@ -575,7 +590,8 @@ int Vect__copy_areas(struct Map_info *In, int field, struct Map_info *Out) if (0 > V2__update_area_pg(Out, (const struct line_pnts **)Points, nisles + 1, cat)) { G_warning(_("Writing area %d failed"), area); - return -1; + ret = -1; + goto free_exit; } } #endif @@ -587,11 +603,13 @@ int Vect__copy_areas(struct Map_info *In, int field, struct Map_info *Out) nskipped); /* free allocated space for isles */ +free_exit: for (i = 0; i < nparts_alloc; i++) Vect_destroy_line_struct(Points[i]); Vect_destroy_cats_struct(Cats); + G_free(Points); - return 0; + return ret; } /*! @@ -615,6 +633,7 @@ int Vect_copy_tables(struct Map_info *In, struct Map_info *Out, int field) { int i, n, type; struct field_info *Fi; + const char *map_name = NULL; n = Vect_get_num_dblinks(In); @@ -631,20 +650,23 @@ int Vect_copy_tables(struct Map_info *In, struct Map_info *Out, int field) In->dblnk->field[i].number); return -1; } - if (field > 0 && Fi->number != field) + if (field > 0 && Fi->number != field) { + Vect_destroy_field_info(Fi); continue; + } if (Vect_copy_table(In, Out, Fi->number, Fi->number, Fi->name, type) != 0) { - + map_name = Vect_get_full_name(In); G_warning( _("Unable to copy table <%s> for layer %d from <%s> to <%s>"), - Fi->table, Fi->number, Vect_get_full_name(In), - Vect_get_name(Out)); + Fi->table, Fi->number, map_name, Vect_get_name(Out)); + G_free((void *)map_name); + Vect_destroy_field_info(Fi); return -1; } + Vect_destroy_field_info(Fi); } - return 0; } @@ -729,10 +751,10 @@ int Vect_copy_table_by_cats(struct Map_info *In, struct Map_info *Out, int field_in, int field_out, const char *field_name, int type, int *cats, int ncats) { - int ret; + int ret = 0; struct field_info *Fi, *Fin; const char *name, *key; - dbDriver *driver; + dbDriver *driver = NULL; G_debug(2, "Vect_copy_table_by_cats(): field_in = %d field_out = %d", field_in, field_out); @@ -757,7 +779,7 @@ int Vect_copy_table_by_cats(struct Map_info *In, struct Map_info *Out, if (ret == -1) { G_warning(_("Unable to add database link for vector map <%s>"), Out->name); - return -1; + goto free_exit; } if (cats) @@ -770,7 +792,8 @@ int Vect_copy_table_by_cats(struct Map_info *In, struct Map_info *Out, Fin->table, key, cats, ncats); if (ret == DB_FAILED) { G_warning(_("Unable to copy table <%s>"), Fin->table); - return -1; + ret = -1; + goto free_exit; } driver = db_start_driver_open_database(Fin->driver, @@ -779,22 +802,30 @@ int Vect_copy_table_by_cats(struct Map_info *In, struct Map_info *Out, if (!driver) { G_warning(_("Unable to open database <%s> with driver <%s>"), Fin->database, Fin->driver); - return -1; + ret = -1; + goto free_exit; } /* do not allow duplicate keys */ if (db_create_index2(driver, Fin->table, Fi->key) != DB_OK) { G_warning(_("Unable to create index")); - return -1; + ret = -1; + goto close_db_free_exit; } if (db_grant_on_table(driver, Fin->table, DB_PRIV_SELECT, DB_GROUP | DB_PUBLIC) != DB_OK) { G_warning(_("Unable to grant privileges on table <%s>"), Fin->table); - return -1; + ret = -1; + goto close_db_free_exit; } +close_db_free_exit: db_close_database_shutdown_driver(driver); - return 0; +free_exit: + Vect_destroy_field_info(Fi); + Vect_destroy_field_info(Fin); + + return ret; } diff --git a/lib/vector/Vlib/geos.c b/lib/vector/Vlib/geos.c index 719e0fdd270..2c68a0a6fba 100644 --- a/lib/vector/Vlib/geos.c +++ b/lib/vector/Vlib/geos.c @@ -290,7 +290,7 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset, long size; double *x, *y, *z; - GEOSCoordSequence *pseq; + GEOSCoordSequence *pseq = NULL; G_debug(3, "V1_read_line_geos(): offset = %ld", offset); @@ -353,8 +353,6 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset, G_debug(3, " n_points = %d dim = %d", n_points, (Map->head.with_z) ? 3 : 2); - pseq = GEOSCoordSeq_create(n_points, (Map->head.with_z) ? 3 : 2); - x = (double *)G_malloc(n_points * sizeof(double)); y = (double *)G_malloc(n_points * sizeof(double)); if (Map->head.with_z) @@ -362,17 +360,22 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset, else z = NULL; - if (0 >= dig__fread_port_D(x, n_points, &(Map->dig_fp))) - return NULL; /* end of file */ + if (0 >= dig__fread_port_D(x, n_points, &(Map->dig_fp))) { + goto free_return; /* end of file */ + } - if (0 >= dig__fread_port_D(y, n_points, &(Map->dig_fp))) - return NULL; /* end of file */ + if (0 >= dig__fread_port_D(y, n_points, &(Map->dig_fp))) { + goto free_return; /* end of file */ + } if (Map->head.with_z) { - if (0 >= dig__fread_port_D(z, n_points, &(Map->dig_fp))) - return NULL; /* end of file */ + if (0 >= dig__fread_port_D(z, n_points, &(Map->dig_fp))) { + goto free_return; /* end of file */ + } } + pseq = GEOSCoordSeq_create(n_points, (Map->head.with_z) ? 3 : 2); + for (i = 0; i < n_points; i++) { GEOSCoordSeq_setX(pseq, i, x[i]); GEOSCoordSeq_setY(pseq, i, y[i]); @@ -382,6 +385,7 @@ GEOSCoordSequence *V1_read_line_geos(struct Map_info *Map, long offset, G_debug(3, " off = %ld", (long)dig_ftell(&(Map->dig_fp))); +free_return: G_free((void *)x); G_free((void *)y); if (z) diff --git a/lib/vector/Vlib/legal_vname.c b/lib/vector/Vlib/legal_vname.c index cd2aa0f14ba..f51df6ace66 100644 --- a/lib/vector/Vlib/legal_vname.c +++ b/lib/vector/Vlib/legal_vname.c @@ -32,7 +32,7 @@ int Vect_legal_filename(const char *s) { /* full list of SQL keywords available at - http://www.postgresql.org/docs/8.2/static/sql-keywords-appendix.html + https://www.postgresql.org/docs/8.2/static/sql-keywords-appendix.html */ static const char *keywords[] = {"and", "or", "not", NULL}; char buf[GNAME_MAX]; diff --git a/lib/vector/Vlib/open.c b/lib/vector/Vlib/open.c index 501b31eb4cb..0008156c34a 100644 --- a/lib/vector/Vlib/open.c +++ b/lib/vector/Vlib/open.c @@ -572,6 +572,7 @@ int Vect__open_old(struct Map_info *Map, const char *name, const char *mapset, if (access(file_path, F_OK) == 0) /* fidx file exists? */ unlink(file_path); } + Map->support_updated = TRUE; } return level; diff --git a/lib/vector/Vlib/open_pg.c b/lib/vector/Vlib/open_pg.c index 7db0113be99..293291066c2 100644 --- a/lib/vector/Vlib/open_pg.c +++ b/lib/vector/Vlib/open_pg.c @@ -535,11 +535,11 @@ void connect_db(struct Format_info_pg *pg_info) /* try connection settings for given database first, then try * any settings defined for pg driver */ - db_get_login2("pg", dbname, &user, &passwd, &host, &port); + db_get_login("pg", dbname, &user, &passwd, &host, &port); /* any settings defined for pg driver disabled - can cause problems when running multiple local/remote db clusters if (strlen(dbname) > 0 && !user && !passwd) - db_get_login2("pg", NULL, &user, &passwd, &host, &port); + db_get_login("pg", NULL, &user, &passwd, &host, &port); */ if (user || passwd || host || port) { char conninfo[DB_SQL_MAX]; diff --git a/lib/vector/vectorlib_pg.dox b/lib/vector/vectorlib_pg.dox index c3a072c6a14..d95b3dec1c2 100644 --- a/lib/vector/vectorlib_pg.dox +++ b/lib/vector/vectorlib_pg.dox @@ -10,14 +10,14 @@ by GRASS Development Team (https://grass.osgeo.org) write PostGIS data directly without any external library (like in the case of \ref vlibOgr). GRASS-PostGIS data provider is implemented using libpq +href="https://www.postgresql.org/docs/9.2/static/libpq.html">libpq library. Note that GRASS-PostGIS data provider is compiled only when GRASS is configured with --with-postgres switch. See the trac +href="https://trac.osgeo.org/grass/wiki/Grass7/VectorLib/PostGISInterface">trac page for more info. \section vlibFn List of functions diff --git a/locale/grass_po_stats.py b/locale/grass_po_stats.py index b5f15026691..bfae49629d3 100644 --- a/locale/grass_po_stats.py +++ b/locale/grass_po_stats.py @@ -21,10 +21,12 @@ import subprocess import sys +from pathlib import Path + def read_po_files(inputdirpath): """Return a dictionary with for each language the list of *.po files""" - originalpath = os.getcwd() + originalpath = Path.cwd() os.chdir(inputdirpath) languages = {} for pofile in sorted(glob.glob("*.po")): @@ -79,10 +81,9 @@ def langDefinition(fil): f.close() if len(lang) == 2: return " ".join(lang) - elif len(lang) == 1: + if len(lang) == 1: return lang[0] - else: - return "" + return "" def get_stats(languages, directory): @@ -144,7 +145,7 @@ def writejson(stats, outfile): fout.close() try: os.remove("messages.mo") - except: + except OSError: pass diff --git a/locale/po/grassmods_ar.po b/locale/po/grassmods_ar.po index b21aefa5d0b..cbb43ec6e9e 100644 --- a/locale/po/grassmods_ar.po +++ b/locale/po/grassmods_ar.po @@ -71377,7 +71377,7 @@ msgid "Either or must be given" msgstr "طبقتين يجب تحديدهم" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_bn.po b/locale/po/grassmods_bn.po index 17a11f251b8..f3526d45180 100644 --- a/locale/po/grassmods_bn.po +++ b/locale/po/grassmods_bn.po @@ -65839,7 +65839,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_cs.po b/locale/po/grassmods_cs.po index c6f5f75df4c..0d17c962990 100644 --- a/locale/po/grassmods_cs.po +++ b/locale/po/grassmods_cs.po @@ -68271,7 +68271,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_de.po b/locale/po/grassmods_de.po index 8603cfda94d..7e994f4b379 100644 --- a/locale/po/grassmods_de.po +++ b/locale/po/grassmods_de.po @@ -68907,7 +68907,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_el.po b/locale/po/grassmods_el.po index 5b07d819bd2..e183723b634 100644 --- a/locale/po/grassmods_el.po +++ b/locale/po/grassmods_el.po @@ -66429,7 +66429,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_es.po b/locale/po/grassmods_es.po index 676e7382c2d..ca8a6727270 100644 --- a/locale/po/grassmods_es.po +++ b/locale/po/grassmods_es.po @@ -70595,7 +70595,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_fi.po b/locale/po/grassmods_fi.po index 15504ea84ae..692d9c0d9f2 100644 --- a/locale/po/grassmods_fi.po +++ b/locale/po/grassmods_fi.po @@ -65889,7 +65889,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_fr.po b/locale/po/grassmods_fr.po index f13cc33269f..8f4602fc6ec 100644 --- a/locale/po/grassmods_fr.po +++ b/locale/po/grassmods_fr.po @@ -68934,7 +68934,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_hu.po b/locale/po/grassmods_hu.po index 193acc17813..ee0f0929c11 100644 --- a/locale/po/grassmods_hu.po +++ b/locale/po/grassmods_hu.po @@ -66112,7 +66112,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_id_ID.po b/locale/po/grassmods_id_ID.po index c7159086153..d9a39bafe24 100644 --- a/locale/po/grassmods_id_ID.po +++ b/locale/po/grassmods_id_ID.po @@ -65729,7 +65729,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_it.po b/locale/po/grassmods_it.po index 3120ef6c35b..94368222e52 100644 --- a/locale/po/grassmods_it.po +++ b/locale/po/grassmods_it.po @@ -68276,7 +68276,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_ja.po b/locale/po/grassmods_ja.po index 3444ccaf5db..0dd3735b064 100644 --- a/locale/po/grassmods_ja.po +++ b/locale/po/grassmods_ja.po @@ -67358,7 +67358,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_ko.po b/locale/po/grassmods_ko.po index 5e3acc44adc..8d255c6f5ad 100644 --- a/locale/po/grassmods_ko.po +++ b/locale/po/grassmods_ko.po @@ -67003,7 +67003,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_lv.po b/locale/po/grassmods_lv.po index 717f25bac27..43e408d8721 100644 --- a/locale/po/grassmods_lv.po +++ b/locale/po/grassmods_lv.po @@ -67248,7 +67248,7 @@ msgid "Either or must be given" msgstr "2 līmeņiem jābūt norādītiem" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_ml.po b/locale/po/grassmods_ml.po index 201460df7bb..a3693866979 100644 --- a/locale/po/grassmods_ml.po +++ b/locale/po/grassmods_ml.po @@ -65839,7 +65839,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_pl.po b/locale/po/grassmods_pl.po index 8edda3da8e1..dccca2f5d0f 100644 --- a/locale/po/grassmods_pl.po +++ b/locale/po/grassmods_pl.po @@ -67713,7 +67713,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_pt.po b/locale/po/grassmods_pt.po index 63404997a1a..4a28f18ff64 100644 --- a/locale/po/grassmods_pt.po +++ b/locale/po/grassmods_pt.po @@ -67030,7 +67030,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_pt_BR.po b/locale/po/grassmods_pt_BR.po index 673f09c2d8c..d7bcb3c7f41 100644 --- a/locale/po/grassmods_pt_BR.po +++ b/locale/po/grassmods_pt_BR.po @@ -68320,7 +68320,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_ro.po b/locale/po/grassmods_ro.po index 46ac81a4b36..3f4174329a4 100644 --- a/locale/po/grassmods_ro.po +++ b/locale/po/grassmods_ro.po @@ -67214,7 +67214,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_ru.po b/locale/po/grassmods_ru.po index cc9bdc51a78..2630e39adcf 100644 --- a/locale/po/grassmods_ru.po +++ b/locale/po/grassmods_ru.po @@ -66746,7 +66746,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_si.po b/locale/po/grassmods_si.po index 7f42447aee9..b2f15092dbc 100644 --- a/locale/po/grassmods_si.po +++ b/locale/po/grassmods_si.po @@ -65839,7 +65839,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_sl.po b/locale/po/grassmods_sl.po index e2b72f76d56..56c5e73fd60 100644 --- a/locale/po/grassmods_sl.po +++ b/locale/po/grassmods_sl.po @@ -71740,7 +71740,7 @@ msgid "Either or must be given" msgstr "Uporabiš lahko ali 'from_table' ali 'select'" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_ta.po b/locale/po/grassmods_ta.po index d76c586fc00..4bd45b751d5 100644 --- a/locale/po/grassmods_ta.po +++ b/locale/po/grassmods_ta.po @@ -65897,7 +65897,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_th.po b/locale/po/grassmods_th.po index bb0898b05f1..a38947544d5 100644 --- a/locale/po/grassmods_th.po +++ b/locale/po/grassmods_th.po @@ -66270,7 +66270,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_tr.po b/locale/po/grassmods_tr.po index 6e58f486013..ef10aa29895 100644 --- a/locale/po/grassmods_tr.po +++ b/locale/po/grassmods_tr.po @@ -67181,7 +67181,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_uk.po b/locale/po/grassmods_uk.po index 8bf34d792ef..ded3fc09c7a 100644 --- a/locale/po/grassmods_uk.po +++ b/locale/po/grassmods_uk.po @@ -66059,7 +66059,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_vi.po b/locale/po/grassmods_vi.po index bfe8eb81909..cb4f0aa95a9 100644 --- a/locale/po/grassmods_vi.po +++ b/locale/po/grassmods_vi.po @@ -66307,7 +66307,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_zh.po b/locale/po/grassmods_zh.po index f5926443d90..3ec8942025d 100644 --- a/locale/po/grassmods_zh.po +++ b/locale/po/grassmods_zh.po @@ -66768,7 +66768,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/po/grassmods_zh_CN.po b/locale/po/grassmods_zh_CN.po index 9ba4d09e886..476cc510193 100644 --- a/locale/po/grassmods_zh_CN.po +++ b/locale/po/grassmods_zh_CN.po @@ -65730,7 +65730,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/locale/templates/grassmods.pot b/locale/templates/grassmods.pot index c339eb81069..3476f2faa63 100644 --- a/locale/templates/grassmods.pot +++ b/locale/templates/grassmods.pot @@ -65839,7 +65839,7 @@ msgid "Either or must be given" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:129 -msgid "'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)" +msgid "'gdalinfo' not found, install GDAL tools first (https://gdal.org)" msgstr "" #: ../scripts/i.in.spotvgt/i.in.spotvgt.py:146 diff --git a/macosx/ReadMe.md b/macosx/ReadMe.md index ac19f4c57de..86fb1c0ba38 100644 --- a/macosx/ReadMe.md +++ b/macosx/ReadMe.md @@ -230,7 +230,7 @@ build)*: To install the new Python GUI (see [REQUIREMENTS.html](../REQUIREMENTS.html) and [gui/wxpython/README](../gui/wxpython/README), wxpython installer -available at [wxpython.org](http://wxpython.org/)), add this to configure (fill +available at [wxpython.org](https://wxpython.org/)), add this to configure (fill in the correct version at x.x.x.x for the wxpython you have installed): ```bash diff --git a/man/build_check.py b/man/build_check.py index 6111a4dbe9f..9d9675fb7ac 100644 --- a/man/build_check.py +++ b/man/build_check.py @@ -9,7 +9,7 @@ import sys import os -from build_html import * +from build_html import html_dir, message_tmpl, html_files, read_file os.chdir(html_dir) diff --git a/man/build_check_rest.py b/man/build_check_rest.py index 159be8453db..f9868dfd697 100644 --- a/man/build_check_rest.py +++ b/man/build_check_rest.py @@ -9,7 +9,7 @@ import sys import os -from build_rest import * +from build_rest import rest_dir, message_tmpl, rest_files, read_file os.chdir(rest_dir) diff --git a/man/build_class.py b/man/build_class.py index 8300c62079f..564fb5c20e6 100644 --- a/man/build_class.py +++ b/man/build_class.py @@ -9,7 +9,20 @@ import sys import os -from build_html import * +from build_html import ( + html_dir, + write_html_header, + grass_version, + modclass_intro_tmpl, + modclass_tmpl, + to_title, + html_files, + check_for_desc_override, + get_desc, + desc2_tmpl, + write_html_footer, + replace_file, +) no_intro_page_classes = ["display", "general", "miscellaneous", "postscript"] diff --git a/man/build_class_graphical.py b/man/build_class_graphical.py index 955f5c2a63e..83338f1942c 100644 --- a/man/build_class_graphical.py +++ b/man/build_class_graphical.py @@ -91,10 +91,7 @@ def file_matches(filename, patterns): - for pattern in patterns: - if fnmatch.fnmatch(filename, pattern): - return True - return False + return any(fnmatch.fnmatch(filename, pattern) for pattern in patterns) def starts_with_module(string, module) -> bool: @@ -102,9 +99,7 @@ def starts_with_module(string, module) -> bool: # module = module.replace('wxGUI.', 'g.gui.') # TODO: matches g.mapsets images for g.mapset and d.rast.num for d.rast return bool( - string.startswith(module.replace(".", "_")) - or string.startswith(module.replace(".", "")) - or string.startswith(module) + string.startswith((module.replace(".", "_"), module.replace(".", ""), module)) ) @@ -170,7 +165,7 @@ def generate_page_for_category( img_class = "linkimg" if skip_no_image and not img: continue - elif not img: + if not img: img = "grass_logo.png" img_class = "default-img" if basename.startswith("wxGUI"): diff --git a/man/build_class_rest.py b/man/build_class_rest.py index c1de3d623d0..05aec125d04 100644 --- a/man/build_class_rest.py +++ b/man/build_class_rest.py @@ -9,7 +9,19 @@ import sys import os -from build_rest import * +from build_rest import ( + rest_dir, + grass_version, + modclass_intro_tmpl, + modclass_tmpl, + desc2_tmpl, + write_rest_header, + write_rest_footer, + rest_files, + check_for_desc_override, + get_desc, + replace_file, +) os.chdir(rest_dir) diff --git a/man/build_full_index.py b/man/build_full_index.py index 76379787905..7d2ce03e342 100644 --- a/man/build_full_index.py +++ b/man/build_full_index.py @@ -9,7 +9,23 @@ import sys import os -from build_html import * +from operator import itemgetter + +from build_html import ( + html_dir, + grass_version, + html_files, + write_html_header, + write_html_footer, + check_for_desc_override, + get_desc, + replace_file, + to_title, + full_index_header, + toc, + cmd2_tmpl, + desc1_tmpl, +) year = None if len(sys.argv) > 1: @@ -36,7 +52,7 @@ prefix = cmd.split(".")[0] if prefix not in [item[0] for item in classes]: classes.append((prefix, class_labels.get(prefix, prefix))) -classes.sort(key=lambda tup: tup[0]) +classes.sort(key=itemgetter(0)) # begin full index: filename = "full_index.html" diff --git a/man/build_full_index_rest.py b/man/build_full_index_rest.py index 14167df0f84..26183505393 100644 --- a/man/build_full_index_rest.py +++ b/man/build_full_index_rest.py @@ -8,7 +8,20 @@ import os -from build_rest import * +from build_rest import ( + rest_dir, + rest_files, + write_rest_header, + grass_version, + full_index_header, + sections, + cmd2_tmpl, + check_for_desc_override, + get_desc, + desc1_tmpl, + write_rest_footer, + replace_file, +) os.chdir(rest_dir) diff --git a/man/build_html.py b/man/build_html.py index daa38b557f4..a8cc4c057a5 100644 --- a/man/build_html.py +++ b/man/build_html.py @@ -393,7 +393,7 @@ def check_for_desc_override(basename): def read_file(name): - f = open(name, "r") + f = open(name) s = f.read() f.close() return s @@ -464,10 +464,7 @@ def write_html_cmd_overview(f): def write_html_footer(f, index_url, year=None): - if year is None: - cur_year = default_year - else: - cur_year = year + cur_year = default_year if year is None else year f.write( footer_tmpl.substitute( grass_version=grass_version, index_url=index_url, year=cur_year @@ -476,7 +473,7 @@ def write_html_footer(f, index_url, year=None): def get_desc(cmd): - f = open(cmd, "r") + f = open(cmd) while True: line = f.readline() if not line: @@ -494,8 +491,7 @@ def get_desc(cmd): sp = line.split("-", 1) if len(sp) > 1: return sp[1].strip() - else: - return None + return None return "" diff --git a/man/build_index.py b/man/build_index.py index 5a01787afe3..12de7f01162 100644 --- a/man/build_index.py +++ b/man/build_index.py @@ -9,7 +9,14 @@ import sys import os -from build_html import * +from build_html import ( + html_dir, + grass_version, + write_html_header, + write_html_cmd_overview, + write_html_footer, + replace_file, +) os.chdir(html_dir) diff --git a/man/build_index_rest.py b/man/build_index_rest.py index 68463bbb753..b919042e4af 100644 --- a/man/build_index_rest.py +++ b/man/build_index_rest.py @@ -9,7 +9,14 @@ import os -from build_rest import * +from build_rest import ( + rest_dir, + grass_version, + write_rest_header, + write_rest_cmd_overview, + write_rest_footer, + replace_file, +) os.chdir(rest_dir) diff --git a/man/build_keywords.py b/man/build_keywords.py index 477c1a131ff..b0dfe95e0e3 100644 --- a/man/build_keywords.py +++ b/man/build_keywords.py @@ -21,7 +21,13 @@ import os import sys import glob -from build_html import * +from build_html import ( + grass_version, + header1_tmpl, + headerkeywords_tmpl, + write_html_footer, +) + blacklist = [ "Display", @@ -81,17 +87,17 @@ def get_module_man_html_file_path(module): try: index_keys = lines.index("

    KEYWORDS

    \n") + 1 index_desc = lines.index("

    NAME

    \n") + 1 - except: + except Exception: continue try: keys = lines[index_keys].split(",") - except: + except Exception: continue for key in keys: key = key.strip() try: key = key.split(">")[1].split("<")[0] - except: + except Exception: pass if not key: sys.exit("Empty keyword from file %s line: %s" % (fname, lines[index_keys])) @@ -104,10 +110,10 @@ def get_module_man_html_file_path(module): for black in blacklist: try: del keywords[black] - except: + except Exception: try: del keywords[black.lower()] - except: + except Exception: continue for key in sorted(keywords.keys()): @@ -152,7 +158,7 @@ def get_module_man_html_file_path(module): for k in sorted(char_list.keys()): test_length += 1 # toc += '
  • %s
  • ' % (char_list[k], k) - if test_length % 4 == 0 and not test_length == all_keys: + if test_length % 4 == 0 and test_length != all_keys: toc += '\n%s, ' % (char_list[k], k) elif test_length % 4 == 0 and test_length == all_keys: toc += '\n%s' % (char_list[k], k) diff --git a/man/build_manual_gallery.py b/man/build_manual_gallery.py index 3d381e27877..a8b077be8f9 100755 --- a/man/build_manual_gallery.py +++ b/man/build_manual_gallery.py @@ -102,10 +102,7 @@ def img_in_html(filename, imagename) -> bool: def file_matches(filename, patterns): - for pattern in patterns: - if fnmatch.fnmatch(filename, pattern): - return True - return False + return any(fnmatch.fnmatch(filename, pattern) for pattern in patterns) def get_files(directory, patterns, exclude_patterns): @@ -135,8 +132,7 @@ def title_from_names(module_name, img_name): img_name = img_name.strip() if img_name: return "{name} ({desc})".format(name=module_name, desc=img_name) - else: - return "{name}".format(name=module_name) + return "{name}".format(name=module_name) def get_module_name(filename): diff --git a/man/build_rest.py b/man/build_rest.py index ea1dd7692d2..a98a099a076 100644 --- a/man/build_rest.py +++ b/man/build_rest.py @@ -271,7 +271,7 @@ def check_for_desc_override(basename): def read_file(name): - f = open(name, "r") + f = open(name) s = f.read() f.close() return s @@ -337,7 +337,7 @@ def write_rest_footer(f, index_url): def get_desc(cmd): - f = open(cmd, "r") + f = open(cmd) while True: line = f.readline() if not line: @@ -355,8 +355,7 @@ def get_desc(cmd): sp = line.split("-", 1) if len(sp) > 1: return sp[1].strip() - else: - return None + return None return "" diff --git a/man/build_topics.py b/man/build_topics.py index bd0606d1aeb..be5f2962d2c 100644 --- a/man/build_topics.py +++ b/man/build_topics.py @@ -6,7 +6,15 @@ import os import sys import glob -from build_html import * +from build_html import ( + grass_version, + header1_tmpl, + headertopics_tmpl, + headerkey_tmpl, + desc1_tmpl, + moduletopics_tmpl, + write_html_footer, +) path = sys.argv[1] year = os.getenv("VERSION_DATE") @@ -24,16 +32,16 @@ try: index_keys = lines.index("

    KEYWORDS

    \n") + 1 index_desc = lines.index("

    NAME

    \n") + 1 - except: + except Exception: continue try: key = lines[index_keys].split(",")[1].strip().replace(" ", "_") key = key.split(">")[1].split("<")[0] - except: + except Exception: continue try: desc = lines[index_desc].split("-", 1)[1].strip() - except: + except Exception: desc.strip() if key not in keywords.keys(): keywords[key] = {} diff --git a/man/parser_standard_options.py b/man/parser_standard_options.py index 15d1e0fc9ae..ad027a1b6b4 100644 --- a/man/parser_standard_options.py +++ b/man/parser_standard_options.py @@ -47,8 +47,7 @@ def split_opt_line(line): index = line.index("=") key = line[:index].strip() default = line[index + 1 :].strip() - if default.startswith("_("): - default = default[2:] + default = default.removeprefix("_(") return key, default def parse_glines(glines): diff --git a/mswindows/README.html b/mswindows/README.html index 2b6f87db703..91be0f9afbb 100644 --- a/mswindows/README.html +++ b/mswindows/README.html @@ -7,7 +7,7 @@ Instructions how to prepare a WinGRASS package installer has been moved to -the wiki +the wiki page. diff --git a/mswindows/external/rbatch/R.bat b/mswindows/external/rbatch/R.bat index d55a6b395a8..fd28421d126 100644 --- a/mswindows/external/rbatch/R.bat +++ b/mswindows/external/rbatch/R.bat @@ -1,7 +1,7 @@ @Echo OFF :: Software and documentation is (c) 2013 GKX Associates Inc. and -:: licensed under [GPL 2.0](http://www.gnu.org/licenses/gpl-2.0.html). +:: licensed under [GPL 2.0](https://www.gnu.org/licenses/gpl-2.0.html). :: Help is at bottom of script or just run script with single argument: help @@ -520,7 +520,7 @@ goto:eof :Rhelp echo (c) 2013 G. Grothendieck -echo License: GPL 2.0 ( http://www.gnu.org/licenses/gpl-2.0.html ) +echo License: GPL 2.0 ( https://www.gnu.org/licenses/gpl-2.0.html ) echo Launch script for R and associated functions. echo Usage: R.bat [subcommand] [arguments] echo Subcommands where (0) means takes no arguments; (A) means may need Admin priv diff --git a/mswindows/external/rbatch/README.grass b/mswindows/external/rbatch/README.grass index 85f32b7a9be..40bc7a307a7 100644 --- a/mswindows/external/rbatch/README.grass +++ b/mswindows/external/rbatch/README.grass @@ -13,7 +13,7 @@ at svn-revision 104 (2012-08-31). -- -See http://trac.osgeo.org/grass/ticket/1149#comment:9 +See https://trac.osgeo.org/grass/ticket/1149#comment:9 -- diff --git a/mswindows/external/rbatch/Rpathset.bat b/mswindows/external/rbatch/Rpathset.bat index 7873fc01907..590e9a58980 100644 --- a/mswindows/external/rbatch/Rpathset.bat +++ b/mswindows/external/rbatch/Rpathset.bat @@ -1,5 +1,5 @@ :: Software and documentation is (c) 2013 GKX Associates Inc. and -:: licensed under [GPL 2.0](http://www.gnu.org/licenses/gpl-2.0.html). +:: licensed under [GPL 2.0](https://www.gnu.org/licenses/gpl-2.0.html). :: Purpose: setup path to use R, Rtools and other utilities from cmd line. :: diff --git a/mswindows/external/rbatch/batchfiles.md b/mswindows/external/rbatch/batchfiles.md index 2c10e2bcf75..de26ff2748f 100644 --- a/mswindows/external/rbatch/batchfiles.md +++ b/mswindows/external/rbatch/batchfiles.md @@ -3,7 +3,7 @@ G. Grothendieck Software and documentation is (c) 2013 GKX Associates Inc. and licensed -under [GPL 2.0](http://www.gnu.org/licenses/gpl-2.0.html). +under [GPL 2.0](https://www.gnu.org/licenses/gpl-2.0.html). ## Introduction ## diff --git a/mswindows/external/rbatch/batchfiles.tex b/mswindows/external/rbatch/batchfiles.tex index da8d64664b7..acfa8c6e634 100644 --- a/mswindows/external/rbatch/batchfiles.tex +++ b/mswindows/external/rbatch/batchfiles.tex @@ -3,7 +3,7 @@ \section{Windows Batch Files for R} G. Grothendieck Software and documentation is (c) 2013 GKX Associates Inc. and licensed -under \href{http://www.gnu.org/licenses/gpl-2.0.html}{GPL 2.0}. +under \href{https://www.gnu.org/licenses/gpl-2.0.html}{GPL 2.0}. \subsection{Introduction} diff --git a/mswindows/external/rbatch/copydir.bat b/mswindows/external/rbatch/copydir.bat index f346560b3f0..9ab646e6e0c 100644 --- a/mswindows/external/rbatch/copydir.bat +++ b/mswindows/external/rbatch/copydir.bat @@ -1,6 +1,6 @@ @echo off :: Software and documentation is (c) 2013 GKX Associates Inc. and -:: licensed under [GPL 2.0](http://www.gnu.org/licenses/gpl-2.0.html). +:: licensed under [GPL 2.0](https://www.gnu.org/licenses/gpl-2.0.html). setlocal if not "%2"=="" goto:run echo Usage: copydir fromdir todir diff --git a/mswindows/external/rbatch/movedir.bat b/mswindows/external/rbatch/movedir.bat index 104d6a0d5f0..57fb0a7a498 100644 --- a/mswindows/external/rbatch/movedir.bat +++ b/mswindows/external/rbatch/movedir.bat @@ -1,6 +1,6 @@ @echo off :: Software and documentation is (c) 2013 GKX Associates Inc. and -:: licensed under [GPL 2.0](http://www.gnu.org/licenses/gpl-2.0.html). +:: licensed under [GPL 2.0](https://www.gnu.org/licenses/gpl-2.0.html). setlocal if not "%2"=="" goto:run echo Usage: copydir fromdir todir diff --git a/mswindows/osgeo4w/build_osgeo4w.sh b/mswindows/osgeo4w/build_osgeo4w.sh index 6885bfe02f8..d38354d4b78 100755 --- a/mswindows/osgeo4w/build_osgeo4w.sh +++ b/mswindows/osgeo4w/build_osgeo4w.sh @@ -38,7 +38,7 @@ export ARCH=x86_64-w64-mingw32 --with-nls \ --with-readline \ --with-blas \ - --with-lapack-includes=/mingw64/include/lapack \ + --with-lapack \ --with-freetype \ --with-freetype-includes=${OSGEO4W_ROOT_MSYS}/include/freetype2 \ --with-proj-share=${OSGEO4W_ROOT_MSYS}/share/proj \ diff --git a/ps/ps.map/do_geogrid.c b/ps/ps.map/do_geogrid.c index 0fac5f80cac..c22ef86379c 100644 --- a/ps/ps.map/do_geogrid.c +++ b/ps/ps.map/do_geogrid.c @@ -300,6 +300,7 @@ void get_ll_bounds(double *w, double *e, double *s, double *n) double ew, ns; int first; + east = west = north = south = 0.0; e1 = PS.w.east; w1 = PS.w.west; n1 = PS.w.north; diff --git a/ps/ps.map/do_scalebar.c b/ps/ps.map/do_scalebar.c index a53325172f3..760a6825288 100644 --- a/ps/ps.map/do_scalebar.c +++ b/ps/ps.map/do_scalebar.c @@ -2,6 +2,7 @@ #include #include +#include #include #include "local_proto.h" #include "distance.h" @@ -182,17 +183,17 @@ int do_scalebar(void) /* draw units label */ if (sb.units == SB_UNITS_AUTO) - strcpy(num, G_database_unit_name(TRUE)); + (void)G_strlcpy(num, G_database_unit_name(TRUE), sizeof(num)); else if (sb.units == SB_UNITS_METERS) - strcpy(num, _("meters")); + (void)G_strlcpy(num, _("meters"), sizeof(num)); else if (sb.units == SB_UNITS_KM) - strcpy(num, _("kilometers")); + (void)G_strlcpy(num, _("kilometers"), sizeof(num)); else if (sb.units == SB_UNITS_FEET) - strcpy(num, _("feet")); + (void)G_strlcpy(num, _("feet"), sizeof(num)); else if (sb.units == SB_UNITS_MILES) - strcpy(num, _("miles")); + (void)G_strlcpy(num, _("miles"), sizeof(num)); else if (sb.units == SB_UNITS_NMILES) - strcpy(num, _("nautical miles")); + (void)G_strlcpy(num, _("nautical miles"), sizeof(num)); text_box_path(72.0 * (x + length / 2), 72.0 * (PS.page_height - (sb.y + 0.075)), CENTER, UPPER, num, diff --git a/ps/ps.map/ps_vareas.c b/ps/ps.map/ps_vareas.c index 5cd3471a6a8..3968140bd25 100644 --- a/ps/ps.map/ps_vareas.c +++ b/ps/ps.map/ps_vareas.c @@ -65,6 +65,7 @@ static int plot_area(struct Map_info *P_map, int area, double shift) if (0 > (ret = Vect_get_area_points(P_map, area, Points))) { if (ret == -1) G_warning(_("Read error in vector map")); + Vect_destroy_line_struct(Points); return 0; } construct_path(Points, shift, WHOLE_PATH); @@ -76,10 +77,12 @@ static int plot_area(struct Map_info *P_map, int area, double shift) if (0 > (ret = Vect_get_isle_points(P_map, island, Points))) { if (ret == -1) G_warning(_("Read error in vector map")); + Vect_destroy_line_struct(Points); return -1; } construct_path(Points, shift, WHOLE_PATH); } + Vect_destroy_line_struct(Points); return 1; } diff --git a/ps/ps.map/ps_vpoints.c b/ps/ps.map/ps_vpoints.c index 80b29a349b1..cd320b46f11 100644 --- a/ps/ps.map/ps_vpoints.c +++ b/ps/ps.map/ps_vpoints.c @@ -268,5 +268,6 @@ int PS_vpoints_plot(struct Map_info *P_map, int vec) } /* for (line) */ fprintf(PS.fp, "\n"); + Vect_destroy_cats_struct(Cats); return 0; } diff --git a/ps/ps.map/r_instructions.c b/ps/ps.map/r_instructions.c index 0e2c012fd92..87a2e4bbfcf 100644 --- a/ps/ps.map/r_instructions.c +++ b/ps/ps.map/r_instructions.c @@ -29,7 +29,7 @@ static char *help[] = { "read unix-file eps Encapsulated PostScript file", "border [y|n] mapinfo map information", "window region definition region region definition", - "maskcolor MASK color", + "maskcolor mask color", "rectangle east north east north", "scale 1:#|# inches|# panels|1 inch = # miles", "outline map composition outline", diff --git a/pyproject.toml b/pyproject.toml index eb866cb0e08..d739653809e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ requires-python = ">=3.9" [tool.black] required-version = '24' line-length = 88 -target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] +target-version = ['py39', 'py310', 'py311', 'py312', 'py313'] # 'extend-exclude' excludes files or directories in addition to the defaults extend-exclude = ''' ( @@ -34,9 +34,7 @@ select = [ "COM", # flake8-commas (COM) "D", # pydocstyle (D) "DTZ", # flake8-datetimez (DTZ) - "E4", # pycodestyle (E, W) - "E7", # pycodestyle (E, W) - "E9", # pycodestyle (E, W) + "E", # pycodestyle (E, W) "F", # Pyflakes (F) "FA", # flake8-future-annotations (FA) "FBT", # flake8-boolean-trap (FBT) @@ -48,6 +46,7 @@ select = [ "INT", # flake8-gettext (INT) "ISC", # flake8-implicit-str-concat (ISC) "LOG", # flake8-logging (LOG) + "N", # pep8-naming (N) "NPY", # NumPy-specific rules (NPY) "PERF", # Perflint (PERF) "PGH", # pygrep-hooks (PGH) @@ -98,9 +97,7 @@ ignore = [ "B904", # raise-without-from-inside-except "B909", # loop-iterator-mutation "BLE001", # blind-except - "C404", # unnecessary-list-comprehension-dict "C414", # unnecessary-double-cast-or-process - "C416", # unnecessary-comprehension "COM812", # missing-trailing-comma "COM818", # trailing-comma-on-bare-tuple "D1", @@ -128,16 +125,14 @@ ignore = [ "DTZ006", # call-datetime-fromtimestamp "DTZ007", # call-datetime-strptime-without-zone "DTZ011", # call-date-today - "E401", # multiple-imports-on-one-line "E402", # module-import-not-at-top-of-file + "E501", # line-too-long "E721", # type-comparison "E722", # bare-except "E731", # lambda-assignment "E741", # ambiguous-variable-name - "F401", # unused-import "F403", # undefined-local-with-import-star "F405", # undefined-local-with-import-star-usage - "F601", # multi-value-repeated-key-literal "F811", # redefined-while-unused "F821", # undefined-name "F822", # undefined-export @@ -145,16 +140,23 @@ ignore = [ "FBT001", # boolean-type-hint-positional-argument "FBT002", # boolean-default-value-positional-argument "FBT003", # boolean-positional-value-in-call - "FURB118", # reimplemented-operator "I001", # unsorted-imports "ISC003", # explicit-string-concatenation + "N801", # invalid-class-name + "N802", # invalid-function-name + "N803", # invalid-argument-name + "N806", # non-lowercase-variable-in-function + "N812", # lowercase-imported-as-non-lowercase + "N814", # camelcase-imported-as-constant + "N815", # mixed-case-variable-in-class-scope + "N816", # mixed-case-variable-in-global-scope + "N818", # error-suffix-on-exception-name + "N999", # invalid-module-name "PERF203", # try-except-in-loop "PERF401", # manual-list-comprehension "PERF402", # manual-list-copy "PERF403", # manual-dict-comprehension "PIE794", # duplicate-class-field-definition - "PIE808", # unnecessary-range-start - "PIE810", # multiple-starts-ends-with "PLC0415", # import-outside-top-level "PLC1901", # compare-to-empty-string "PLC2701", # import-private-name @@ -181,13 +183,7 @@ ignore = [ "PLW1641", # eq-without-hash "PLW2901", # redefined-loop-name "PLW3201", # bad-dunder-method-name - "PT001", # pytest-fixture-incorrect-parentheses-style - "PT004", # pytest-missing-fixture-name-underscore - "PT006", # pytest-parametrize-names-wrong-type - "PT009", # pytest-unittest-assertion - "PT011", # pytest-raises-too-broad - "PT018", # pytest-composite-assertion - "PT023", # pytest-incorrect-mark-parentheses-style + "PT004", # pytest-missing-fixture-name-underscore # deprecated, so doesn't appear with --preview "PTH100", # os-path-abspath "PTH101", # os-chmod "PTH102", # os-mkdir @@ -196,12 +192,10 @@ ignore = [ "PTH106", # os-rmdir "PTH107", # os-remove "PTH108", # os-unlink - "PTH109", # os-getcwd "PTH110", # os-path-exists "PTH111", # os-path-expanduser "PTH112", # os-path-isdir "PTH113", # os-path-isfile - "PTH116", # os-stat "PTH117", # os-path-isabs "PTH118", # os-path-join "PTH119", # os-path-basename @@ -214,11 +208,6 @@ ignore = [ "RET501", # unnecessary-return-none "RET502", # implicit-return-value "RET503", # implicit-return - "RET505", # superfluous-else-return - "RET506", # superfluous-else-raise - "RET507", # superfluous-else-continue - "RET508", # superfluous-else-break - "RSE102", # unnecessary-paren-on-raise-exception "RUF003", # ambiguous-unicode-character-comment "RUF005", # collection-literal-concatenation "RUF012", # mutable-class-default @@ -247,20 +236,12 @@ ignore = [ "S606", # start-process-with-no-shell "S607", # start-process-with-partial-path "S608", # hardcoded-sql-expression - "SIM101", # duplicate-isinstance-call "SIM102", # collapsible-if "SIM105", # suppressible-exception - "SIM108", # if-else-block-instead-of-if-exp - "SIM109", # compare-with-tuple - "SIM110", # reimplemented-builtin "SIM113", # enumerate-for-loop - "SIM114", # if-with-same-arms - "SIM115", # open-file-with-context-handler "SIM116", # if-else-block-instead-of-dict-lookup "SIM118", # in-dict-keys - "SIM201", # negate-equal-op "SIM223", # expr-and-false - "SIM401", # if-else-block-instead-of-dict-get "SLF001", # private-member-access "TRY002", # raise-vanilla-class "TRY003", # raise-vanilla-args @@ -268,142 +249,127 @@ ignore = [ "TRY201", # verbose-raise "TRY300", # try-consider-else "TRY301", # raise-within-try - "UP015", # redundant-open-modes "UP030", # format-literals "UP031", # printf-string-formatting "UP032", # f-string "UP036", # outdated-version-block - "W605", # invalid-escape-sequence ] [tool.ruff.lint.per-file-ignores] # See https://docs.astral.sh/ruff/settings/#lint_per-file-ignores # "A005", # builtin-module-shadowing -# "INT002", # f-string-in-get-text-func-call -# "INT001", # format-in-get-text-func-call -# "INT003", # printf-in-get-text-func-call # "PLW0108", # unnecessary-lambda # Ignore `E402` (import violations) in all `__init__.py` files "*/testsuite/**.py" = ["PT009", "PT027"] "__init__.py" = ["E402"] -"general/g.parser/test.py" = ["INT003"] +"display/d.mon/render_cmd.py" = ["SIM115"] "gui/**" = ["PLW0108"] # See https://github.com/OSGeo/grass/issues/4124 -"gui/wxpython/animation/dialogs.py" = ["INT002"] -"gui/wxpython/animation/temporal_manager.py" = ["INT003"] -"gui/wxpython/core/debug.py" = ["INT002"] -"gui/wxpython/core/render.py" = ["INT003"] -"gui/wxpython/gcp/manager.py" = ["INT002"] -"gui/wxpython/gmodeler/model.py" = ["INT001"] -"gui/wxpython/gmodeler/panels.py" = ["INT002", "INT003"] -"gui/wxpython/gui_core/ghelp.py" = ["INT003"] -"gui/wxpython/gui_core/gselect.py" = ["INT002"] -"gui/wxpython/gui_core/pyedit.py" = ["INT002"] -"gui/wxpython/gui_core/pystc.py" = ["INT002"] -"gui/wxpython/gui_core/query.py" = ["INT003"] -"gui/wxpython/history/browser.py" = ["INT002"] -"gui/wxpython/iclass/dialogs.py" = ["INT003"] -"gui/wxpython/iclass/frame.py" = ["FLY002", "INT003"] -"gui/wxpython/iclass/plots.py" = ["INT003"] +"gui/wxpython/animation/temporal_manager.py" = ["SIM115"] +"gui/wxpython/core/*.py" = ["SIM115"] +"gui/wxpython/dbmgr/base.py" = ["SIM115"] +"gui/wxpython/gcp/manager.py" = ["SIM115"] +"gui/wxpython/gmodeler/*.py" = ["SIM115"] +"gui/wxpython/gui_core/*.py" = ["SIM115"] +"gui/wxpython/iclass/frame*.py" = ["SIM115"] +"gui/wxpython/iclass/frame.py" = ["FLY002"] "gui/wxpython/iclass/statistics.py" = ["A005"] -"gui/wxpython/image2target/ii2t_gis_set.py" = ["INT003"] -"gui/wxpython/iscatt/controllers.py" = ["INT003"] -"gui/wxpython/iscatt/dialogs.py" = ["INT003"] -"gui/wxpython/iscatt/frame.py" = ["INT003"] -"gui/wxpython/iscatt/iscatt_core.py" = ["INT003"] +"gui/wxpython/image2target/*.py" = ["SIM115"] "gui/wxpython/iscatt/plots.py" = ["PLW0108"] -"gui/wxpython/lmgr/frame.py" = ["INT003"] -"gui/wxpython/lmgr/workspace.py" = ["INT002"] -"gui/wxpython/location_wizard/dialogs.py" = ["INT003"] -"gui/wxpython/location_wizard/wizard.py" = ["INT003"] -"gui/wxpython/main_window/frame.py" = ["INT003"] -"gui/wxpython/mapdisp/frame.py" = ["INT003"] -"gui/wxpython/mapdisp/test_mapdisp.py" = ["INT003"] -"gui/wxpython/mapwin/analysis.py" = ["INT003"] +"gui/wxpython/lmgr/workspace.py" = ["SIM115"] +"gui/wxpython/location_wizard/wizard.py" = ["SIM115"] +"gui/wxpython/mapdisp/main.py" = ["SIM115"] +"gui/wxpython/modules/colorrules.py" = ["SIM115"] +"gui/wxpython/modules/mcalc_builder.py" = ["SIM115"] +"gui/wxpython/photo2image/*.py" = ["SIM115"] +"gui/wxpython/psmap/*.py" = ["SIM115"] "gui/wxpython/psmap/utils.py" = ["PGH004"] -"gui/wxpython/rdigit/g.gui.rdigit.py" = ["INT002"] -"gui/wxpython/rlisetup/frame.py" = ["INT002"] -"gui/wxpython/rlisetup/functions.py" = ["INT003"] -"gui/wxpython/rlisetup/wizard.py" = ["INT003"] -"gui/wxpython/startup/locdownload.py" = ["INT002"] -"gui/wxpython/timeline/frame.py" = ["FLY002", "INT003"] -"gui/wxpython/tplot/frame.py" = ["FLY002", "INT002", "INT003"] -"gui/wxpython/vnet/vnet_data.py" = ["INT003"] -"gui/wxpython/web_services/dialogs.py" = ["INT003"] -"gui/wxpython/web_services/widgets.py" = ["INT003"] -"gui/wxpython/wxgui.py" = ["INT002"] +"gui/wxpython/rdigit/controller.py" = ["SIM115"] +"gui/wxpython/rlisetup/*.py" = ["SIM115"] +"gui/wxpython/timeline/frame.py" = ["FLY002"] +"gui/wxpython/tools/update_menudata.py" = ["SIM115"] +"gui/wxpython/tplot/frame.py" = ["FLY002"] +"gui/wxpython/vdigit/mapwindow.py" = ["SIM115"] +"gui/wxpython/vnet/*.py" = ["SIM115"] +"gui/wxpython/web_services/dialogs.py" = ["SIM115"] +"gui/wxpython/wxplot/profile*.py" = ["SIM115"] "gui/wxpython/wxplot/profile.py" = ["A005"] +"imagery/i.atcorr/create_iwave.py" = ["SIM115"] +"lib/imagery/testsuite/test_imagery_signature_management.py" = ["SIM115"] "lib/imagery/testsuite/test_imagery_sigsetfile.py" = ["FURB152"] -"lib/init/grass.py" = ["INT003"] +"lib/init/grass.py" = ["SIM115"] +"locale/grass_po_stats.py" = ["SIM115"] +"man/build_*.py" = ["SIM115"] +"man/parser_standard_options.py" = ["SIM115"] "python/grass/__init__.py" = ["PYI056"] "python/grass/exp*/tests/grass_script_mapset_session_test.py" = ["SIM117"] "python/grass/exp*/tests/grass_script_tmp_mapset_session_test.py" = ["SIM117"] +"python/grass/gunittest/case.py" = ["PT009"] "python/grass/gunittest/loader.py" = ["PYI024"] "python/grass/gunittest/multireport.py" = ["PYI024"] "python/grass/gunittest/testsu*/d*/s*/s*/subsub*/t*/test_segfaut.py" = ["B018"] "python/grass/gunittest/testsuite/test_assertions_rast3d.py" = ["FLY002"] -"python/grass/jupyter/tests/reprojection_renderer_test.py" = ["PT013"] +"python/grass/imaging/images2*.py" = ["SIM115"] "python/grass/jupyter/testsuite/interactivemap_test.py" = ["PGH004"] "python/grass/jupyter/testsuite/map_test.py" = ["PGH004"] "python/grass/pydispatch/signal.py" = ["A005"] -"python/grass/pygrass/raster/category.py" = ["INT002"] -"python/grass/pygrass/vector/__init__.py" = ["INT003"] +"python/grass/pygrass/modules/grid/grid.py" = ["SIM115"] +"python/grass/pygrass/modules/grid/testsuite/test_*_modules_grid_doctests.py" = ["F401"] +"python/grass/pygrass/modules/interface/env.py" = ["SIM115"] +"python/grass/pygrass/modules/testsuite/test_pygrass_modules_doctests.py" = ["F401"] +"python/grass/pygrass/raster/segment.py" = ["SIM115"] +"python/grass/pygrass/tests/*.py" = ["SIM115"] "python/grass/pygrass/vector/geometry.py" = ["PYI024"] "python/grass/pygrass/vector/sql.py" = ["FLY002"] "python/grass/pygrass/vector/testsuite/test_table.py" = ["PLW0108"] "python/grass/script/array.py" = ["A005"] -"python/grass/script/raster.py" = ["INT003"] -"python/grass/temporal/abstract_space_time_dataset.py" = ["INT003"] -"python/grass/temporal/aggregation.py" = ["INT003"] -"python/grass/temporal/c_libraries_interface.py" = ["INT003"] -"python/grass/temporal/core.py" = ["INT002", "INT003"] -"python/grass/temporal/datetime_math.py" = ["INT003"] -"python/grass/temporal/mapcalc.py" = ["INT003"] -"python/grass/temporal/space_time_datasets.py" = ["INT003"] -"python/grass/temporal/stds_export.py" = ["INT003"] -"python/grass/temporal/stds_import.py" = ["INT003"] -"python/grass/temporal/temporal_algebra.py" = ["INT003"] -"python/grass/temporal/temporal_raster_base_algebra.py" = ["INT003"] -"python/grass/temporal/univar_statistics.py" = ["INT002"] +"python/grass/script/core.py" = ["SIM115"] +"python/grass/script/db.py" = ["SIM115"] +"python/grass/script/raster.py" = ["SIM115"] +"python/grass/script/utils.py" = ["SIM115"] +"python/grass/temporal/aggregation.py" = ["SIM115"] +"python/grass/temporal/register.py" = ["SIM115"] +"python/grass/temporal/stds_export.py" = ["SIM115"] +"python/grass/temporal/stds_import.py" = ["SIM115"] +"python/grass/temporal/univar_statistics.py" = ["SIM115"] +"python/grass/utils/download.py" = ["SIM115"] +"raster/r.*/testsuite/*.py" = ["SIM115"] +"raster/r.topidx/*.py" = ["SIM115"] "raster3d/r3.flow/testsuite/r3flow_test.py" = ["FLY002"] "raster3d/r3.gradient/testsuite/r3gradient_test.py" = ["FLY002"] -"scripts/d.polar/d.polar.py" = ["FURB154", "INT002"] -"scripts/g.extension.all/g.extension.all.py" = ["INT002"] -"scripts/g.extension/g.extension.py" = ["INT002"] -"scripts/i.oif/i.oif.py" = ["INT003"] -"scripts/i.pansharpen/i.pansharpen.py" = ["FLY002", "INT003"] -"scripts/i.spectral/i.spectral.py" = ["FLY002", "INT002"] -"scripts/r.in.srtm/r.in.srtm.py" = ["FLY002"] -"scripts/r.in.wms/wms_base.py" = ["INT003"] -"scripts/r.in.wms/wms_cap_parsers.py" = ["INT003"] -"scripts/r.in.wms/wms_drv.py" = ["INT003"] -"scripts/r.in.wms/wms_gdal_drv.py" = ["INT003"] -"scripts/r.pack/r.pack.py" = ["INT003"] -"scripts/r.tileset/r.tileset.py" = ["INT003"] -"scripts/r.unpack/r.unpack.py" = ["INT002"] -"scripts/v.rast.stats/v.rast.stats.py" = ["INT002"] -"scripts/v.to.lines/v.to.lines.py" = ["INT003"] -"scripts/v.unpack/v.unpack.py" = ["INT002", "INT003"] -"scripts/v.what.strds/v.what.strds.py" = ["INT003"] -"temporal/t.rast.accdetect/t.rast.accdetect.py" = ["INT003"] -"temporal/t.rast.accumulate/t.rast.accumulate.py" = ["INT003"] +"scripts/d.correlate/d.correlate.py" = ["SIM115"] +"scripts/d.frame/d.frame.py" = ["SIM115"] +"scripts/d.polar/d.polar.py" = ["FURB154", "SIM115"] +"scripts/db.in.ogr/db.in.ogr.py" = ["SIM115"] +"scripts/db.test/db.test.py" = ["SIM115"] +"scripts/db.univar/db.univar.py" = ["SIM115"] +"scripts/g.extension.all/g.extension.all.py" = ["SIM115"] +"scripts/g.extension/g.extension.py" = ["SIM115"] +"scripts/g.search.modules/g.search.modules.py" = ["SIM115"] +"scripts/i.in.spotvgt/i.in.spotvgt.py" = ["SIM115"] +"scripts/i.oif/i.oif*.py" = ["SIM115"] +"scripts/i.pansharpen/i.pansharpen.py" = ["FLY002", "SIM115"] +"scripts/i.spectral/i.spectral.py" = ["FLY002", "SIM115"] +"scripts/m.proj/m.proj.py" = ["SIM115"] +"scripts/r.fillnulls/r.fillnulls.py" = ["SIM115"] +"scripts/r.in.srtm/r.in.srtm.py" = ["FLY002", "SIM115"] +"scripts/r.in.wms/wms_*.py" = ["SIM115"] +"scripts/r.tileset/r.tileset.py" = ["SIM115"] +"scripts/v.*/v.*.py" = ["SIM115"] +"scripts/wxpyimgview/wxpyimgview_gui.py" = ["SIM115"] +"temporal/t.list/t.list.py" = ["SIM115"] "temporal/t.rast.algebra/testsu*/*_algebra_arithmetic.py" = ["FLY002"] -"temporal/t.rast.export/t.rast.export.py" = ["INT002"] -"temporal/t.rast.gapfill/t.rast.gapfill.py" = ["INT003"] -"temporal/t.rast.list/t.rast.list.py" = ["INT002"] -"temporal/t.rast.out.vtk/t.rast.out.vtk.py" = ["INT003"] -"temporal/t.rast.series/t.rast.series.py" = ["INT002"] -"temporal/t.rast.to.rast3/t.rast.to.rast3.py" = ["INT003"] -"temporal/t.rast.what/t.rast.what.py" = ["INT003"] +"temporal/t.rast.colors/t.rast.colors.py" = ["SIM115"] +"temporal/t.rast.series/t.rast.series.py" = ["SIM115"] +"temporal/t.rast.what/t.rast.what.py" = ["SIM115"] "temporal/t.register/testsu*/*_raster_different_local.py" = ["FLY002"] "temporal/t.register/testsu*/*_raster_mapmetadata.py" = ["FLY002"] "temporal/t.register/testsuite/test_t_register_raster.py" = ["FLY002"] "temporal/t.register/testsuite/test_t_register_raster_file.py" = ["FLY002"] -"temporal/t.remove/t.remove.py" = ["INT002", "INT003"] -"temporal/t.unregister/t.unregister.py" = ["INT003"] -"temporal/t.vect.observe.strds/t.vect.observe.strds.py" = ["INT003"] +"temporal/t.remove/t.remove.py" = ["SIM115"] +"temporal/t.unregister/t.unregister.py" = ["SIM115"] +"utils/**.py" = ["SIM115"] "utils/generate_release_notes.py" = ["PGH004"] -"utils/mkhtml.py" = ["INT002"] "vector/v.fill.holes/examples.ipynb" = ["PTH201"] [tool.ruff.lint.flake8-import-conventions.extend-aliases] diff --git a/python/grass/app/data.py b/python/grass/app/data.py index 439a6c3c4d1..10997cd59e8 100644 --- a/python/grass/app/data.py +++ b/python/grass/app/data.py @@ -15,8 +15,12 @@ import os import tempfile import getpass +import subprocess import sys from shutil import copytree, ignore_patterns +from pathlib import Path + +import grass.script as gs import grass.grassdb.config as cfg from grass.grassdb.checks import is_location_valid @@ -162,3 +166,69 @@ def ensure_default_data_hierarchy(): mapset_path = os.path.join(gisdbase, location, mapset) return gisdbase, location, mapset, mapset_path + + +class MapsetLockingException(Exception): + pass + + +def lock_mapset(mapset_path, force_lock_removal, message_callback): + """Acquire a lock for a mapset and return name of new lock file + + Raises MapsetLockingException when it is not possible to acquire a lock for the + given mapset either because of existing lock or due to insufficient permissions. + A corresponding localized message is given in the exception. + + A *message_callback* is a function which will be called to report messages about + certain states. Specifically, the function is called when forcibly unlocking the + mapset. + + Assumes that the runtime is set up (specifically that GISBASE is in + the environment). + """ + if not os.path.exists(mapset_path): + raise MapsetLockingException(_("Path '{}' doesn't exist").format(mapset_path)) + if not os.access(mapset_path, os.W_OK): + error = _("Path '{}' not accessible.").format(mapset_path) + stat_info = Path(mapset_path).stat() + mapset_uid = stat_info.st_uid + if mapset_uid != os.getuid(): + error = "{error}\n{detail}".format( + error=error, + detail=_("You are not the owner of '{}'.").format(mapset_path), + ) + raise MapsetLockingException(error) + # Check for concurrent use + lockfile = os.path.join(mapset_path, ".gislock") + locker_path = os.path.join(os.environ["GISBASE"], "etc", "lock") + ret = subprocess.run( + [locker_path, lockfile, "%d" % os.getpid()], check=False + ).returncode + msg = None + if ret == 2: + if not force_lock_removal: + msg = _( + "{user} is currently running GRASS in selected mapset" + " (file {file} found). Concurrent use of one mapset not allowed.\n" + "You can force launching GRASS using -f flag" + " (assuming your have sufficient access permissions)." + " Confirm in a process manager " + "that there is no other process using the mapset." + ).format(user=Path(lockfile).owner(), file=lockfile) + else: + message_callback( + _( + "{user} is currently running GRASS in selected mapset" + " (file {file} found), but forcing to launch GRASS anyway..." + ).format(user=Path(lockfile).owner(), file=lockfile) + ) + gs.try_remove(lockfile) + elif ret != 0: + msg = _( + "Unable to properly access lock file '{name}'.\n" + "Please resolve this with your system administrator." + ).format(name=lockfile) + + if msg: + raise MapsetLockingException(msg) + return lockfile diff --git a/python/grass/app/runtime.py b/python/grass/app/runtime.py index 3f3805c9dfd..27f35760b8f 100644 --- a/python/grass/app/runtime.py +++ b/python/grass/app/runtime.py @@ -79,10 +79,7 @@ def append_left_addon_paths(paths, config_dir, env): # addons (base) addon_base = env.get("GRASS_ADDON_BASE") if not addon_base: - if MACOS: - name = "Addons" - else: - name = "addons" + name = "addons" if not MACOS else "Addons" addon_base = os.path.join(config_dir, name) env["GRASS_ADDON_BASE"] = addon_base @@ -174,10 +171,7 @@ def set_python_path_variable(install_path, env): """Set PYTHONPATH to find GRASS Python package in subprocesses""" path = env.get("PYTHONPATH") etcpy = os.path.join(install_path, "etc", "python") - if path: - path = etcpy + os.pathsep + path - else: - path = etcpy + path = etcpy + os.pathsep + path if path else etcpy env["PYTHONPATH"] = path diff --git a/python/grass/benchmark/__init__.py b/python/grass/benchmark/__init__.py index a4a7bf4e991..62a6a85c3e1 100644 --- a/python/grass/benchmark/__init__.py +++ b/python/grass/benchmark/__init__.py @@ -34,3 +34,17 @@ save_results_to_file, ) from .runners import benchmark_nprocs, benchmark_resolutions, benchmark_single + +__all__ = [ + "benchmark_nprocs", + "benchmark_resolutions", + "benchmark_single", + "join_results", + "join_results_from_files", + "load_results", + "load_results_from_file", + "nprocs_plot", + "num_cells_plot", + "save_results", + "save_results_to_file", +] diff --git a/python/grass/benchmark/app.py b/python/grass/benchmark/app.py index 09cdf3f9481..835fc0d544b 100644 --- a/python/grass/benchmark/app.py +++ b/python/grass/benchmark/app.py @@ -47,11 +47,7 @@ def join_results_cli(args): def select_only(result): return result.label == args.only - if args.only: - select_function = select_only - else: - select_function = None - + select_function = select_only if args.only else None results = join_results_from_files( source_filenames=args.results, prefixes=args.prefixes, diff --git a/python/grass/benchmark/plots.py b/python/grass/benchmark/plots.py index 9483fda9116..24afcbcfbae 100644 --- a/python/grass/benchmark/plots.py +++ b/python/grass/benchmark/plots.py @@ -25,10 +25,7 @@ def get_pyplot(to_file): """ import matplotlib as mpl # pylint: disable=import-outside-toplevel - if to_file: - backend = "agg" - else: - backend = None + backend = "agg" if to_file else None if backend: mpl.use(backend) @@ -124,10 +121,7 @@ def num_cells_plot(results, filename=None, title=None, show_resolution=False): x_ticks = set() for result in results: - if show_resolution: - x = result.resolutions - else: - x = result.cells + x = result.resolutions if show_resolution else result.cells x_ticks.update(x) plt.plot(x, result.times, label=result.label) if hasattr(result, "all_times"): diff --git a/python/grass/docs/src/pygrass_index.rst b/python/grass/docs/src/pygrass_index.rst index 9e782e4c452..844e5578ae8 100644 --- a/python/grass/docs/src/pygrass_index.rst +++ b/python/grass/docs/src/pygrass_index.rst @@ -46,7 +46,7 @@ References Resources Analysis Support System (GRASS) Geographic Information System (GIS)*. ISPRS International Journal of Geo-Information. 2(1):201-219. `doi:10.3390/ijgi2010201 - `_ + `_ * `Python related articles in the GRASS GIS Wiki `_ * `GRASS GIS 8 Programmer's Manual @@ -54,7 +54,7 @@ References This project has been funded with support from the `Google Summer of Code 2012 -`_ +`_ .. Indices and tables diff --git a/python/grass/docs/src/pygrass_modules.rst b/python/grass/docs/src/pygrass_modules.rst index a668739a34f..854119057d6 100644 --- a/python/grass/docs/src/pygrass_modules.rst +++ b/python/grass/docs/src/pygrass_modules.rst @@ -200,4 +200,4 @@ Multiple GRASS modules can be joined into one object by :class:`~pygrass.modules.interface.module.MultiModule`. -.. _Popen: http://docs.python.org/library/subprocess.html#Popen +.. _Popen: https://docs.python.org/library/subprocess.html#Popen diff --git a/python/grass/docs/src/temporal_framework.rst b/python/grass/docs/src/temporal_framework.rst index 7e68de132a9..2443098b26a 100644 --- a/python/grass/docs/src/temporal_framework.rst +++ b/python/grass/docs/src/temporal_framework.rst @@ -414,7 +414,7 @@ Temporal shifting References ---------- -* Gebbert, S., Pebesma, E., 2014. *TGRASS: A temporal GIS for field based environmental modeling*. Environmental Modelling & Software. 2(1):201-219. `doi:10.1016/j.envsoft.2013.11.001 `_ +* Gebbert, S., Pebesma, E., 2014. *TGRASS: A temporal GIS for field based environmental modeling*. Environmental Modelling & Software. 2(1):201-219. `doi:10.1016/j.envsoft.2013.11.001 `_ * `TGRASS related articles in the GRASS GIS Wiki `_ * Supplementary material of the publication *The GRASS GIS Temporal Framework* to be published in diff --git a/python/grass/exceptions/__init__.py b/python/grass/exceptions/__init__.py index b22d0a45c1d..deec48ffd96 100644 --- a/python/grass/exceptions/__init__.py +++ b/python/grass/exceptions/__init__.py @@ -71,13 +71,9 @@ def __init__(self, module, code, returncode, errors=None): """ # CalledProcessError has undocumented constructor super().__init__(returncode, module) - if not module or module in code: - # No need to include module name if it is directly in code - # of if it is not set. - executed = code - else: - # Make sure module name is there if provided and not in code. - executed = f"{module} {code}" + # No need to include module name if it is directly in code of if it is not set. + # Otherwise, make sure module name is there if provided and not in code. + executed = code if not module or module in code else f"{module} {code}" if errors: # We assume actual errors, e.g., captured stderr. err = _("See the following errors:\n{errors}").format(errors=errors) diff --git a/python/grass/experimental/tests/grass_script_mapset_session_test.py b/python/grass/experimental/tests/grass_script_mapset_session_test.py index 3877e61576e..740770937dd 100644 --- a/python/grass/experimental/tests/grass_script_mapset_session_test.py +++ b/python/grass/experimental/tests/grass_script_mapset_session_test.py @@ -68,7 +68,8 @@ def test_create_overwrite(xy_session): .strip() .split() ) - assert len(rasters) == 1 and rasters[0] == "a" + assert len(rasters) == 1 + assert rasters[0] == "a" with experimental.MapsetSession( name, create=True, overwrite=True, env=xy_session.env ) as session: @@ -86,7 +87,8 @@ def test_create_overwrite(xy_session): .strip() .split() ) - assert len(rasters) == 1 and rasters[0] == "a" + assert len(rasters) == 1 + assert rasters[0] == "a" assert os.path.exists(session_file) @@ -103,7 +105,8 @@ def test_ensure(xy_session): .strip() .split() ) - assert len(rasters) == 1 and rasters[0] == "a" + assert len(rasters) == 1 + assert rasters[0] == "a" with experimental.MapsetSession(name, ensure=True, env=xy_session.env) as session: session_mapset = gs.read_command("g.mapset", flags="p", env=session.env).strip() assert name == session_mapset @@ -112,7 +115,8 @@ def test_ensure(xy_session): .strip() .split() ) - assert len(rasters) == 1 and rasters[0] == "a" + assert len(rasters) == 1 + assert rasters[0] == "a" gs.run_command("r.mapcalc", expression="b = 1", env=session.env) rasters = ( gs.read_command("g.list", type="raster", mapset=".", env=session.env) diff --git a/python/grass/experimental/tests/grass_script_tmp_mapset_session_test.py b/python/grass/experimental/tests/grass_script_tmp_mapset_session_test.py index 744becc1e7b..f7098004527 100644 --- a/python/grass/experimental/tests/grass_script_tmp_mapset_session_test.py +++ b/python/grass/experimental/tests/grass_script_tmp_mapset_session_test.py @@ -74,7 +74,7 @@ def test_without_context_manager(xy_session): def test_multiple_sequential_with_context_manager(xy_session): """Session creates, starts, and finishes""" session_file = xy_session.env["GISRC"] - for i in range(0, 5): + for i in range(5): with experimental.TemporaryMapsetSession(env=xy_session.env) as session: assert session.active gs.run_command("g.region", flags="p", env=session.env) @@ -104,7 +104,7 @@ def test_multiple_parallel_without_context_manager(xy_session): """Session creates, starts, and finishes""" session_file = xy_session.env["GISRC"] sessions = [] - for i in range(0, 5): + for i in range(5): session_file = xy_session.env["GISRC"] session = experimental.TemporaryMapsetSession(env=xy_session.env) gs.run_command("g.region", flags="p", env=session.env) diff --git a/python/grass/grassdb/checks.py b/python/grass/grassdb/checks.py index 4de65a4cba3..369cdf60e62 100644 --- a/python/grass/grassdb/checks.py +++ b/python/grass/grassdb/checks.py @@ -113,7 +113,7 @@ def is_current_user_mapset_owner(mapset_path): # Mapset needs to be owned by user. if sys.platform == "win32": return True - stat_info = os.stat(mapset_path) + stat_info = Path(mapset_path).stat() mapset_uid = stat_info.st_uid return mapset_uid == os.getuid() @@ -159,7 +159,7 @@ def is_first_time_user(): genv = gisenv() if "LAST_MAPSET_PATH" in genv.keys(): return genv["LAST_MAPSET_PATH"] == os.path.join( - os.getcwd(), cfg.unknown_location, cfg.unknown_mapset + Path.cwd(), cfg.unknown_location, cfg.unknown_mapset ) return False @@ -222,13 +222,13 @@ def get_reason_id_mapset_not_usable(mapset_path): if not os.path.exists(mapset_path): return "non-existent" # Check whether mapset is valid - elif not is_mapset_valid(mapset_path): + if not is_mapset_valid(mapset_path): return "invalid" # Check whether mapset is owned by current user - elif not is_current_user_mapset_owner(mapset_path): + if not is_current_user_mapset_owner(mapset_path): return "different-owner" # Check whether mapset is locked - elif is_mapset_locked(mapset_path): + if is_mapset_locked(mapset_path): return "locked" return None diff --git a/python/grass/grassdb/history.py b/python/grass/grassdb/history.py index 60b5459700d..d7c22eb36fc 100644 --- a/python/grass/grassdb/history.py +++ b/python/grass/grassdb/history.py @@ -81,9 +81,7 @@ def _read_from_plain_text(history_path): stores only executed commands.""" content_list = [] try: - with open( - history_path, encoding="utf-8", mode="r", errors="replace" - ) as file_history: + with open(history_path, encoding="utf-8", errors="replace") as file_history: content_list = [ {"command": line.strip(), "command_info": None} for line in file_history ] @@ -287,7 +285,7 @@ def _add_entry_to_JSON(history_path, entry): :param dict entry: entry consisting of 'command' and 'command_info' keys """ try: - with open(history_path, encoding="utf-8", mode="r") as file_history: + with open(history_path, encoding="utf-8") as file_history: existing_data = json.load(file_history) except (OSError, ValueError): existing_data = [] diff --git a/python/grass/grassdb/testsuite/test_manage.py b/python/grass/grassdb/testsuite/test_manage.py index a2788d4f1a8..43b8945bd31 100644 --- a/python/grass/grassdb/testsuite/test_manage.py +++ b/python/grass/grassdb/testsuite/test_manage.py @@ -18,6 +18,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.gmodules import call_module from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows class TestMapsetPath(TestCase): @@ -38,6 +39,7 @@ def test_mapset_from_path_object(self): self.assertEqual(mapset_path.mapset, mapset_name) self.assertEqual(mapset_path.path, Path(path) / location_name / mapset_name) + @xfail_windows def test_mapset_from_str(self): """Check with path from str and database directory as Path""" path = "does/not/exist" @@ -60,6 +62,7 @@ def test_mapset_from_str(self): class TestSplitMapsetPath(TestCase): """Check that split works with different parameters""" + @xfail_windows def test_split_path(self): """Check that pathlib.Path is correctly split""" ref_db = "does/not/exist" @@ -71,6 +74,7 @@ def test_split_path(self): self.assertEqual(new_location, ref_location) self.assertEqual(new_mapset, ref_mapset) + @xfail_windows def test_split_str(self): """Check that path as str is correctly split""" ref_db = "does/not/exist" @@ -82,6 +86,7 @@ def test_split_str(self): self.assertEqual(new_location, ref_location) self.assertEqual(new_mapset, ref_mapset) + @xfail_windows def test_split_str_trailing_slash(self): """Check that path as str with a trailing slash is correctly split""" ref_db = "does/not/exist" diff --git a/python/grass/gunittest/case.py b/python/grass/gunittest/case.py index 4d1b37bdfed..4e0ee3ab24d 100644 --- a/python/grass/gunittest/case.py +++ b/python/grass/gunittest/case.py @@ -10,6 +10,7 @@ """ import os +from pathlib import Path import shutil import subprocess import hashlib @@ -690,11 +691,8 @@ def assertFileMd5(self, filename, md5, text=False, msg=None): at the end of file (as for example, Git or PEP8 requires). """ self.assertFileExists(filename, msg=msg) - if text: - actual = text_file_md5(filename) - else: - actual = file_md5(filename) - if not actual == md5: + actual = text_file_md5(filename) if text else file_md5(filename) + if actual != md5: standardMsg = ( "File <{name}> does not have the right MD5 sum.\n" "Expected is <{expected}>," @@ -735,10 +733,9 @@ def _get_unique_name(self, name): # and ensure uniqueness by add UUID if self.readable_names: return "tmp_" + self.id().replace(".", "_") + "_" + name - else: - # UUID might be overkill (and expensive) but it's safe and simple - # alternative is to create hash from the readable name - return "tmp_" + str(uuid.uuid4()).replace("-", "") + # UUID might be overkill (and expensive) but it's safe and simple + # alternative is to create hash from the readable name + return "tmp_" + str(uuid.uuid4()).replace("-", "") def _compute_difference_raster(self, first, second, name_part): """Compute difference of two rasters (first - second) @@ -1227,8 +1224,9 @@ def assertVectorAsciiEqualsVectorAscii( """ import difflib - fromlines = open(actual).readlines() - tolines = open(reference).readlines() + with open(actual) as f1, open(reference) as f2: + fromlines = f1.readlines() + tolines = f2.readlines() context_lines = 3 # number of context lines # TODO: filenames are set to "actual" and "reference", isn't it too general? # it is even more useful if map names or file names are some generated @@ -1252,18 +1250,18 @@ def assertVectorAsciiEqualsVectorAscii( os.remove(reference) stdmsg = "There is a difference between vectors when compared as ASCII files.\n" - output = StringIO() # TODO: there is a diff size constant which we can use # we are setting it unlimited but we can just set it large maxlines = 100 i = 0 - for line in diff: - if i >= maxlines: - break - output.write(line) - i += 1 - stdmsg += output.getvalue() - output.close() + with StringIO() as output: + for line in diff: + if i >= maxlines: + break + output.write(line) + i += 1 + stdmsg += output.getvalue() + # it seems that there is not better way of asking whether there was # a difference (always a iterator object is returned) if i > 0: @@ -1288,11 +1286,9 @@ def assertVectorAsciiEqualsVectorAscii( "actual", context=True, numlines=context_lines, + charset="utf-8", ) - htmldiff_file = open(htmldiff_file_name, "w") - for line in htmldiff: - htmldiff_file.write(line) - htmldiff_file.close() + Path(htmldiff_file_name).write_text(htmldiff, encoding="utf-8") self.fail(self._formatMessage(msg, stdmsg)) @@ -1340,12 +1336,9 @@ def runModule(cls, module, expecting_stdout=False, **kwargs): errors = " The errors are:\n" + module.outputs.stderr else: errors = " There were no error messages." - if module.outputs.stdout: - # this is not appropriate for translation but we don't want - # and don't need testing to be translated - got = "only whitespace." - else: - got = "nothing." + # This is not appropriate for translation but we don't want + # and don't need testing to be translated + got = "only whitespace." if module.outputs.stdout else "nothing." raise RuntimeError( "Module call " + module.get_python() diff --git a/python/grass/gunittest/checkers.py b/python/grass/gunittest/checkers.py index fb46a1deb66..c63f6d08ff0 100644 --- a/python/grass/gunittest/checkers.py +++ b/python/grass/gunittest/checkers.py @@ -638,7 +638,7 @@ def text_file_md5( if prepend_lines: for line in prepend_lines: hasher.update(encode(line)) - with open(filename, "r") as f: + with open(filename) as f: for line in f: # replace platform newlines by standard newline if os.linesep != "\n": diff --git a/python/grass/gunittest/invoker.py b/python/grass/gunittest/invoker.py index f07e8dd5a84..29b62830e25 100644 --- a/python/grass/gunittest/invoker.py +++ b/python/grass/gunittest/invoker.py @@ -54,10 +54,7 @@ def update_keyval_file(filename, module, returncode): keyval["name"] = module.name keyval["tested_dir"] = module.tested_dir if "status" not in keyval.keys(): - if returncode is None or returncode: - status = "failed" - else: - status = "passed" + status = "failed" if returncode is None or returncode else "passed" keyval["status"] = status keyval["returncode"] = returncode keyval["test_file_authors"] = test_file_authors @@ -244,7 +241,7 @@ def try_decode(data, encodings): Path(stdout_path).write_text(stdout) with open(stderr_path, "w") as stderr_file: - if type(stderr) == "bytes": + if isinstance(stderr, bytes): stderr_file.write(decode(stderr)) elif isinstance(stderr, str): stderr_file.write(stderr) diff --git a/python/grass/gunittest/loader.py b/python/grass/gunittest/loader.py index 33234e2b083..50fa368f62a 100644 --- a/python/grass/gunittest/loader.py +++ b/python/grass/gunittest/loader.py @@ -6,17 +6,28 @@ License (>=v2). Read the file COPYING that comes with GRASS GIS for details. -:authors: Vaclav Petras +:authors: Vaclav Petras, Edouard Choinière """ -import os -import fnmatch -import unittest +from __future__ import annotations + import collections +import fnmatch +import os import re +import unittest +from pathlib import PurePath +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from collections.abc import Iterable -def fnmatch_exclude_with_base(files, base, exclude): +def fnmatch_exclude_with_base( + files: Iterable[str], + base: str | os.PathLike, + exclude: Iterable[str | os.PathLike | PurePath], +) -> list[str]: """Return list of files not matching any exclusion pattern :param files: list of file names @@ -24,23 +35,13 @@ def fnmatch_exclude_with_base(files, base, exclude): :param exclude: list of fnmatch glob patterns for exclusion """ not_excluded = [] - patterns = [] - # Make all dir separators slashes and drop leading current dir - # for both patterns and (later) for files. - for pattern in exclude: - pattern = pattern.replace(os.sep, "/") - if pattern.startswith("./"): - patterns.append(pattern[2:]) - else: - patterns.append(pattern) + patterns = {str(PurePath(item)) for item in exclude} + base_path = PurePath(base) for filename in files: - full_file_path = os.path.join(base, filename) - test_filename = full_file_path.replace(os.sep, "/") - if full_file_path.startswith("./"): - test_filename = full_file_path[2:] + test_filename: PurePath = base_path / filename matches = False for pattern in patterns: - if fnmatch.fnmatch(test_filename, pattern): + if fnmatch.fnmatch(str(test_filename), pattern): matches = True break if not matches: @@ -116,16 +117,16 @@ def discover_modules( dirs.remove(testsuite_dir) # do not recurse to testsuite full = os.path.join(root, testsuite_dir) - all_files = os.listdir(full) + files = os.listdir(full) if file_pattern: - files = fnmatch.filter(all_files, file_pattern) + files = fnmatch.filter(files, file_pattern) if file_regexp: - files = [f for f in all_files if re.match(file_regexp, f)] + files = [f for f in files if re.match(file_regexp, f)] if exclude: files = fnmatch_exclude_with_base(files, full, exclude) files = sorted(files) # get test/module name without .py - # extpecting all files to end with .py + # expecting all files to end with .py # this will not work for invoking bat files but it works fine # as long as we handle only Python files (and using Python # interpreter for invoking) @@ -234,4 +235,18 @@ def discover(self, start_dir, pattern="test*.py", top_level_dir=None): if __name__ == "__main__": - GrassTestLoader().discover() + for expression in [r".*\.py$", r".*\.sh$"]: + modules = discover_modules( + start_dir=".", + grass_location="all", + file_regexp=expression, + skip_dirs=GrassTestLoader.skip_dirs, + testsuite_dir=GrassTestLoader.testsuite_dir, + all_locations_value=GrassTestLoader.all_tests_value, + universal_location_value=GrassTestLoader.universal_tests_value, + import_modules=False, + exclude=None, + ) + print("Expression:", expression) + print(len(modules)) + print([module.file_path for module in modules]) diff --git a/python/grass/gunittest/multireport.py b/python/grass/gunittest/multireport.py index edeb98636ee..5a0350f1786 100644 --- a/python/grass/gunittest/multireport.py +++ b/python/grass/gunittest/multireport.py @@ -16,6 +16,7 @@ import datetime import operator from collections import defaultdict, namedtuple +from pathlib import Path from grass.gunittest.checkers import text_to_keyvalue from grass.gunittest.utils import ensure_dir @@ -103,8 +104,7 @@ def median(values): sorted_values = sorted(values) if n % 2 == 0: return (sorted_values[n / 2 - 1] + sorted_values[n / 2]) / 2 - else: - return sorted_values[n / 2] + return sorted_values[n / 2] # this is useful for debugging or some other stat # cmeans = [] @@ -119,10 +119,7 @@ def median(values): smedian = median(successes) smax = max(successes) - if successes[-1] < smedian: - color = "r" - else: - color = "g" + color = "r" if successes[-1] < smedian else "g" # another possibility is to color according to the gradient, ideally # on the whole curve but that's much more complicated @@ -472,7 +469,7 @@ def main(): # skipping incomplete reports # use only results list for further processing continue - summary = text_to_keyvalue(open(summary_file).read(), sep="=") + summary = text_to_keyvalue(Path(summary_file).read_text(), sep="=") if use_timestamps: test_timestamp = datetime.datetime.fromtimestamp( os.path.getmtime(summary_file) @@ -516,147 +513,156 @@ def main(): except KeyError as e: print("File %s does not have right values (%s)" % (report, e.message)) - locations_main_page = open(os.path.join(output, "index.html"), "w") - locations_main_page.write( - "" - "

    Test reports grouped by location type

    " - "" - "" - "" - "" - "" - "" - ) + with open(os.path.join(output, "index.html"), "w") as locations_main_page: + locations_main_page.write( + "" + "

    Test reports grouped by location type

    " + "
    LocationSuccessful filesSuccessful tests
    " + "" + "" + "" + "" + "" + ) - PlotStyle = namedtuple( - "PlotStyle", - ["linestyle", "linewidth", "success_color", "fail_color", "total_color"], - ) - plot_style = PlotStyle( - linestyle="-", linewidth=4.0, success_color="g", fail_color="r", total_color="b" - ) + PlotStyle = namedtuple( + "PlotStyle", + ["linestyle", "linewidth", "success_color", "fail_color", "total_color"], + ) + plot_style = PlotStyle( + linestyle="-", + linewidth=4.0, + success_color="g", + fail_color="r", + total_color="b", + ) - for location_type, results in results_in_locations.items(): - results = sorted(results, key=operator.attrgetter("timestamp")) - # TODO: document: location type must be a valid dir name - directory = os.path.join(output, location_type) - ensure_dir(directory) + for location_type, results in results_in_locations.items(): + results = sorted(results, key=operator.attrgetter("timestamp")) + # TODO: document: location type must be a valid dir name + directory = os.path.join(output, location_type) + ensure_dir(directory) - if location_type == "unknown": - title = "Test reports" - else: - title = "Test reports for <{type}> location type".format( - type=location_type + if location_type == "unknown": + title = "Test reports" + else: + title = "Test reports for <{type}> location type".format( + type=location_type + ) + + x = [date2num(result.timestamp) for result in results] + # the following would be an alternative but it does not work with + # labels and automatic axis limits even after removing another date fun + # x = [result.svn_revision for result in results] + xlabels = [ + result.timestamp.strftime("%Y-%m-%d") + + " (r" + + result.svn_revision + + ")" + for result in results + ] + step = len(x) / 10 + xticks = x[step::step] + xlabels = xlabels[step::step] + tests_successful_plot( + x=x, + xticks=xticks, + xlabels=xlabels, + results=results, + filename=os.path.join(directory, "tests_successful_plot.png"), + style=plot_style, + ) + files_successful_plot( + x=x, + xticks=xticks, + xlabels=xlabels, + results=results, + filename=os.path.join(directory, "files_successful_plot.png"), + style=plot_style, + ) + tests_plot( + x=x, + xticks=xticks, + xlabels=xlabels, + results=results, + filename=os.path.join(directory, "tests_plot.png"), + style=plot_style, + ) + tests_percent_plot( + x=x, + xticks=xticks, + xlabels=xlabels, + results=results, + filename=os.path.join(directory, "tests_percent_plot.png"), + style=plot_style, + ) + files_plot( + x=x, + xticks=xticks, + xlabels=xlabels, + results=results, + filename=os.path.join(directory, "files_plot.png"), + style=plot_style, + ) + files_percent_plot( + x=x, + xticks=xticks, + xlabels=xlabels, + results=results, + filename=os.path.join(directory, "files_percent_plot.png"), + style=plot_style, + ) + info_plot( + x=x, + xticks=xticks, + xlabels=xlabels, + results=results, + filename=os.path.join(directory, "info_plot.png"), + style=plot_style, ) - x = [date2num(result.timestamp) for result in results] - # the following would be an alternative but it does not work with - # labels and automatic axis limits even after removing another date fun - # x = [result.svn_revision for result in results] - xlabels = [ - result.timestamp.strftime("%Y-%m-%d") + " (r" + result.svn_revision + ")" - for result in results - ] - step = len(x) / 10 - xticks = x[step::step] - xlabels = xlabels[step::step] - tests_successful_plot( - x=x, - xticks=xticks, - xlabels=xlabels, - results=results, - filename=os.path.join(directory, "tests_successful_plot.png"), - style=plot_style, - ) - files_successful_plot( - x=x, - xticks=xticks, - xlabels=xlabels, - results=results, - filename=os.path.join(directory, "files_successful_plot.png"), - style=plot_style, - ) - tests_plot( - x=x, - xticks=xticks, - xlabels=xlabels, - results=results, - filename=os.path.join(directory, "tests_plot.png"), - style=plot_style, - ) - tests_percent_plot( - x=x, - xticks=xticks, - xlabels=xlabels, - results=results, - filename=os.path.join(directory, "tests_percent_plot.png"), - style=plot_style, - ) - files_plot( - x=x, - xticks=xticks, - xlabels=xlabels, - results=results, - filename=os.path.join(directory, "files_plot.png"), - style=plot_style, - ) - files_percent_plot( - x=x, - xticks=xticks, - xlabels=xlabels, - results=results, - filename=os.path.join(directory, "files_percent_plot.png"), - style=plot_style, - ) - info_plot( - x=x, - xticks=xticks, - xlabels=xlabels, - results=results, - filename=os.path.join(directory, "info_plot.png"), - style=plot_style, - ) + main_page( + results=results, + filename="index.html", + images=[ + "tests_successful_plot.png", + "files_successful_plot.png", + "tests_plot.png", + "files_plot.png", + "tests_percent_plot.png", + "files_percent_plot.png", + "info_plot.png", + ], + captions=[ + "Success of individual tests in percents", + "Success of test files in percents", + "Successes, failures and number of individual tests", + "Successes, failures and number of test files", + "Successes and failures of individual tests in percent", + "Successes and failures of test files in percents", + "Additional information", + ], + directory=directory, + title=title, + ) - main_page( - results=results, - filename="index.html", - images=[ - "tests_successful_plot.png", - "files_successful_plot.png", - "tests_plot.png", - "files_plot.png", - "tests_percent_plot.png", - "files_percent_plot.png", - "info_plot.png", - ], - captions=[ - "Success of individual tests in percents", - "Success of test files in percents", - "Successes, failures and number of individual tests", - "Successes, failures and number of test files", - "Successes and failures of individual tests in percent", - "Successes and failures of test files in percents", - "Additional information", - ], - directory=directory, - title=title, - ) + files_successes = sum(result.files_successes for result in results) + files_total = sum(result.files_total for result in results) + successes = sum(result.successes for result in results) + total = sum(result.total for result in results) + per_test = success_to_html_percent(total=total, successes=successes) + per_file = success_to_html_percent( + total=files_total, successes=files_successes + ) + locations_main_page.write( + "" + "" + "" + "".format(location=location_type, pfiles=per_file, ptests=per_test) + ) + locations_main_page.write("
    LocationSuccessful filesSuccessful tests
    {location}{pfiles}{ptests}
    ") + locations_main_page.write("") - files_successes = sum(result.files_successes for result in results) - files_total = sum(result.files_total for result in results) - successes = sum(result.successes for result in results) - total = sum(result.total for result in results) - per_test = success_to_html_percent(total=total, successes=successes) - per_file = success_to_html_percent(total=files_total, successes=files_successes) - locations_main_page.write( - "" - "{location}" - "{pfiles}{ptests}" - "".format(location=location_type, pfiles=per_file, ptests=per_test) - ) - locations_main_page.write("") - locations_main_page.write("") - locations_main_page.close() return 0 diff --git a/python/grass/gunittest/multirunner.py b/python/grass/gunittest/multirunner.py index fd648406332..ebb9e80049a 100644 --- a/python/grass/gunittest/multirunner.py +++ b/python/grass/gunittest/multirunner.py @@ -30,15 +30,13 @@ def _get_encoding(): def decode(bytes_, encoding=None): if isinstance(bytes_, bytes): return bytes_.decode(_get_encoding()) - else: - return bytes_ + return bytes_ def encode(string, encoding=None): if isinstance(string, str): return string.encode(_get_encoding()) - else: - return string + return string def text_to_string(text): diff --git a/python/grass/gunittest/reporters.py b/python/grass/gunittest/reporters.py index 0911ca0fdd7..7c93872a656 100644 --- a/python/grass/gunittest/reporters.py +++ b/python/grass/gunittest/reporters.py @@ -51,12 +51,9 @@ def replace_in_file(file_path, pattern, repl): """ # using tmp file to store the replaced content tmp_file_path = file_path + ".tmp" - old_file = open(file_path, "r") - new_file = open(tmp_file_path, "w") - for line in old_file: - new_file.write(re.sub(pattern=pattern, string=line, repl=repl)) - new_file.close() - old_file.close() + with open(file_path) as old_file, open(tmp_file_path, "w") as new_file: + for line in old_file: + new_file.write(re.sub(pattern=pattern, string=line, repl=repl)) # remove old file since it must not exist for rename/move os.remove(file_path) # replace old file by new file @@ -110,11 +107,10 @@ def get_source_url(path, revision, line=None): :param revision: SVN revision (should be a number) :param line: line in the file (should be None for directories) """ - tracurl = "http://trac.osgeo.org/grass/browser/" + tracurl = "https://trac.osgeo.org/grass/browser/" if line: return "{tracurl}{path}?rev={revision}#L{line}".format(**locals()) - else: - return "{tracurl}{path}?rev={revision}".format(**locals()) + return "{tracurl}{path}?rev={revision}".format(**locals()) def html_escape(text): @@ -153,8 +149,7 @@ def to_web_path(path): """ if os.path.sep != "/": return path.replace(os.path.sep, "/") - else: - return path + return path def get_svn_revision(): @@ -172,14 +167,12 @@ def get_svn_revision(): rc = p.poll() if not rc: stdout = stdout.strip() - if stdout.endswith("M"): - stdout = stdout[:-1] + stdout = stdout.removesuffix("M") if ":" in stdout: # the first one is the one of source code stdout = stdout.split(":")[0] return stdout - else: - return None + return None def get_svn_info(): @@ -211,8 +204,7 @@ def get_svn_info(): if relurl is not None: relurl = relurl.text # relative path has ^ at the beginning in SVN version 1.8.8 - if relurl.startswith("^"): - relurl = relurl[1:] + relurl = relurl.removeprefix("^") else: # SVN version 1.8.8 supports relative-url but older do not # so, get relative part from absolute URL @@ -242,11 +234,8 @@ def get_svn_path_authors(path, from_date=None): :returns: a set of authors """ - if from_date is None: - # this is the SVN default for local copies - revision_range = "BASE:1" - else: - revision_range = "BASE:{%s}" % from_date + # "BASE:1" is the SVN default for local copies + revision_range = "BASE:1" if from_date is None else "BASE:{%s}" % from_date try: # TODO: allow also usage of --limit p = subprocess.Popen( @@ -441,9 +430,9 @@ def end_file_test(self, returncode, **kwargs): def percent_to_html(percent): if percent is None: return 'unknown percentage' - elif percent > 100 or percent < 0: + if percent > 100 or percent < 0: return "? {:.2f}% ?".format(percent) - elif percent < 40: + if percent < 40: color = "red" elif percent < 70: color = "orange" @@ -457,13 +446,11 @@ def percent_to_html(percent): def wrap_stdstream_to_html(infile, outfile, module, stream): before = "

    %s

    " % (module.name + " " + stream)
         after = "
    " - html = open(outfile, "w") - html.write(before) - with open(infile) as text: + with open(outfile, "w") as html, open(infile) as text: + html.write(before) for line in text: html.write(color_error_line(html_escape(line))) - html.write(after) - html.close() + html.write(after) def html_file_preview(filename): @@ -484,7 +471,7 @@ def html_file_preview(filename): elif size < 10 * max_size: def tail(filename, n): - return collections.deque(open(filename), n) + return collections.deque(open(filename), n) # noqa: SIM115 html.write("... (lines omitted)\n") for line in tail(filename, 50): @@ -497,14 +484,10 @@ def tail(filename, n): def returncode_to_html_text(returncode, timed_out=None): if returncode: - if timed_out is not None: - extra = f" (timeout >{timed_out}s)" - else: - extra = "" + extra = f" (timeout >{timed_out}s)" if timed_out is not None else "" return f'FAILED{extra}' - else: - # alternatives: SUCCEEDED, passed, OK - return 'succeeded' + # alternatives: SUCCEEDED, passed, OK + return 'succeeded' # not used @@ -514,31 +497,28 @@ def returncode_to_html_sentence(returncode): '' " Test failed (return code %d)" % (returncode) ) - else: - return ( - '' - " Test succeeded (return code %d)" % (returncode) - ) + return ( + '' + " Test succeeded (return code %d)" % (returncode) + ) def returncode_to_success_html_par(returncode): if returncode: return '

    Test failed

    ' - else: - return '

    Test succeeded

    ' + return '

    Test succeeded

    ' def success_to_html_text(total, successes): if successes < total: return 'FAILED' - elif successes == total: + if successes == total: # alternatives: SUCCEEDED, passed, OK return 'succeeded' - else: - return ( - '' - "? more successes than total ?" - ) + return ( + '' + "? more successes than total ?" + ) UNKNOWN_NUMBER_HTML = 'unknown' @@ -566,7 +546,8 @@ def start(self, results_dir): super().start(results_dir) # having all variables public although not really part of API main_page_name = os.path.join(results_dir, self._main_page_name) - self.main_index = open(main_page_name, "w") + # TODO: Ensure file is closed in all situations + self.main_index = open(main_page_name, "w") # noqa: SIM115 # TODO: this can be moved to the counter class self.failures = 0 @@ -633,8 +614,7 @@ def finish(self): def format_percentage(percentage): if percentage is not None: return "{nsper:.0f}%".format(nsper=percentage) - else: - return "unknown percentage" + return "unknown percentage" summary_sentence = ( "\nExecuted {nfiles} test files in {time:}." @@ -735,8 +715,7 @@ def end_file_test( ) file_index_path = os.path.join(cwd, "index.html") - file_index = open(file_index_path, "w") - file_index.write( + header = ( '' "

    {m.name}

    " "

    {m.tested_dir} – {m.name}

    " @@ -775,7 +754,6 @@ def end_file_test( dur=self.file_time, ) ) - file_index.write(summary_section) modules = test_summary.get("tested_modules", None) if modules: @@ -784,12 +762,6 @@ def end_file_test( # alternatively a link to module test summary if type(modules) is not list: modules = [modules] - file_index.write( - "Tested modules{0}".format( - ", ".join(sorted(set(modules))) - ) - ) - file_index.write("") # here we would have also links to coverage, profiling, ... # '
  • code coverage
  • ' @@ -799,7 +771,6 @@ def end_file_test( '
  • standard output (stdout)
  • ' '
  • standard error output (stderr)
  • ' ) - file_index.write(files_section) supplementary_files = test_summary.get("supplementary_files", None) if supplementary_files: @@ -811,17 +782,31 @@ def end_file_test( # moreover something can be shared with other explicitly # using constructors as seems advantageous for counting self._file_anonymizer.anonymize(supplementary_files) - for f in supplementary_files: - file_index.write('
  • {f}
  • '.format(f=f)) - file_index.write("") + with open(file_index_path, "w") as file_index: + file_index.write(header) + file_index.write(summary_section) + if modules: + file_index.write( + "Tested modules{0}".format( + ", ".join(sorted(set(modules))) + ) + ) + file_index.write("") - if returncode: - file_index.write("

    Standard error output (stderr)

    ") - file_index.write(html_file_preview(stderr)) + file_index.write(files_section) + + if supplementary_files: + for f in supplementary_files: + file_index.write('
  • {f}
  • '.format(f=f)) + + file_index.write("") - file_index.write("") - file_index.close() + if returncode: + file_index.write("

    Standard error output (stderr)

    ") + file_index.write(html_file_preview(stderr)) + + file_index.write("") if returncode: pass @@ -866,10 +851,7 @@ def finish(self): # this shoul be moved to some additional meta passed in constructor svn_info = get_svn_info() - if not svn_info: - svn_revision = "" - else: - svn_revision = svn_info["revision"] + svn_revision = "" if not svn_info else svn_info["revision"] summary = {} summary["files_total"] = self.test_files @@ -986,8 +968,7 @@ def finish(self): def format_percentage(percentage): if percentage is not None: return "{nsper:.0f}%".format(nsper=percentage) - else: - return "unknown percentage" + return "unknown percentage" summary_sentence = ( "\nExecuted {nfiles} test files in {time:}." @@ -1035,10 +1016,7 @@ def end_file_test( num_failed = test_summary.get("failures", 0) num_failed += test_summary.get("errors", 0) if num_failed: - if num_failed > 1: - text = " ({f} tests failed)" - else: - text = " ({f} test failed)" + text = " ({f} tests failed)" if num_failed > 1 else " ({f} test failed)" self._stream.write(text.format(f=num_failed)) self._stream.write("\n") # TODO: here we lost the possibility to include also file name @@ -1095,7 +1073,7 @@ def report_for_dir(self, root, directory, test_files): os.path.join(root, directory) ) == os.path.abspath(root): page_name = os.path.join(root, self.top_level_testsuite_page_name) - page = open(page_name, "w") + # TODO: should we use forward slashes also for the HTML because # it is simpler are more consistent with the rest on MS Windows? head = "

    {name} testsuite results

    ".format(name=directory) @@ -1108,106 +1086,108 @@ def report_for_dir(self, root, directory, test_files): "FailedPercent successful" "" ) - page.write(head) - page.write(tests_table_head) - for test_file_name in test_files: - # TODO: put keyvalue fine name to constant - summary_filename = os.path.join( - root, directory, test_file_name, "test_keyvalue_result.txt" - ) - # if os.path.exists(summary_filename): - summary = text_to_keyvalue(Path(summary_filename).read_text(), sep="=") - # else: - # TODO: write else here - # summary = None - - if "total" not in summary: - bad_ones = successes = UNKNOWN_NUMBER_HTML - total = None - else: - bad_ones = summary["failures"] + summary["errors"] - successes = summary["successes"] - total = summary["total"] - - self.failures += summary["failures"] - self.errors += summary["errors"] - self.skipped += summary["skipped"] - self.successes += summary["successes"] - self.expected_failures += summary["expected_failures"] - self.unexpected_successes += summary["unexpected_successes"] - self.total += summary["total"] - - dir_failures += summary["failures"] - dir_errors += summary["failures"] - dir_skipped += summary["skipped"] - dir_successes += summary["successes"] - dir_expected_failures += summary["expected_failures"] - dir_unexpected_success += summary["unexpected_successes"] - dir_total += summary["total"] - - # TODO: keyvalue method should have types for keys function - # perhaps just the current post processing function is enough - test_file_authors = summary.get("test_file_authors") - if not test_file_authors: - test_file_authors = [] - if type(test_file_authors) is not list: - test_file_authors = [test_file_authors] - test_files_authors.extend(test_file_authors) - - file_total += 1 - # Use non-zero return code in case it is missing. - # (This can happen when the test has timed out.) - return_code = summary.get("returncode", 1) - file_successes += 0 if return_code else 1 + with open(page_name, "w") as page: + page.write(head) + page.write(tests_table_head) + for test_file_name in test_files: + # TODO: put keyvalue fine name to constant + summary_filename = os.path.join( + root, directory, test_file_name, "test_keyvalue_result.txt" + ) + # if os.path.exists(summary_filename): + summary = text_to_keyvalue(Path(summary_filename).read_text(), sep="=") + # else: + # TODO: write else here + # summary = None + + if "total" not in summary: + bad_ones = successes = UNKNOWN_NUMBER_HTML + total = None + else: + bad_ones = summary["failures"] + summary["errors"] + successes = summary["successes"] + total = summary["total"] + + self.failures += summary["failures"] + self.errors += summary["errors"] + self.skipped += summary["skipped"] + self.successes += summary["successes"] + self.expected_failures += summary["expected_failures"] + self.unexpected_successes += summary["unexpected_successes"] + self.total += summary["total"] + + dir_failures += summary["failures"] + dir_errors += summary["failures"] + dir_skipped += summary["skipped"] + dir_successes += summary["successes"] + dir_expected_failures += summary["expected_failures"] + dir_unexpected_success += summary["unexpected_successes"] + dir_total += summary["total"] + + # TODO: keyvalue method should have types for keys function + # perhaps just the current post processing function is enough + test_file_authors = summary.get("test_file_authors") + if not test_file_authors: + test_file_authors = [] + if type(test_file_authors) is not list: + test_file_authors = [test_file_authors] + test_files_authors.extend(test_file_authors) + + file_total += 1 + # Use non-zero return code in case it is missing. + # (This can happen when the test has timed out.) + return_code = summary.get("returncode", 1) + file_successes += 0 if return_code else 1 + + pass_per = success_to_html_percent(total=total, successes=successes) + row = ( + "" + '{f}' + "{status}" + "{ntests}{stests}" + "{ftests}{ptests}" + "".format( + f=test_file_name, + status=returncode_to_html_text(return_code), + stests=successes, + ftests=bad_ones, + ntests=total, + ptests=pass_per, + ) + ) + page.write(row) - pass_per = success_to_html_percent(total=total, successes=successes) - row = ( - "" - '{f}' + self.testsuites += 1 + self.testsuites_successes += 1 if file_successes == file_total else 0 + self.files += file_total + self.files_successes += file_successes + + dir_pass_per = success_to_html_percent( + total=dir_total, successes=dir_successes + ) + file_pass_per = success_to_html_percent( + total=file_total, successes=file_successes + ) + tests_table_foot = ( + "" + "Summary" "{status}" "{ntests}{stests}" "{ftests}{ptests}" - "".format( - f=test_file_name, - status=returncode_to_html_text(return_code), - stests=successes, - ftests=bad_ones, - ntests=total, - ptests=pass_per, + "".format( + status=file_pass_per, + stests=dir_successes, + ftests=dir_failures + dir_errors, + ntests=dir_total, + ptests=dir_pass_per, ) ) - page.write(row) - - self.testsuites += 1 - self.testsuites_successes += 1 if file_successes == file_total else 0 - self.files += file_total - self.files_successes += file_successes - - dir_pass_per = success_to_html_percent(total=dir_total, successes=dir_successes) - file_pass_per = success_to_html_percent( - total=file_total, successes=file_successes - ) - tests_table_foot = ( - "" - "Summary" - "{status}" - "{ntests}{stests}" - "{ftests}{ptests}" - "".format( - status=file_pass_per, - stests=dir_successes, - ftests=dir_failures + dir_errors, - ntests=dir_total, - ptests=dir_pass_per, + page.write(tests_table_foot) + test_authors = get_html_test_authors_table( + directory=directory, tests_authors=test_files_authors ) - ) - page.write(tests_table_foot) - test_authors = get_html_test_authors_table( - directory=directory, tests_authors=test_files_authors - ) - page.write(test_authors) - page.write("") - page.close() + page.write(test_authors) + page.write("") status = success_to_html_text(total=file_total, successes=file_successes) return ( @@ -1235,7 +1215,6 @@ def report_for_dirs(self, root, directories): # absolute/relative paths page_name = os.path.join(root, self.main_page_name) - page = open(page_name, "w") head = "

    Testsuites results

    " tests_table_head = ( "" @@ -1248,14 +1227,6 @@ def report_for_dirs(self, root, directories): "" "" ) - page.write(head) - page.write(tests_table_head) - - for directory, test_files in directories.items(): - row = self.report_for_dir( - root=root, directory=directory, test_files=test_files - ) - page.write(row) pass_per = success_to_html_percent(total=self.total, successes=self.successes) file_pass_per = success_to_html_percent( @@ -1283,5 +1254,16 @@ def report_for_dirs(self, root, directories): ptests=pass_per, ) ) - page.write(tests_table_foot) - page.write("") + + with open(page_name, "w") as page: + page.write(head) + page.write(tests_table_head) + + for directory, test_files in directories.items(): + row = self.report_for_dir( + root=root, directory=directory, test_files=test_files + ) + page.write(row) + + page.write(tests_table_foot) + page.write("") diff --git a/python/grass/gunittest/runner.py b/python/grass/gunittest/runner.py index b99c6704c89..0bbd0f361b9 100644 --- a/python/grass/gunittest/runner.py +++ b/python/grass/gunittest/runner.py @@ -83,8 +83,7 @@ def getDescription(self, test): doc_first_line = test.shortDescription() if self.descriptions and doc_first_line: return "\n".join((str(test), doc_first_line)) - else: - return str(test) + return str(test) def startTest(self, test): super().startTest(test) diff --git a/python/grass/gunittest/testsuite/test_assertions.py b/python/grass/gunittest/testsuite/test_assertions.py index 3af538132f3..ed27c0e54fb 100644 --- a/python/grass/gunittest/testsuite/test_assertions.py +++ b/python/grass/gunittest/testsuite/test_assertions.py @@ -11,6 +11,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows class TestTextAssertions(TestCase): @@ -34,6 +35,7 @@ def test_assertLooksLike(self): def test_assertLooksLike_multiline(self): self.assertLooksLike("a=123\nb=456\nc=789", "a=...\nb=...\nc=...") + @xfail_windows def test_assertLooksLike_multiline_platform_dependent(self): self.assertLooksLike( "a=123\nb=456\nc=789", "a=...{nl}b=...{nl}c=...".format(nl=os.linesep) @@ -384,6 +386,7 @@ def test_assertFileExists_empty_file(self): self.failureException, self.assertFileExists, filename=self.emtpy_file ) + @xfail_windows def test_assertFileMd5(self): self.assertFileMd5(filename=self.file_with_md5, md5=self.file_md5) self.assertRaises( diff --git a/python/grass/gunittest/testsuite/test_assertions_vect.py b/python/grass/gunittest/testsuite/test_assertions_vect.py index 8b3288ad2ca..0a73580ba58 100644 --- a/python/grass/gunittest/testsuite/test_assertions_vect.py +++ b/python/grass/gunittest/testsuite/test_assertions_vect.py @@ -5,6 +5,7 @@ from grass.exceptions import CalledModuleError from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows V_UNIVAR_SCHOOLS_WIDTH_SUBSET = """n=144 @@ -281,6 +282,7 @@ def test_assertVectorAsciiEqualsVectorAscii_diff_content(self): self.assertFileExists(self.simple_base_file) self.assertFileExists(self.simple_modified_file) + @xfail_windows def test_assertVectorEqualsAscii_by_import(self): amap = "simple_vector_map_imported_base" self.runModule( diff --git a/python/grass/gunittest/testsuite/test_checkers.py b/python/grass/gunittest/testsuite/test_checkers.py index d35ffcb19d8..b11b25778a3 100644 --- a/python/grass/gunittest/testsuite/test_checkers.py +++ b/python/grass/gunittest/testsuite/test_checkers.py @@ -24,6 +24,7 @@ file_md5, text_file_md5, ) +from grass.gunittest.utils import xfail_windows class TestValuesEqual(TestCase): @@ -386,6 +387,7 @@ def tearDownClass(cls): try_remove(cls.correct_file_name_unix_nl) try_remove(cls.wrong_file_name) + @xfail_windows def test_text_file_binary(self): r"""File with ``\n`` (LF) newlines as binary (MD5 has ``\n``).""" self.assertEqual( diff --git a/python/grass/gunittest/utils.py b/python/grass/gunittest/utils.py index c1afea3d5ad..5313dbb9bc8 100644 --- a/python/grass/gunittest/utils.py +++ b/python/grass/gunittest/utils.py @@ -14,6 +14,8 @@ from pathlib import Path import shutil import sys +from unittest import expectedFailure +import warnings def ensure_dir(directory): @@ -80,3 +82,17 @@ def safe_repr(obj, short=False): if not short or len(result) < _MAX_LENGTH: return result return result[:_MAX_LENGTH] + " [truncated]..." + + +def xfail_windows(test_item): + """Marks a test as an expected failure or error only on Windows + Equivalent to applying @unittest.expectedFailure only when running + on Windows. + """ + if not sys.platform.startswith("win"): + return lambda func: func + warnings.warn( + "Once the test is fixed and passing, remove the @xfail_windows decorator", + stacklevel=2, + ) + return expectedFailure(test_item) diff --git a/python/grass/imaging/__init__.py b/python/grass/imaging/__init__.py index 41626697f8e..7434942abe0 100644 --- a/python/grass/imaging/__init__.py +++ b/python/grass/imaging/__init__.py @@ -1,4 +1,15 @@ -from grass.imaging.images2gif import readGif, writeGif -from grass.imaging.images2swf import readSwf, writeSwf from grass.imaging.images2avi import readAvi, writeAvi +from grass.imaging.images2gif import readGif, writeGif from grass.imaging.images2ims import readIms, writeIms +from grass.imaging.images2swf import readSwf, writeSwf + +__all__ = [ + "readAvi", + "readGif", + "readIms", + "readSwf", + "writeAvi", + "writeGif", + "writeIms", + "writeSwf", +] diff --git a/python/grass/imaging/images2avi.py b/python/grass/imaging/images2avi.py index f0b1904823d..9776b9c0db2 100644 --- a/python/grass/imaging/images2avi.py +++ b/python/grass/imaging/images2avi.py @@ -137,25 +137,22 @@ def writeAvi( + "\n" + _("Could not write avi.") ) - else: - # An error occurred, show - print(gs.decode(outPut)) - print(gs.decode(S.stderr.read())) - raise RuntimeError(_("Could not write avi.")) - else: - try: - # Copy avi - shutil.copy(os.path.join(tempDir, "output.avi"), filename) - except Exception as err: - # Clean up - _cleanDir(tempDir) - if bg_task: - return str(err) - else: - raise - + # An error occurred, show + print(gs.decode(outPut)) + print(gs.decode(S.stderr.read())) + raise RuntimeError(_("Could not write avi.")) + try: + # Copy avi + shutil.copy(os.path.join(tempDir, "output.avi"), filename) + except Exception as err: # Clean up _cleanDir(tempDir) + if bg_task: + return str(err) + raise + + # Clean up + _cleanDir(tempDir) def readAvi(filename, asNumpy=True): @@ -197,11 +194,11 @@ def readAvi(filename, asNumpy=True): # Clean up _cleanDir(tempDir) raise RuntimeError("Could not read avi.") - else: - # Read images - images = images2ims.readIms(os.path.join(tempDir, "im*.jpg"), asNumpy) - # Clean up - _cleanDir(tempDir) + + # Read images + images = images2ims.readIms(os.path.join(tempDir, "im*.jpg"), asNumpy) + # Clean up + _cleanDir(tempDir) # Done return images diff --git a/python/grass/imaging/images2gif.py b/python/grass/imaging/images2gif.py index a4dc2dc0824..d37ec0c4e32 100644 --- a/python/grass/imaging/images2gif.py +++ b/python/grass/imaging/images2gif.py @@ -58,7 +58,7 @@ Useful links: * http://tronche.com/computer-graphics/gif/ - * http://en.wikipedia.org/wiki/Graphics_Interchange_Format + * https://en.wikipedia.org/wiki/Graphics_Interchange_Format * http://www.w3.org/Graphics/GIF/spec-gif89a.txt """ @@ -265,7 +265,7 @@ def handleSubRectangles(self, images, subRectangles): xy = (0, 0) if hasattr(xy, "__len__"): if len(xy) == len(images): - xy = [xxyy for xxyy in xy] + xy = list(xy) else: raise ValueError("len(xy) doesn't match amount of images.") else: @@ -594,7 +594,7 @@ def writeGifVisvis( # Check duration if hasattr(duration, "__len__"): if len(duration) == len(images): - duration = [d for d in duration] + duration = list(duration) else: raise ValueError("len(duration) doesn't match amount of images.") else: @@ -1060,9 +1060,8 @@ def quantize(self, image): """ if get_cKDTree(): return self.quantize_with_scipy(image) - else: - print("Scipy not available, falling back to slower version.") - return self.quantize_without_scipy(image) + print("Scipy not available, falling back to slower version.") + return self.quantize_without_scipy(image) def quantize_with_scipy(self, image): w, h = image.size diff --git a/python/grass/imaging/images2ims.py b/python/grass/imaging/images2ims.py index 31088a22f2e..d86a2247952 100644 --- a/python/grass/imaging/images2ims.py +++ b/python/grass/imaging/images2ims.py @@ -31,6 +31,8 @@ """ import os +from operator import itemgetter +from string import digits try: import numpy as np @@ -92,8 +94,7 @@ def checkImages(images): def _getFilenameParts(filename): if "*" in filename: return tuple(filename.split("*", 1)) - else: - return os.path.splitext(filename) + return os.path.splitext(filename) def _getFilenameWithFormatter(filename, N): @@ -117,7 +118,7 @@ def _getSequenceNumber(filename, part1, part2): # Get all numeric chars seq2 = "" for c in seq: - if c in "0123456789": + if c in digits: seq2 += c else: break @@ -214,7 +215,7 @@ def readIms(filename, asNumpy=True): images.append((im.copy(), nr)) # Sort images - images.sort(key=lambda x: x[1]) + images.sort(key=itemgetter(1)) images = [im[0] for im in images] # Convert to numpy if needed diff --git a/python/grass/imaging/images2swf.py b/python/grass/imaging/images2swf.py index 0a08ed9d46d..7d6f5a25f9b 100644 --- a/python/grass/imaging/images2swf.py +++ b/python/grass/imaging/images2swf.py @@ -392,7 +392,7 @@ def __init__(self): def ProcessTag(self): """Implement this to create the tag.""" - raise NotImplementedError() + raise NotImplementedError def GetTag(self): """Calls processTag and attaches the header.""" @@ -796,7 +796,7 @@ def writeSwf(filename, images, duration=0.1, repeat=True): # Check duration if hasattr(duration, "__len__"): if len(duration) == len(images2): - duration = [d for d in duration] + duration = list(duration) else: raise ValueError("len(duration) doesn't match amount of images.") else: diff --git a/python/grass/jupyter/__init__.py b/python/grass/jupyter/__init__.py index 91457f07ac3..21223c2cd47 100644 --- a/python/grass/jupyter/__init__.py +++ b/python/grass/jupyter/__init__.py @@ -109,6 +109,17 @@ from .interactivemap import InteractiveMap, Raster, Vector from .map import Map from .map3d import Map3D +from .seriesmap import SeriesMap from .setup import init from .timeseriesmap import TimeSeriesMap -from .seriesmap import SeriesMap + +__all__ = [ + "InteractiveMap", + "Map", + "Map3D", + "Raster", + "SeriesMap", + "TimeSeriesMap", + "Vector", + "init", +] diff --git a/python/grass/jupyter/baseseriesmap.py b/python/grass/jupyter/baseseriesmap.py index 634e172f3c5..4497b16593d 100644 --- a/python/grass/jupyter/baseseriesmap.py +++ b/python/grass/jupyter/baseseriesmap.py @@ -25,7 +25,7 @@ import grass.script as gs from .map import Map -from .utils import get_number_of_cores +from .utils import get_number_of_cores, save_gif class BaseSeriesMap: @@ -210,3 +210,49 @@ def change_image(index): width="100%", display="inline-flex", flex_flow="row wrap" ) return widgets.HBox([play, slider, out_img], layout=layout) + + def save( + self, + filename, + duration=500, + label=True, + font=None, + text_size=12, + text_color="gray", + ): + """ + Creates a GIF animation of rendered layers. + + Text color must be in a format accepted by PIL ImageColor module. For supported + formats, visit: + https://pillow.readthedocs.io/en/stable/reference/ImageColor.html#color-names + + param str filename: name of output GIF file + param int duration: time to display each frame; milliseconds + param bool label: include label on each frame + param str font: font file + param int text_size: size of label text + param str text_color: color to use for the text. + """ + + # Render images if they have not been already + if not self._layers_rendered: + self.render() + + input_files = [] + for index in self._indices: + input_files.append(self._base_filename_dict[index]) + + save_gif( + input_files, + filename, + duration=duration, + label=label, + labels=self._labels, + font=font, + text_size=text_size, + text_color=text_color, + ) + + # Display the GIF + return filename diff --git a/python/grass/jupyter/interactivemap.py b/python/grass/jupyter/interactivemap.py index 085c2843fe7..d843ac3b6b6 100644 --- a/python/grass/jupyter/interactivemap.py +++ b/python/grass/jupyter/interactivemap.py @@ -178,7 +178,7 @@ def add_to(self, interactive_map): else: import ipyleaflet # pylint: disable=import-outside-toplevel - with open(self._filename, "r", encoding="utf-8") as file: + with open(self._filename, encoding="utf-8") as file: data = json.load(file) # allow using opacity directly to keep interface # consistent for both backends diff --git a/python/grass/jupyter/map3d.py b/python/grass/jupyter/map3d.py index dd373f315a7..99253251406 100644 --- a/python/grass/jupyter/map3d.py +++ b/python/grass/jupyter/map3d.py @@ -210,10 +210,7 @@ def render(self, **kwargs): with Display( size=(self._width, self._height), **additional_kwargs ) as display: - if has_env_copy: - env = display.env() - else: - env = os.environ.copy() + env = display.env() if has_env_copy else os.environ.copy() self._region_manager.set_region_from_command(env=env, **kwargs) self.overlay.region_manager.set_region_from_env(env) gs.run_command(module, env=env, **kwargs) diff --git a/python/grass/jupyter/seriesmap.py b/python/grass/jupyter/seriesmap.py index 8615ad488fb..ae6bde911b6 100644 --- a/python/grass/jupyter/seriesmap.py +++ b/python/grass/jupyter/seriesmap.py @@ -20,7 +20,6 @@ from .map import Map from .region import RegionManagerForSeries -from .utils import save_gif from .baseseriesmap import BaseSeriesMap @@ -165,49 +164,3 @@ def render(self): ) tasks = [(i,) for i in range(self.baseseries)] self._render(tasks) - - def save( - self, - filename, - duration=500, - label=True, - font=None, - text_size=12, - text_color="gray", - ): - """ - Creates a GIF animation of rendered layers. - - Text color must be in a format accepted by PIL ImageColor module. For supported - formats, visit: - https://pillow.readthedocs.io/en/stable/reference/ImageColor.html#color-names - - param str filename: name of output GIF file - param int duration: time to display each frame; milliseconds - param bool label: include label on each frame - param str font: font file - param int text_size: size of label text - param str text_color: color to use for the text - """ - - # Render images if they have not been already - if not self._layers_rendered: - self.render() - - tmp_files = [] - for file in self._base_filename_dict.values(): - tmp_files.append(file) - - save_gif( - tmp_files, - filename, - duration=duration, - label=label, - labels=self._labels, - font=font, - text_size=text_size, - text_color=text_color, - ) - - # Display the GIF - return filename diff --git a/python/grass/jupyter/tests/grass_jupyter_session_test.py b/python/grass/jupyter/tests/grass_jupyter_session_test.py index 7b6bc89e4ed..17b6e7fbf5d 100644 --- a/python/grass/jupyter/tests/grass_jupyter_session_test.py +++ b/python/grass/jupyter/tests/grass_jupyter_session_test.py @@ -27,8 +27,8 @@ def test_init_finish(tmp_path): import os import grass.script as gs import grass.jupyter as gj -gs.core._create_location_xy("{tmp_path}", "{location}") -session = gj.init("{tmp_path / location}") +gs.core._create_location_xy(r"{tmp_path}", r"{location}") +session = gj.init(r"{tmp_path / location}") gs.read_command("g.region", flags="p") print(os.environ["GISRC"]) session.finish() @@ -49,8 +49,8 @@ def test_init_with_auto_finish(tmp_path): import os import grass.script as gs import grass.jupyter as gj -gs.core._create_location_xy("{tmp_path}", "{location}") -session = gj.init("{tmp_path / location}") +gs.core._create_location_xy(r"{tmp_path}", r"{location}") +session = gj.init(r"{tmp_path / location}") print(os.environ["GISRC"]) """ diff --git a/python/grass/jupyter/tests/reprojection_renderer_test.py b/python/grass/jupyter/tests/reprojection_renderer_test.py index 907522ab2f8..f9ef7888110 100644 --- a/python/grass/jupyter/tests/reprojection_renderer_test.py +++ b/python/grass/jupyter/tests/reprojection_renderer_test.py @@ -1,7 +1,7 @@ """Test ReprojectionRenderer functions""" from pathlib import Path -from pytest import approx +import pytest from grass.jupyter.reprojection_renderer import ReprojectionRenderer @@ -21,8 +21,8 @@ def test_render_raster(simple_dataset): assert Path(filename).exists() # Test bounding box is correct # Raster is same extent as region so no need to test bbox for use_region=True - assert bbox[0] == approx([0.00072155, -85.48874388]) - assert bbox[1] == approx([0.00000000, -85.48766880]) + assert bbox[0] == pytest.approx([0.00072155, -85.48874388]) + assert bbox[1] == pytest.approx([0.00000000, -85.48766880]) # render_vector produces json diff --git a/python/grass/jupyter/testsuite/interactivemap_test.py b/python/grass/jupyter/testsuite/interactivemap_test.py index 6b8a7379548..493578596b5 100644 --- a/python/grass/jupyter/testsuite/interactivemap_test.py +++ b/python/grass/jupyter/testsuite/interactivemap_test.py @@ -103,24 +103,26 @@ def test_query_button(self): # Create InteractiveMap with ipyleaflet backend interactive_map = gj.InteractiveMap(map_backend="ipyleaflet") interactive_map.add_raster("elevation") - interactive_map.add_vector("roadsmajor") - interactive_map.add_query_button() - self.assertIsNotNone(interactive_map.map) - self.assertTrue(interactive_map.query_mode is False) - # Toggle query button to activate - interactive_map.query_mode = True - self.assertTrue(interactive_map.query_mode) - # Toggle query button to deactivate - interactive_map.query_mode = False - self.assertFalse(interactive_map.query_mode) + button = interactive_map.setup_query_interface() + self.assertIsNotNone(interactive_map._controllers[button].query_raster((0, 0))) + + @unittest.skipIf(not can_import_ipyleaflet(), "Cannot import ipyleaflet") + def test_draw(self): + """Test the draw_computational_region method.""" + # Create InteractiveMap + interactive_map = gj.InteractiveMap(map_backend="ipyleaflet") + button = interactive_map.setup_drawing_interface() + interactive_map._controllers[button].activate() + self.assertIsNotNone(interactive_map._controllers[button].save_button_control) @unittest.skipIf(not can_import_ipyleaflet(), "Cannot import ipyleaflet") def test_draw_computational_region(self): """Test the draw_computational_region method.""" # Create InteractiveMap - interactive_map = gj.InteractiveMap() - interactive_map.draw_computational_region() - self.assertTrue(callable(interactive_map.draw_computational_region)) + interactive_map = gj.InteractiveMap(map_backend="ipyleaflet") + button = interactive_map.setup_computational_region_interface() + interactive_map._controllers[button].activate() + self.assertIsNotNone(interactive_map._controllers[button].save_button_control) if __name__ == "__main__": diff --git a/python/grass/jupyter/testsuite/map3d_test.py b/python/grass/jupyter/testsuite/map3d_test.py index b28b6a03a5b..5f88fad24e7 100644 --- a/python/grass/jupyter/testsuite/map3d_test.py +++ b/python/grass/jupyter/testsuite/map3d_test.py @@ -26,6 +26,7 @@ import grass.jupyter as gj from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows def can_import_ipython(): @@ -81,12 +82,14 @@ def tearDown(self): else: file.unlink(missing_ok=True) + @xfail_windows def test_defaults(self): """Check that default settings work""" renderer = gj.Map3D() renderer.render(elevation_map="elevation", color_map="elevation") self.assertFileExists(renderer.filename) + @xfail_windows def test_filename(self): """Check that custom filename works""" custom_filename = "test_filename.png" @@ -96,12 +99,14 @@ def test_filename(self): renderer.render(elevation_map="elevation", color_map="elevation") self.assertFileExists(custom_filename) + @xfail_windows def test_hw(self): """Check that custom width and height works""" renderer = gj.Map3D(width=200, height=400) renderer.render(elevation_map="elevation", color_map="elevation") self.assertFileExists(renderer.filename) + @xfail_windows def test_overlay(self): """Check that overlay works""" renderer = gj.Map3D() diff --git a/python/grass/jupyter/timeseriesmap.py b/python/grass/jupyter/timeseriesmap.py index 3ac94bea93e..2acfa575126 100644 --- a/python/grass/jupyter/timeseriesmap.py +++ b/python/grass/jupyter/timeseriesmap.py @@ -20,7 +20,6 @@ from .map import Map from .region import RegionManagerForTimeSeries -from .utils import save_gif from .baseseriesmap import BaseSeriesMap @@ -312,49 +311,3 @@ def render(self): filename = os.path.join(self._tmpdir.name, f"{layer}.png") tasks.append((date, layer, filename)) self._render(tasks) - - def save( - self, - filename, - duration=500, - label=True, - font="DejaVuSans.ttf", - text_size=12, - text_color="gray", - ): - """ - Creates a GIF animation of rendered layers. - - Text color must be in a format accepted by PIL ImageColor module. For supported - formats, visit: - https://pillow.readthedocs.io/en/stable/reference/ImageColor.html#color-names - - param str filename: name of output GIF file - param int duration: time to display each frame; milliseconds - param bool label: include date/time stamp on each frame - param str font: font file - param int text_size: size of date/time text - param str text_color: color to use for the text. - """ - - # Render images if they have not been already - if not self._layers_rendered: - self.render() - - input_files = [] - for date in self._labels: - input_files.append(self._base_filename_dict[date]) - - save_gif( - input_files, - filename, - duration=duration, - label=label, - labels=self._labels, - font=font, - text_size=text_size, - text_color=text_color, - ) - - # Display the GIF - return filename diff --git a/python/grass/pydispatch/robustapply.py b/python/grass/pydispatch/robustapply.py index a050f54341a..2ec88443a1a 100644 --- a/python/grass/pydispatch/robustapply.py +++ b/python/grass/pydispatch/robustapply.py @@ -35,7 +35,7 @@ def function(receiver): if hasattr(receiver, im_func): # an instance-method... return receiver, getattr(getattr(receiver, im_func), func_code), 1 - elif not hasattr(receiver, func_code): + if not hasattr(receiver, func_code): raise ValueError("unknown receiver type %s %s" % (receiver, type(receiver))) return receiver, getattr(receiver, func_code), 0 @@ -86,5 +86,5 @@ def robustApply(receiver, *arguments, **named): ) # fc does not have a **kwds type parameter, therefore # remove unacceptable arguments. - named = dict([(k, v) for k, v in named.items() if k in acceptable]) + named = {k: v for k, v in named.items() if k in acceptable} return receiver(*arguments, **named) diff --git a/python/grass/pydispatch/saferef.py b/python/grass/pydispatch/saferef.py index a802a1982c1..90769c46b36 100644 --- a/python/grass/pydispatch/saferef.py +++ b/python/grass/pydispatch/saferef.py @@ -35,8 +35,7 @@ def safeRef(target, onDelete=None): return BoundMethodWeakref(target=target, onDelete=onDelete) if onDelete is not None: return weakref.ref(target, onDelete) - else: - return weakref.ref(target) + return weakref.ref(target) class BoundMethodWeakref: @@ -92,11 +91,10 @@ def __new__(cls, target, onDelete=None, *arguments, **named): if current is not None: current.deletionMethods.append(onDelete) return current - else: - base = super().__new__(cls) - cls._allInstances[key] = base - base.__init__(target, onDelete, *arguments, **named) - return base + base = super().__new__(cls) + cls._allInstances[key] = base + base.__init__(target, onDelete, *arguments, **named) + return base def __init__(self, target, onDelete=None): """Return a weak-reference-like instance for a bound method diff --git a/python/grass/pydispatch/signal.py b/python/grass/pydispatch/signal.py index 1e968e99dca..51808e01ee3 100644 --- a/python/grass/pydispatch/signal.py +++ b/python/grass/pydispatch/signal.py @@ -7,7 +7,7 @@ from grass.pydispatch import dispatcher -def _islambda(function): +def _islambda(function) -> bool: """ Tests if object is a lambda function. @@ -146,10 +146,7 @@ class connects to the signal:: will print """ if weak is None: - if _islambda(handler): - weak = False - else: - weak = True + weak = not _islambda(handler) dispatcher.connect(receiver=handler, signal=self, weak=weak) def disconnect(self, handler, weak=True): diff --git a/python/grass/pygrass/errors.py b/python/grass/pygrass/errors.py index a63b300a862..a017b85b33f 100644 --- a/python/grass/pygrass/errors.py +++ b/python/grass/pygrass/errors.py @@ -11,9 +11,8 @@ def must_be_open(method): def wrapper(self, *args, **kargs): if self.is_open(): return method(self, *args, **kargs) - else: - msgr = get_msgr() - msgr.warning(_("The map is close!")) + msgr = get_msgr() + msgr.warning(_("The map is close!")) return wrapper @@ -23,10 +22,7 @@ def mapinfo_must_be_set(method): def wrapper(self, *args, **kargs): if self.c_mapinfo: return method(self, *args, **kargs) - else: - raise GrassError( - _("The self.c_mapinfo pointer must be correctly initiated") - ) + raise GrassError(_("The self.c_mapinfo pointer must be correctly initiated")) return wrapper @@ -36,9 +32,6 @@ def must_be_in_current_mapset(method): def wrapper(self, *args, **kargs): if self.mapset == libgis.G_mapset().decode(): return method(self, *args, **kargs) - else: - raise GrassError( - _("Map <{}> not found in current mapset").format(self.name) - ) + raise GrassError(_("Map <{}> not found in current mapset").format(self.name)) return wrapper diff --git a/python/grass/pygrass/gis/__init__.py b/python/grass/pygrass/gis/__init__.py index 3f380368d28..29fecd3d699 100644 --- a/python/grass/pygrass/gis/__init__.py +++ b/python/grass/pygrass/gis/__init__.py @@ -114,7 +114,7 @@ def make_mapset(mapset, location=None, gisdbase=None): res = libgis.G_make_mapset(gisdbase, location, mapset) if res == -1: raise GrassError("Cannot create new mapset") - elif res == -2: + if res == -2: raise GrassError("Illegal name") @@ -162,8 +162,7 @@ def __getitem__(self, location): """ if location in self.locations(): return Location(location, self.name) - else: - raise KeyError("Location: %s does not exist" % location) + raise KeyError("Location: %s does not exist" % location) def __iter__(self): for loc in self.locations(): @@ -234,8 +233,7 @@ def _set_name(self, name): def __getitem__(self, mapset): if mapset in self.mapsets(): return Mapset(mapset) - else: - raise KeyError("Mapset: %s does not exist" % mapset) + raise KeyError("Mapset: %s does not exist" % mapset) def __iter__(self): lpath = self.path() @@ -271,7 +269,7 @@ def mapsets(self, pattern=None, permissions=True): [...] """ - mapsets = [mapset for mapset in self] + mapsets = [mapset for mapset in self] # noqa: C416 if permissions: mapsets = [ mapset @@ -430,7 +428,7 @@ def __iter__(self): def read(self): """Return the mapsets in the search path""" try: - with open(self.spath, "r") as f: + with open(self.spath) as f: lines = f.readlines() if lines: return [line.strip() for line in lines] diff --git a/python/grass/pygrass/gis/region.py b/python/grass/pygrass/gis/region.py index 98c75a15631..892a3664b49 100644 --- a/python/grass/pygrass/gis/region.py +++ b/python/grass/pygrass/gis/region.py @@ -331,10 +331,7 @@ def __eq__(self, reg): "zone", "proj", ] - for attr in attrs: - if getattr(self, attr) != getattr(reg, attr): - return False - return True + return all(getattr(self, attr) == getattr(reg, attr) for attr in attrs) def __ne__(self, other): return not self == other diff --git a/python/grass/pygrass/messages/__init__.py b/python/grass/pygrass/messages/__init__.py index 36356433381..54d9af1b1c5 100644 --- a/python/grass/pygrass/messages/__init__.py +++ b/python/grass/pygrass/messages/__init__.py @@ -262,8 +262,7 @@ def fatal(self, message): if self.raise_on_error is True: raise FatalError(message) - else: - sys.exit(1) + sys.exit(1) def debug(self, level, message): """Send a debug message to stderr diff --git a/python/grass/pygrass/modules/__init__.py b/python/grass/pygrass/modules/__init__.py index 61073791599..ce4d169fedd 100644 --- a/python/grass/pygrass/modules/__init__.py +++ b/python/grass/pygrass/modules/__init__.py @@ -1,2 +1,9 @@ -from grass.pygrass.modules.interface import Module, MultiModule, ParallelModuleQueue from grass.pygrass.modules import shortcuts +from grass.pygrass.modules.interface import Module, MultiModule, ParallelModuleQueue + +__all__ = [ + "Module", + "MultiModule", + "ParallelModuleQueue", + "shortcuts", +] diff --git a/python/grass/pygrass/modules/grid/__init__.py b/python/grass/pygrass/modules/grid/__init__.py index 1c971174998..0d770ed3ad2 100644 --- a/python/grass/pygrass/modules/grid/__init__.py +++ b/python/grass/pygrass/modules/grid/__init__.py @@ -1 +1,3 @@ from grass.pygrass.modules.grid.grid import GridModule + +__all__ = ["GridModule"] diff --git a/python/grass/pygrass/modules/grid/grid.py b/python/grass/pygrass/modules/grid/grid.py index fb338ca973a..ffae173ca79 100644 --- a/python/grass/pygrass/modules/grid/grid.py +++ b/python/grass/pygrass/modules/grid/grid.py @@ -121,10 +121,8 @@ def read_gisrc(gisrc): ... genv['GISDBASE'])) True """ - with open(gisrc, "r") as gfile: - gis = dict( - [(k.strip(), v.strip()) for k, v in [row.split(":", 1) for row in gfile]] - ) + with open(gisrc) as gfile: + gis = {k.strip(): v.strip() for k, v in [row.split(":", 1) for row in gfile]} return gis["MAPSET"], gis["LOCATION_NAME"], gis["GISDBASE"] @@ -147,7 +145,7 @@ def get_mapset(gisrc_src, gisrc_dst): copy_special_mapset_files(path_src, path_dst) src = Mapset(msrc, lsrc, gsrc) dst = Mapset(mdst, ldst, gdst) - visible = [m for m in src.visible] + visible = list(src.visible) if src.name not in visible: visible.append(src.name) dst.visible.extend(visible) @@ -189,7 +187,7 @@ def rmloc(r): # change gisdbase to src env["GISRC"] = gisrc_src get_grp(group=grp, env_=env) - rasts = [r for r in get_grp.outputs.stdout.split()] + rasts = list(get_grp.outputs.stdout.split()) # change gisdbase to dst env["GISRC"] = gisrc_dst rast2cp = [r for r in rasts if rmloc(r) not in all_rasts] @@ -497,15 +495,15 @@ def __init__( self.gisrc_dst = write_gisrc( self.n_mset.gisdbase, self.n_mset.location, self.n_mset.name ) - rasters = [r for r in select(self.module.inputs, "raster")] + rasters = list(select(self.module.inputs, "raster")) if rasters: copy_rasters( rasters, self.gisrc_src, self.gisrc_dst, region=self.region ) - vectors = [v for v in select(self.module.inputs, "vector")] + vectors = list(select(self.module.inputs, "vector")) if vectors: copy_vectors(vectors, self.gisrc_src, self.gisrc_dst) - groups = [g for g in select(self.module.inputs, "group")] + groups = list(select(self.module.inputs, "group")) if groups: copy_groups(groups, self.gisrc_src, self.gisrc_dst, region=self.region) self.bboxes = split_region_in_overlapping_tiles( @@ -592,7 +590,7 @@ def get_works(self): else: ldst, gdst = self.mset.location, self.mset.gisdbase cmd = self.module.get_dict() - groups = [g for g in select(self.module.inputs, "group")] + groups = list(select(self.module.inputs, "group")) for row, box_row in enumerate(self.bboxes): for col, box in enumerate(box_row): inms = None @@ -603,7 +601,7 @@ def get_works(self): indx = row * cols + col inms[key] = "%s@%s" % (self.inlist[key][indx], self.mset.name) # set the computational region, prepare the region parameters - bbox = dict([(k[0], str(v)) for k, v in box.items()[:-2]]) + bbox = {k[0]: str(v) for k, v in box.items()[:-2]} bbox["nsres"] = "%f" % reg.nsres bbox["ewres"] = "%f" % reg.ewres new_mset = ( diff --git a/python/grass/pygrass/modules/interface/__init__.py b/python/grass/pygrass/modules/interface/__init__.py index a05211e21c3..bde59049c6e 100644 --- a/python/grass/pygrass/modules/interface/__init__.py +++ b/python/grass/pygrass/modules/interface/__init__.py @@ -4,14 +4,20 @@ @author: pietro """ -from grass.pygrass.modules.interface import flag -from grass.pygrass.modules.interface import parameter -from grass.pygrass.modules.interface import module -from grass.pygrass.modules.interface import typedict -from grass.pygrass.modules.interface import read - +from grass.pygrass.modules.interface import flag, module, parameter, read, typedict from grass.pygrass.modules.interface.module import ( Module, MultiModule, ParallelModuleQueue, ) + +__all__ = [ + "Module", + "MultiModule", + "ParallelModuleQueue", + "flag", + "module", + "parameter", + "read", + "typedict", +] diff --git a/python/grass/pygrass/modules/interface/docstring.py b/python/grass/pygrass/modules/interface/docstring.py index 2fde05f73de..397338fcbb8 100644 --- a/python/grass/pygrass/modules/interface/docstring.py +++ b/python/grass/pygrass/modules/interface/docstring.py @@ -44,8 +44,7 @@ def __init__(self, class_doc, fget): def __get__(self, obj, type=None): if obj is None: return self.class_doc - else: - return self.fget(obj) + return self.fget(obj) def __set__(self, obj, value): raise AttributeError("can't set attribute") diff --git a/python/grass/pygrass/modules/interface/env.py b/python/grass/pygrass/modules/interface/env.py index ad6e4c4800e..d3d6e371238 100644 --- a/python/grass/pygrass/modules/interface/env.py +++ b/python/grass/pygrass/modules/interface/env.py @@ -13,13 +13,10 @@ def get_env(): gisrc = os.environ.get("GISRC") if gisrc is None: raise RuntimeError("You are not in a GRASS session, GISRC not found.") - with open(gisrc, mode="r") as grc: - return dict( - [ - (k.strip(), v.strip()) - for k, v in [row.split(":", 1) for row in grc if row] - ] - ) + with open(gisrc) as grc: + return { + k.strip(): v.strip() for k, v in [row.split(":", 1) for row in grc if row] + } def get_debug_level(): diff --git a/python/grass/pygrass/modules/interface/flag.py b/python/grass/pygrass/modules/interface/flag.py index b2e78e30717..b6f00fdb744 100644 --- a/python/grass/pygrass/modules/interface/flag.py +++ b/python/grass/pygrass/modules/interface/flag.py @@ -52,10 +52,8 @@ def get_bash(self): if self.value: if self.special: return "--%s" % self.name[0] - else: - return "-%s" % self.name - else: - return "" + return "-%s" % self.name + return "" def get_python(self): """Return the python representation of a flag. diff --git a/python/grass/pygrass/modules/interface/module.py b/python/grass/pygrass/modules/interface/module.py index c8a1e723a05..7f70d82bac1 100644 --- a/python/grass/pygrass/modules/interface/module.py +++ b/python/grass/pygrass/modules/interface/module.py @@ -559,7 +559,7 @@ def __init__(self, cmd, *args, **kargs): # get the xml of the module self.xml = get_cmd_xml.communicate()[0] # transform and parse the xml into an Element class: - # http://docs.python.org/library/xml.etree.elementtree.html + # https://docs.python.org/library/xml.etree.elementtree.html tree = fromstring(self.xml) for e in tree: @@ -720,12 +720,11 @@ def get_python(self): # pre name par flg special if flags and special: return "%s.%s(%s, flags=%r, %s)" % (prefix, name, params, flags, special) - elif flags: + if flags: return "%s.%s(%s, flags=%r)" % (prefix, name, params, flags) - elif special: + if special: return "%s.%s(%s, %s)" % (prefix, name, params, special) - else: - return "%s.%s(%s)" % (prefix, name, params) + return "%s.%s(%s)" % (prefix, name, params) def __str__(self): """Return the command string that can be executed in a shell""" @@ -1026,16 +1025,15 @@ def run(self): module.finish_ = True module.run() return None + if self.set_temp_region is True: + self.p = Process( + target=run_modules_in_temp_region, args=[self.module_list, self.q] + ) else: - if self.set_temp_region is True: - self.p = Process( - target=run_modules_in_temp_region, args=[self.module_list, self.q] - ) - else: - self.p = Process(target=run_modules, args=[self.module_list, self.q]) - self.p.start() + self.p = Process(target=run_modules, args=[self.module_list, self.q]) + self.p.start() - return self.p + return self.p def wait(self): """Wait for all processes to finish. Call this method diff --git a/python/grass/pygrass/modules/interface/parameter.py b/python/grass/pygrass/modules/interface/parameter.py index 798efde56b7..d950cd40008 100644 --- a/python/grass/pygrass/modules/interface/parameter.py +++ b/python/grass/pygrass/modules/interface/parameter.py @@ -18,15 +18,15 @@ def _check_value(param, value): string = (bytes, str) def raiseexcpet(exc, param, ptype, value): - """Function to modifa the error message""" + """Function to modify the error message""" msg = req % (param.name, param.typedesc, ptype, value, str(exc)) if isinstance(exc, ValueError): raise ValueError(msg) - elif isinstance(exc, TypeError): + if isinstance(exc, TypeError): raise TypeError(msg) - else: - exc.message = msg - raise exc + + exc.message = msg + raise exc def check_string(value): """Function to check that a string parameter is already a string""" @@ -216,7 +216,7 @@ def __init__(self, xparameter=None, diz=None): # if "gisprompt" in diz and diz["gisprompt"]: self.typedesc = diz["gisprompt"].get("prompt", "") - self.input = not diz["gisprompt"]["age"] == "new" + self.input = diz["gisprompt"]["age"] != "new" else: self.input = True @@ -337,10 +337,7 @@ def __doc__(self): .. """ if hasattr(self, "values"): - if self.isrange: - vals = self.isrange - else: - vals = ", ".join([repr(val) for val in self.values]) + vals = self.isrange or ", ".join([repr(val) for val in self.values]) else: vals = False if self.keydescvalues: diff --git a/python/grass/pygrass/modules/interface/testsuite/test_modules.py b/python/grass/pygrass/modules/interface/testsuite/test_modules.py index 3318154f87d..ee005498692 100644 --- a/python/grass/pygrass/modules/interface/testsuite/test_modules.py +++ b/python/grass/pygrass/modules/interface/testsuite/test_modules.py @@ -21,7 +21,7 @@ class ModulesMeta(type): - def __new__(mcs, name, bases, dict): + def __new__(cls, name, bases, dict): def gen_test(cmd): def test(self): Module(cmd) @@ -36,7 +36,7 @@ def test(self): for cmd in cmds: test_name = "test__%s" % cmd.replace(".", "_") dict[test_name] = gen_test(cmd) - return type.__new__(mcs, name, bases, dict) + return type.__new__(cls, name, bases, dict) class TestModules(TestCase, metaclass=ModulesMeta): diff --git a/python/grass/pygrass/modules/tests/grass_pygrass_grid_test.py b/python/grass/pygrass/modules/tests/grass_pygrass_grid_test.py index 6a9915b6a14..c4ada9c4667 100644 --- a/python/grass/pygrass/modules/tests/grass_pygrass_grid_test.py +++ b/python/grass/pygrass/modules/tests/grass_pygrass_grid_test.py @@ -210,7 +210,7 @@ def run_grid_module(): @xfail_mp_spawn @pytest.mark.parametrize( - "width, height, processes", + ("width", "height", "processes"), [ (None, None, max_processes()), (10, None, max_processes()), @@ -249,7 +249,7 @@ def run_grid_module(): @xfail_mp_spawn @pytest.mark.needs_solo_run @pytest.mark.parametrize( - "processes, backend", + ("processes", "backend"), [ (1, "RasterRow"), (9, "RasterRow"), diff --git a/python/grass/pygrass/modules/testsuite/test_import_isolation.py b/python/grass/pygrass/modules/testsuite/test_import_isolation.py index d1321a554d0..af643ec2fee 100644 --- a/python/grass/pygrass/modules/testsuite/test_import_isolation.py +++ b/python/grass/pygrass/modules/testsuite/test_import_isolation.py @@ -36,14 +36,17 @@ def test_import_isolation(self): isolate, check(*self.patterns), msg="Test isolation before any import." ) # same import done in __init__ file - from grass.pygrass.modules.interface import Module, ParallelModuleQueue - from grass.pygrass.modules import shortcuts + from grass.pygrass.modules.interface import ( + Module, # noqa: F401 + ParallelModuleQueue, # noqa: F401 + ) + from grass.pygrass.modules import shortcuts # noqa: F401 self.assertEqual( isolate, check(*self.patterns), msg="Test isolation after import Module." ) # test the other way round - from grass.pygrass.vector import VectorTopo + from grass.pygrass.vector import VectorTopo # noqa: F401 self.assertNotEqual( isolate, diff --git a/python/grass/pygrass/raster/__init__.py b/python/grass/pygrass/raster/__init__.py index 0356513e017..61ec85841cb 100644 --- a/python/grass/pygrass/raster/__init__.py +++ b/python/grass/pygrass/raster/__init__.py @@ -327,17 +327,16 @@ def __setitem__(self, key, row): if isinstance(key, slice): # Get the start, stop, and step from the slice return [self.put_row(ii, row) for ii in range(*key.indices(len(self)))] - elif isinstance(key, tuple): + if isinstance(key, tuple): x, y = key return self.put(x, y, row) - elif isinstance(key, int): + if isinstance(key, int): if key < 0: # Handle negative indices key += self._rows if key >= self._rows: raise IndexError(_("Index out of range: %r.") % key) return self.put_row(key, row) - else: - raise TypeError("Invalid argument type.") + raise TypeError("Invalid argument type.") @must_be_open def map2segment(self): diff --git a/python/grass/pygrass/raster/abstract.py b/python/grass/pygrass/raster/abstract.py index edea42e7bdd..68b5e501ed4 100644 --- a/python/grass/pygrass/raster/abstract.py +++ b/python/grass/pygrass/raster/abstract.py @@ -393,10 +393,10 @@ def __getitem__(self, key): if isinstance(key, slice): # Get the start, stop, and step from the slice return (self.get_row(ii) for ii in range(*key.indices(len(self)))) - elif isinstance(key, tuple): + if isinstance(key, tuple): x, y = key return self.get(x, y) - elif isinstance(key, int): + if isinstance(key, int): if not self.is_open(): raise IndexError("Can not operate on a closed map. Call open() first.") if key < 0: # Handle negative indices @@ -408,8 +408,7 @@ def __getitem__(self, key): ) ) return self.get_row(key) - else: - fatal("Invalid argument type.") + fatal("Invalid argument type.") def __iter__(self): """Return a constructor of the class""" @@ -434,8 +433,7 @@ def exist(self): self.mapset = mapset or "" return bool(mapset) return bool(utils.get_mapset_raster(self.name, self.mapset)) - else: - return False + return False def is_open(self): """Return True if the map is open False otherwise. @@ -485,8 +483,7 @@ def name_mapset(self, name=None, mapset=None): if mapset and mapset != gis_env["MAPSET"]: return "{name}@{mapset}".format(name=name, mapset=mapset) - else: - return name + return name def rename(self, newname): """Rename the map""" diff --git a/python/grass/pygrass/raster/buffer.py b/python/grass/pygrass/raster/buffer.py index 51420f16610..0e34ac84159 100644 --- a/python/grass/pygrass/raster/buffer.py +++ b/python/grass/pygrass/raster/buffer.py @@ -20,13 +20,12 @@ class Buffer(np.ndarray): def mtype(self): if self.dtype in CELL: return "CELL" - elif self.dtype in FCELL: + if self.dtype in FCELL: return "FCELL" - elif self.dtype in DCELL: + if self.dtype in DCELL: return DCELL - else: - err = "Raster type: %r not supported by GRASS." - raise TypeError(err % self.dtype) + err = "Raster type: %r not supported by GRASS." + raise TypeError(err % self.dtype) def __new__( cls, shape, mtype="FCELL", buffer=None, offset=0, strides=None, order=None diff --git a/python/grass/pygrass/raster/category.py b/python/grass/pygrass/raster/category.py index 00381f91130..9c34bb8390f 100644 --- a/python/grass/pygrass/raster/category.py +++ b/python/grass/pygrass/raster/category.py @@ -68,7 +68,7 @@ def _get_mtype(self): def _set_mtype(self, mtype): if mtype.upper() not in {"CELL", "FCELL", "DCELL"}: - raise ValueError(_("Raster type: {0} not supported".format(mtype))) + raise ValueError(_("Raster type: {0} not supported").format(mtype)) self._mtype = mtype self._gtype = RTYPE[self.mtype]["grass type"] @@ -187,9 +187,9 @@ def _set_c_cat(self, label, min_cat, max_cat=None): # Manage C function Errors if err == 1: return None - elif err == 0: + if err == 0: raise GrassError(_("Null value detected")) - elif err == -1: + if err == -1: raise GrassError(_("Error executing: Rast_set_cat")) def __del__(self): @@ -299,7 +299,7 @@ def read_rules(self, filename, sep=":"): """ self.reset() - with open(filename, "r") as f: + with open(filename) as f: for row in f: cat = row.strip().split(sep) if len(cat) == 2: diff --git a/python/grass/pygrass/raster/history.py b/python/grass/pygrass/raster/history.py index 5ec855cf1bb..8f227affabc 100644 --- a/python/grass/pygrass/raster/history.py +++ b/python/grass/pygrass/raster/history.py @@ -59,10 +59,7 @@ def __del__(self): """Rast_free_history""" def __eq__(self, hist): - for attr in self.attrs: - if getattr(self, attr) != getattr(hist, attr): - return False - return True + return all(getattr(self, attr) == getattr(hist, attr) for attr in self.attrs) def __len__(self): return self.length() diff --git a/python/grass/pygrass/raster/testsuite/test_category.py b/python/grass/pygrass/raster/testsuite/test_category.py index 527c43b894f..113264c82f6 100644 --- a/python/grass/pygrass/raster/testsuite/test_category.py +++ b/python/grass/pygrass/raster/testsuite/test_category.py @@ -6,6 +6,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows from grass.pygrass.raster import RasterRow from grass.pygrass.raster.category import Category @@ -76,6 +77,7 @@ def testFirstCat(self): self.assertEqual(cats[7], cat7) self.assertEqual(cats[15], cat15) + @xfail_windows def testWrite(self): tmpfile = tempfile(False) cats = Category(self.name) diff --git a/python/grass/pygrass/raster/testsuite/test_numpy.py b/python/grass/pygrass/raster/testsuite/test_numpy.py index 5f0b2309544..b23926d8ba7 100644 --- a/python/grass/pygrass/raster/testsuite/test_numpy.py +++ b/python/grass/pygrass/raster/testsuite/test_numpy.py @@ -6,6 +6,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows from numpy.random import default_rng from grass.pygrass.raster import raster2numpy, numpy2raster, RasterRow @@ -48,6 +49,7 @@ def test_len(self): self.assertTrue(len(self.numpy_obj), 40) self.assertTrue(len(self.numpy_obj[0]), 60) + @xfail_windows def test_write(self): rng = default_rng() numpy2raster(rng.random([40, 60]), "FCELL", self.name, True) diff --git a/python/grass/pygrass/raster/testsuite/test_raster_img.py b/python/grass/pygrass/raster/testsuite/test_raster_img.py index bbc1cb2dabd..b873b16a86b 100644 --- a/python/grass/pygrass/raster/testsuite/test_raster_img.py +++ b/python/grass/pygrass/raster/testsuite/test_raster_img.py @@ -3,6 +3,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows from grass.pygrass.raster import raster2numpy_img from grass.pygrass.gis.region import Region @@ -149,6 +150,7 @@ def test_resampling_to_numpy_img_1(self): self.assertEqual(len(a), region.rows * region.cols * 4) + @xfail_windows def test_resampling_to_numpy_img_2(self): region = Region() region.ewres = 1 @@ -159,6 +161,7 @@ def test_resampling_to_numpy_img_2(self): self.assertEqual(len(a), region.rows * region.cols * 4) + @xfail_windows def test_resampling_to_numpy_img_3(self): region = Region() region.ewres = 0.4 @@ -169,6 +172,7 @@ def test_resampling_to_numpy_img_3(self): self.assertEqual(len(a), region.rows * region.cols * 1) + @xfail_windows def test_resampling_to_numpy_img_4(self): region = Region() region.ewres = 0.1 diff --git a/python/grass/pygrass/rpc/__init__.py b/python/grass/pygrass/rpc/__init__.py index 07cbfe6503a..a6ab19b9369 100644 --- a/python/grass/pygrass/rpc/__init__.py +++ b/python/grass/pygrass/rpc/__init__.py @@ -10,8 +10,6 @@ :authors: Soeren Gebbert """ -import time -import threading import sys from multiprocessing import Process, Lock, Pipe from ctypes import CFUNCTYPE, c_void_p @@ -24,7 +22,6 @@ from .base import RPCServerBase from grass.pygrass.gis.region import Region from grass.pygrass import utils -import logging ############################################################################### ############################################################################### diff --git a/python/grass/pygrass/tests/benchmark.py b/python/grass/pygrass/tests/benchmark.py index 75e32541a59..fa7f0c01a65 100644 --- a/python/grass/pygrass/tests/benchmark.py +++ b/python/grass/pygrass/tests/benchmark.py @@ -12,11 +12,11 @@ import copy import cProfile import sys -import os from jinja2 import Template +from pathlib import Path -sys.path.append(os.getcwd()) -sys.path.append("%s/.." % (os.getcwd())) +sys.path.append(str(Path.cwd())) +sys.path.append("%s/.." % (str(Path.cwd()))) import grass.lib.gis as libgis import grass.lib.raster as libraster diff --git a/python/grass/pygrass/tests/set_mapset.py b/python/grass/pygrass/tests/set_mapset.py index f9d4a96fabf..105735efa5a 100644 --- a/python/grass/pygrass/tests/set_mapset.py +++ b/python/grass/pygrass/tests/set_mapset.py @@ -13,7 +13,7 @@ def read_gisrc(gisrcpath): - gisrc = open(gisrcpath, "r") + gisrc = open(gisrcpath) diz = {} for row in gisrc: key, val = row.split(":") diff --git a/python/grass/pygrass/utils.py b/python/grass/pygrass/utils.py index a04e3936a64..d8804665b1e 100644 --- a/python/grass/pygrass/utils.py +++ b/python/grass/pygrass/utils.py @@ -83,24 +83,23 @@ def find_in_gisdbase(type, pattern, gisdbase): (m, mset.name, mset.location, mset.gisdbase) for m in mset.glist(type, pattern) ] - elif gisdbase and location: + if gisdbase and location: loc = Location(location, gisdbase) return find_in_location(type, pattern, loc) - elif gisdbase: + if gisdbase: gis = Gisdbase(gisdbase) return find_in_gisdbase(type, pattern, gis) - elif location: + if location: loc = Location(location) return find_in_location(type, pattern, loc) - elif mapset: + if mapset: mset = Mapset(mapset) return [ (m, mset.name, mset.location, mset.gisdbase) for m in mset.glist(type, pattern) ] - else: - gis = Gisdbase() - return find_in_gisdbase(type, pattern, gis) + gis = Gisdbase() + return find_in_gisdbase(type, pattern, gis) def remove(oldname, maptype): @@ -136,11 +135,10 @@ def decode(obj, encoding=None): """ if isinstance(obj, String): return grassutils.decode(obj.data, encoding=encoding) - elif isinstance(obj, bytes): + if isinstance(obj, bytes): return grassutils.decode(obj) - else: - # eg None - return obj + # eg None + return obj def getenv(env): @@ -337,9 +335,8 @@ def get_raster_for_points(poi_vector, raster, column=None, region=None): result.append((poi.id, poi.x, poi.y, None)) if not column: return result - else: - poi.attrs.commit() - return True + poi.attrs.commit() + return True def r_export(rast, output="", fmt="png", **kargs): @@ -355,8 +352,7 @@ def r_export(rast, output="", fmt="png", **kargs): **kargs, ) return output - else: - raise ValueError("Raster map does not exist.") + raise ValueError("Raster map does not exist.") def get_lib_path(modname, libname=None): diff --git a/python/grass/pygrass/vector/__init__.py b/python/grass/pygrass/vector/__init__.py index 6f29a167b2e..6723b2e44b3 100644 --- a/python/grass/pygrass/vector/__init__.py +++ b/python/grass/pygrass/vector/__init__.py @@ -70,8 +70,7 @@ def __init__(self, name, mapset="", *args, **kwargs): def __repr__(self): if self.exist(): return "%s(%r, %r)" % (self._class_name, self.name, self.mapset) - else: - return "%s(%r)" % (self._class_name, self.name) + return "%s(%r)" % (self._class_name, self.name) def __iter__(self): """:: @@ -315,10 +314,9 @@ def __getitem__(self, key): key.step or 1, ) ] - elif isinstance(key, int): + if isinstance(key, int): return self.read(key) - else: - raise ValueError("Invalid argument type: %r." % key) + raise ValueError("Invalid argument type: %r." % key) @must_be_open def num_primitive_of(self, primitive): @@ -392,11 +390,9 @@ def number_of(self, vtype): if isinstance(_NUMOF[vtype], tuple): fn, ptype = _NUMOF[vtype] return fn(self.c_mapinfo, ptype) - else: - return _NUMOF[vtype](self.c_mapinfo) - else: - keys = "', '".join(sorted(_NUMOF.keys())) - raise ValueError("vtype not supported, use one of: '%s'" % keys) + return _NUMOF[vtype](self.c_mapinfo) + keys = "', '".join(sorted(_NUMOF.keys())) + raise ValueError("vtype not supported, use one of: '%s'" % keys) @must_be_open def num_primitives(self): @@ -526,17 +522,16 @@ def cat(self, cat_id, vtype, layer=None, generator=False, geo=None): ) for v_id in ilist ) - else: - return [ - read_line( - feature_id=v_id, - c_mapinfo=self.c_mapinfo, - table=self.table, - writeable=self.writeable, - is2D=is2D, - ) - for v_id in ilist - ] + return [ + read_line( + feature_id=v_id, + c_mapinfo=self.c_mapinfo, + table=self.table, + writeable=self.writeable, + is2D=is2D, + ) + for v_id in ilist + ] @must_be_open def read(self, feature_id): @@ -855,7 +850,7 @@ def features_to_wkb_list(self, bbox=None, feature_type="point", field=1): if not barray: if error == -1: raise GrassError( - _("Unable to read line of feature %i" % (f_id)) + _("Unable to read line of feature %i") % (f_id) ) if error == -2: print("Empty feature %i" % (f_id)) @@ -864,10 +859,7 @@ def features_to_wkb_list(self, bbox=None, feature_type="point", field=1): ok = libvect.Vect_cat_get( ctypes.byref(line_c), field, ctypes.byref(cat) ) - if ok < 1: - pcat = None - else: - pcat = cat.value + pcat = None if ok < 1 else cat.value wkb_list.append((f_id, pcat, ctypes.string_at(barray, size.value))) libgis.G_free(barray) @@ -947,7 +939,7 @@ def areas_to_wkb_list(self, bbox=None, field=1): self.c_mapinfo, a_id, ctypes.byref(size) ) if not barray: - raise GrassError(_("Unable to read area with id %i" % (a_id))) + raise GrassError(_("Unable to read area with id %i") % (a_id)) pcat = None c_ok = libvect.Vect_get_area_cats( diff --git a/python/grass/pygrass/vector/abstract.py b/python/grass/pygrass/vector/abstract.py index 3929006ef25..79307f0d354 100644 --- a/python/grass/pygrass/vector/abstract.py +++ b/python/grass/pygrass/vector/abstract.py @@ -299,8 +299,7 @@ def exist(self): self.mapset = mapset or "" return bool(mapset) return bool(utils.get_mapset_vector(self.name, self.mapset)) - else: - return False + return False def is_open(self): """Return if the Vector is open""" @@ -458,14 +457,14 @@ def close(self, build=False): if hasattr(self, "table") and self.table is not None: self.table.conn.close() if self.is_open(): - if libvect.Vect_close(self.c_mapinfo) != 0: - str_err = "Error when trying to close the map with Vect_close" - raise GrassError(str_err) if ( self.c_mapinfo.contents.mode in {libvect.GV_MODE_RW, libvect.GV_MODE_WRITE} ) and build: self.build() + if libvect.Vect_close(self.c_mapinfo) != 0: + str_err = "Error when trying to close the map with Vect_close" + raise GrassError(str_err) def remove(self): """Remove vector map""" @@ -475,16 +474,11 @@ def remove(self): def build(self): """Close the vector map and build vector Topology""" - self.close() - libvect.Vect_set_open_level(1) - if libvect.Vect_open_old2(self.c_mapinfo, self.name, self.mapset, "0") != 1: - str_err = "Error when trying to open the vector map." - raise GrassError(str_err) - # Vect_build returns 1 on success and 0 on error (bool approach) - if libvect.Vect_build(self.c_mapinfo) != 1: - str_err = "Error when trying build topology with Vect_build" - raise GrassError(str_err) - libvect.Vect_close(self.c_mapinfo) + if self.is_open(): + # Vect_build returns 1 on success and 0 on error (bool approach) + if libvect.Vect_build(self.c_mapinfo) != 1: + str_err = "Error when trying build topology with Vect_build" + raise GrassError(str_err) if __name__ == "__main__": diff --git a/python/grass/pygrass/vector/basic.py b/python/grass/pygrass/vector/basic.py index 079f7ac829f..f031e23ff98 100644 --- a/python/grass/pygrass/vector/basic.py +++ b/python/grass/pygrass/vector/basic.py @@ -149,8 +149,7 @@ def nsewtb(self, tb=True): """ if tb: return (self.north, self.south, self.east, self.west, self.top, self.bottom) - else: - return (self.north, self.south, self.east, self.west) + return (self.north, self.south, self.east, self.west) class BoxList: @@ -308,14 +307,13 @@ def __getitem__(self, key): self.c_ilist.contents.value[indx] for indx in range(*key.indices(len(self))) ] - elif isinstance(key, int): + if isinstance(key, int): if key < 0: # Handle negative indices key += self.c_ilist.contents.n_values if key >= self.c_ilist.contents.n_values: raise IndexError("Index out of range") return self.c_ilist.contents.value[key] - else: - raise ValueError("Invalid argument type: %r." % key) + raise ValueError("Invalid argument type: %r." % key) def __setitem__(self, key, value): if self.contains(value): @@ -329,7 +327,7 @@ def __iter__(self): return (self.c_ilist.contents.value[i] for i in range(self.__len__())) def __repr__(self): - return "Ilist(%r)" % [i for i in self.__iter__()] + return "Ilist(%r)" % list(self.__iter__()) def __contains__(self, item): return item in self.__iter__() diff --git a/python/grass/pygrass/vector/find.py b/python/grass/pygrass/vector/find.py index 9333497f110..25ce9aca8f4 100644 --- a/python/grass/pygrass/vector/find.py +++ b/python/grass/pygrass/vector/find.py @@ -490,11 +490,10 @@ def geos(self, bbox, type="all", bboxlist_only=False): ): if bboxlist_only: return found - else: - return ( - read_line(f_id, self.c_mapinfo, self.table, self.writeable) - for f_id in found.ids - ) + return ( + read_line(f_id, self.c_mapinfo, self.table, self.writeable) + for f_id in found.ids + ) @must_be_open def nodes(self, bbox): @@ -592,16 +591,15 @@ def areas(self, bbox, boxlist=None, bboxlist_only=False): ): if bboxlist_only: return boxlist - else: - return ( - Area( - v_id=a_id, - c_mapinfo=self.c_mapinfo, - table=self.table, - writeable=self.writeable, - ) - for a_id in boxlist.ids + return ( + Area( + v_id=a_id, + c_mapinfo=self.c_mapinfo, + table=self.table, + writeable=self.writeable, ) + for a_id in boxlist.ids + ) @must_be_open def islands(self, bbox, bboxlist_only=False): @@ -652,16 +650,15 @@ def islands(self, bbox, bboxlist_only=False): ): if bboxlist_only: return found - else: - return ( - Isle( - v_id=i_id, - c_mapinfo=self.c_mapinfo, - table=self.table, - writeable=self.writeable, - ) - for i_id in found.ids + return ( + Isle( + v_id=i_id, + c_mapinfo=self.c_mapinfo, + table=self.table, + writeable=self.writeable, ) + for i_id in found.ids + ) class PolygonFinder(AbstractFinder): diff --git a/python/grass/pygrass/vector/geometry.py b/python/grass/pygrass/vector/geometry.py index 1c5d378e6ef..b734161d1ea 100644 --- a/python/grass/pygrass/vector/geometry.py +++ b/python/grass/pygrass/vector/geometry.py @@ -94,8 +94,7 @@ def intersects(lineA, lineB, with_z=False): lineA.c_points, lineB.c_points, line.c_points, int(with_z) ): return line - else: - return [] + return [] # ============================================= @@ -370,8 +369,7 @@ def cat(self): def has_topology(self): if self.c_mapinfo is not None: return self.c_mapinfo.contents.level == 2 - else: - return False + return False @mapinfo_must_be_set def read(self): @@ -539,8 +537,7 @@ def coords(self): """ if self.is2D: return self.x, self.y - else: - return self.x, self.y, self.z + return self.x, self.y, self.z def to_wkt_p(self): """Return a "well know text" (WKT) geometry string Python implementation. :: @@ -577,10 +574,9 @@ def distance(self, pnt): """ if self.is2D or pnt.is2D: return libvect.Vect_points_distance(self.x, self.y, 0, pnt.x, pnt.y, 0, 0) - else: - return libvect.Vect_points_distance( - self.x, self.y, self.z, pnt.x, pnt.y, pnt.z, 1 - ) + return libvect.Vect_points_distance( + self.x, self.y, self.z, pnt.x, pnt.y, pnt.z, 1 + ) def buffer( self, dist=None, dist_x=None, dist_y=None, angle=0, round_=True, tol=0.1 @@ -675,7 +671,7 @@ def __getitem__(self, key): ) for indx in range(*key.indices(len(self))) ] - elif isinstance(key, int): + if isinstance(key, int): if key < 0: # Handle negative indices key += self.c_points.contents.n_points if key >= self.c_points.contents.n_points: @@ -685,8 +681,7 @@ def __getitem__(self, key): self.c_points.contents.y[key], None if self.is2D else self.c_points.contents.z[key], ) - else: - raise ValueError("Invalid argument type: %r." % key) + raise ValueError("Invalid argument type: %r." % key) def __setitem__(self, indx, pnt): """Change the coordinate of point. :: @@ -815,10 +810,7 @@ def extend(self, line, forward=True): """ # set direction - if forward: - direction = libvect.GV_FORWARD - else: - direction = libvect.GV_BACKWARD + direction = libvect.GV_FORWARD if forward else libvect.GV_BACKWARD # check if is a Line object if isinstance(line, Line): c_points = line.c_points @@ -1373,8 +1365,7 @@ def _centroid(self, side, idonly=False): v_id = v_id or None if idonly: return v_id - else: - return Centroid(v_id=v_id, c_mapinfo=self.c_mapinfo) + return Centroid(v_id=v_id, c_mapinfo=self.c_mapinfo) def left_centroid(self, idonly=False): """Return left centroid @@ -1869,7 +1860,7 @@ def c_read_next_line(c_mapinfo, c_points, c_cats): v_id = v_id if v_id != 0 else None ftype = libvect.Vect_read_next_line(c_mapinfo, c_points, c_cats) if ftype == -2: - raise StopIteration() + raise StopIteration if ftype == -1: raise return ftype, v_id, c_points, c_cats @@ -1914,8 +1905,7 @@ def c_read_line(feature_id, c_mapinfo, c_points, c_cats): if feature_id > 0: ftype = libvect.Vect_read_line(c_mapinfo, c_points, c_cats, feature_id) return feature_id, ftype, c_points, c_cats - else: - raise ValueError("The index must be >0, %r given." % feature_id) + raise ValueError("The index must be >0, %r given." % feature_id) def read_line( diff --git a/python/grass/pygrass/vector/table.py b/python/grass/pygrass/vector/table.py index 4b7e99c0a83..b83f751a0dd 100644 --- a/python/grass/pygrass/vector/table.py +++ b/python/grass/pygrass/vector/table.py @@ -65,14 +65,13 @@ def get_path(path, vect_name=None): """ if "$" not in path: return path - else: - mapset = Mapset() - path = path.replace("$GISDBASE", mapset.gisdbase) - path = path.replace("$LOCATION_NAME", mapset.location) - path = path.replace("$MAPSET", mapset.name) - if vect_name is not None: - path = path.replace("$MAP", vect_name) - return path + mapset = Mapset() + path = path.replace("$GISDBASE", mapset.gisdbase) + path = path.replace("$LOCATION_NAME", mapset.location) + path = path.replace("$MAPSET", mapset.name) + if vect_name is not None: + path = path.replace("$MAP", vect_name) + return path class Filters: @@ -135,8 +134,7 @@ def limit(self, number): """ if not isinstance(number, int): raise ValueError("Must be an integer.") - else: - self._limit = "LIMIT {number}".format(number=number) + self._limit = "LIMIT {number}".format(number=number) return self def group_by(self, *groupby): @@ -326,8 +324,7 @@ def sql_descr(self, remove=None): return ", ".join( ["%s %s" % (key, val) for key, val in self.items() if key != remove] ) - else: - return ", ".join(["%s %s" % (key, val) for key, val in self.items()]) + return ", ".join(["%s %s" % (key, val) for key, val in self.items()]) def types(self): """Return a list with the column types. @@ -372,8 +369,7 @@ def names(self, remove=None, unicod=True): nams = list(self.odict.keys()) if unicod: return nams - else: - return [str(name) for name in nams] + return [str(name) for name in nams] def items(self): """Return a list of tuple with column name and column type. @@ -791,10 +787,7 @@ def __eq__(self, link): False """ attrs = ["layer", "name", "table_name", "key", "driver"] - for attr in attrs: - if getattr(self, attr) != getattr(link, attr): - return False - return True + return all(getattr(self, attr) == getattr(link, attr) for attr in attrs) def __ne__(self, other): return not self == other @@ -850,7 +843,7 @@ def connection(self): if not os.path.exists(dbdirpath): os.mkdir(dbdirpath) return sqlite3.connect(dbpath) - elif driver == "pg": + if driver == "pg": try: import psycopg2 @@ -943,11 +936,10 @@ def __iter__(self): def __getitem__(self, item): if isinstance(item, int): return self.by_index(item) - else: - return self.by_name(item) + return self.by_name(item) def __repr__(self): - return "DBlinks(%r)" % [link for link in self.__iter__()] + return "DBlinks(%r)" % list(self.__iter__()) def by_index(self, indx): """Return a Link object by index @@ -1268,10 +1260,7 @@ def create(self, cols, name=None, overwrite=False, cursor=None): """ cur = cursor or self.conn.cursor() coldef = ",\n".join(["%s %s" % col for col in cols]) - if name: - newname = name - else: - newname = self.name + newname = name or self.name try: cur.execute(sql.CREATE_TAB.format(tname=newname, coldef=coldef)) self.conn.commit() diff --git a/python/grass/pygrass/vector/testsuite/test_filters.py b/python/grass/pygrass/vector/testsuite/test_filters.py index 9252b134c02..9adba4cdefc 100644 --- a/python/grass/pygrass/vector/testsuite/test_filters.py +++ b/python/grass/pygrass/vector/testsuite/test_filters.py @@ -6,7 +6,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test - from grass.pygrass.vector.table import Filters diff --git a/python/grass/pygrass/vector/testsuite/test_geometry.py b/python/grass/pygrass/vector/testsuite/test_geometry.py index b2a7a1e37df..6957a473165 100644 --- a/python/grass/pygrass/vector/testsuite/test_geometry.py +++ b/python/grass/pygrass/vector/testsuite/test_geometry.py @@ -6,18 +6,15 @@ import sys import unittest + import numpy as np +import grass.lib.vector as libvect from grass.gunittest.case import TestCase from grass.gunittest.main import test - -import grass.lib.vector as libvect -from grass.script.core import run_command - -from grass.pygrass.vector import Vector, VectorTopo -from grass.pygrass.vector.geometry import Point, Line, Node -from grass.pygrass.vector.geometry import Area, Boundary, Centroid +from grass.pygrass.vector import VectorTopo from grass.pygrass.vector.basic import Bbox +from grass.pygrass.vector.geometry import Area, Line, Node, Point class PointTestCase(TestCase): diff --git a/python/grass/pygrass/vector/testsuite/test_geometry_attrs.py b/python/grass/pygrass/vector/testsuite/test_geometry_attrs.py index 356a55ec4d7..cba638b1901 100644 --- a/python/grass/pygrass/vector/testsuite/test_geometry_attrs.py +++ b/python/grass/pygrass/vector/testsuite/test_geometry_attrs.py @@ -4,16 +4,8 @@ @author: pietro """ -import sys -import unittest -import numpy as np - from grass.gunittest.case import TestCase from grass.gunittest.main import test - -import grass.lib.vector as libvect -from grass.script.core import run_command - from grass.pygrass.vector import VectorTopo diff --git a/python/grass/pygrass/vector/testsuite/test_pygrass_vector_doctests.py b/python/grass/pygrass/vector/testsuite/test_pygrass_vector_doctests.py index b3d26220ec1..2cf0d0ba0c5 100644 --- a/python/grass/pygrass/vector/testsuite/test_pygrass_vector_doctests.py +++ b/python/grass/pygrass/vector/testsuite/test_pygrass_vector_doctests.py @@ -7,10 +7,7 @@ import grass.gunittest.case import grass.gunittest.main import grass.gunittest.utils - import grass.pygrass.vector as gvector -import grass.pygrass.utils as gutils - # doctest does not allow changing the base classes of test case, skip test case # and test suite, so we need to create a new type which inherits from our class diff --git a/python/grass/pygrass/vector/testsuite/test_table.py b/python/grass/pygrass/vector/testsuite/test_table.py index 1acb410a10f..c77233400b1 100644 --- a/python/grass/pygrass/vector/testsuite/test_table.py +++ b/python/grass/pygrass/vector/testsuite/test_table.py @@ -7,16 +7,15 @@ import os import sqlite3 import tempfile as tmp -from string import ascii_letters, digits from random import choice +from string import ascii_letters, digits + import numpy as np from grass.gunittest.case import TestCase from grass.gunittest.main import test - from grass.pygrass.vector.table import Table, get_path - # dictionary that generate random data RNG = np.random.default_rng() COL2VALS = { @@ -65,7 +64,7 @@ def get_table_random_values(nrows, columns): raise TypeError("Unknown column type %s for: %s" % (ctype, cname)) vals.append(COL2VALS[ctype](nrows)) dtype.append((cname, vals[-1].dtype.str)) - return np.array([v for v in zip(*vals)], dtype=dtype) + return np.array(list(zip(*vals)), dtype=dtype) class DBconnection: diff --git a/python/grass/pygrass/vector/testsuite/test_vector.py b/python/grass/pygrass/vector/testsuite/test_vector.py index 5d16333c31f..b4eebb2ab1e 100644 --- a/python/grass/pygrass/vector/testsuite/test_vector.py +++ b/python/grass/pygrass/vector/testsuite/test_vector.py @@ -6,8 +6,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test - -from grass.script.core import run_command from grass.pygrass.vector import VectorTopo diff --git a/python/grass/pygrass/vector/testsuite/test_vector3d.py b/python/grass/pygrass/vector/testsuite/test_vector3d.py index 796f85ca529..84e688d22e8 100644 --- a/python/grass/pygrass/vector/testsuite/test_vector3d.py +++ b/python/grass/pygrass/vector/testsuite/test_vector3d.py @@ -8,13 +8,9 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test - -from grass.script.core import run_command - +from grass.pygrass.gis.region import Region from grass.pygrass.vector import VectorTopo from grass.pygrass.vector.geometry import Point -from grass.pygrass.gis.region import Region -from grass.pygrass.utils import get_mapset_vector def generate_coordinates(number, bbox=None, with_z=False): diff --git a/python/grass/script/__init__.py b/python/grass/script/__init__.py index 8589e8a1521..ea82c2fe451 100644 --- a/python/grass/script/__init__.py +++ b/python/grass/script/__init__.py @@ -7,4 +7,4 @@ from .raster3d import * from .vector import * from .utils import * -from . import setup +from . import setup # noqa: F401 diff --git a/python/grass/script/core.py b/python/grass/script/core.py index a86738926f0..f51814a5900 100644 --- a/python/grass/script/core.py +++ b/python/grass/script/core.py @@ -18,6 +18,8 @@ .. sectionauthor:: Michael Barton """ +from __future__ import annotations + import os import sys import atexit @@ -127,8 +129,7 @@ def _make_unicode(val, enc): if enc == "default": return decode(val) - else: - return decode(val, encoding=enc) + return decode(val, encoding=enc) def get_commands(*, env=None): @@ -335,10 +336,7 @@ def get_module_and_code(args, kwargs): args = make_command(*args, **kwargs) # Since we are in error handler, let's be extra cautious # about an empty command. - if args: - module = args[0] - else: - module = None + module = args[0] if args else None code = " ".join(args) return module, code @@ -349,7 +347,7 @@ def get_module_and_code(args, kwargs): return result if handler.lower() == "ignore": return result - elif handler.lower() == "fatal": + if handler.lower() == "fatal": module, code = get_module_and_code(args, kwargs) fatal( _( @@ -859,9 +857,9 @@ def get_capture_stderr(): # interface to g.parser -def _parse_opts(lines): - options = {} - flags = {} +def _parse_opts(lines: list) -> tuple[dict[str, str], dict[str, bool]]: + options: dict[str, str] = {} + flags: dict[str, bool] = {} for line in lines: if not line: break @@ -891,7 +889,7 @@ def _parse_opts(lines): return (options, flags) -def parser(): +def parser() -> tuple[dict[str, str], dict[str, bool]]: """Interface to g.parser, intended to be run from the top-level, e.g.: :: @@ -1066,7 +1064,7 @@ def _text_to_key_value_dict( {'a': ['Hello'], 'c': [1, 2, 3, 4, 5], 'b': [1.0], 'd': ['hello', 8, 0.1]} """ - text = open(filename, "r").readlines() + text = open(filename).readlines() kvdict = KeyValue() for line in text: @@ -1276,7 +1274,7 @@ def region_env(region3d=False, flags=None, env=None, **kwargs): windfile = os.path.join( gis_env["GISDBASE"], gis_env["LOCATION_NAME"], gis_env["MAPSET"], "WIND" ) - with open(windfile, "r") as fd: + with open(windfile) as fd: grass_region = "" for line in fd: key, value = (x.strip() for x in line.split(":", 1)) @@ -1650,8 +1648,7 @@ def verbosity(): vbstr = os.getenv("GRASS_VERBOSE") if vbstr: return int(vbstr) - else: - return 2 + return 2 # Various utilities, not specific to GRASS @@ -1701,10 +1698,7 @@ def mapsets(search_path=False, env=None): :return: list of mapsets """ - if search_path: - flags = "p" - else: - flags = "l" + flags = "p" if search_path else "l" mapsets = read_command("g.mapsets", flags=flags, sep="newline", quiet=True, env=env) if not mapsets: fatal(_("Unable to list mapsets")) @@ -1894,7 +1888,7 @@ def _create_location_xy(database, location): :param database: GRASS database where to create new location :param location: location name """ - cur_dir = os.getcwd() + cur_dir = Path.cwd() try: os.chdir(database) os.mkdir(location) @@ -2035,10 +2029,7 @@ def create_environment(gisdbase, location, mapset, env=None): f.write("GISDBASE: {g}\n".format(g=gisdbase)) f.write("LOCATION_NAME: {l}\n".format(l=location)) f.write("GUI: text\n") - if env: - env = env.copy() - else: - env = os.environ.copy() + env = env.copy() if env else os.environ.copy() env["GISRC"] = f.name # remove mapset-specific env vars env = sanitize_mapset_environment(env) diff --git a/python/grass/script/db.py b/python/grass/script/db.py index 2725ff06ebe..60813379501 100644 --- a/python/grass/script/db.py +++ b/python/grass/script/db.py @@ -229,8 +229,7 @@ def db_table_in_vector(table, mapset=".", env=None): break if len(used) > 0: return used - else: - return None + return None def db_begin_transaction(driver): diff --git a/python/grass/script/raster.py b/python/grass/script/raster.py index f9937902dab..d82780d7c5c 100644 --- a/python/grass/script/raster.py +++ b/python/grass/script/raster.py @@ -65,8 +65,8 @@ def raster_history(map, overwrite=False, env=None): _( "Unable to write history for <%(map)s>. " "Raster map <%(map)s> not found in current mapset." - % {"map": map, "map": map} ) + % {"map": map} ) return False @@ -88,8 +88,7 @@ def raster_info(map, env=None): def float_or_null(s): if s == "NULL": return None - else: - return float(s) + return float(s) s = read_command("r.info", flags="gre", map=map, env=env) kv = parse_key_val(s) @@ -219,10 +218,7 @@ def raster_what(map, coord, env=None, localized=False): query :param env: """ - if isinstance(map, (bytes, str)): - map_list = [map] - else: - map_list = map + map_list = [map] if isinstance(map, (bytes, str)) else map coord_list = [] if isinstance(coord, tuple): diff --git a/python/grass/script/raster3d.py b/python/grass/script/raster3d.py index 3b89b4fb707..e3db5398158 100644 --- a/python/grass/script/raster3d.py +++ b/python/grass/script/raster3d.py @@ -47,8 +47,7 @@ def raster3d_info(map, env=None): def float_or_null(s): if s == "NULL": return None - else: - return float(s) + return float(s) s = read_command("r3.info", flags="rg", map=map, env=env) kv = parse_key_val(s) diff --git a/python/grass/script/task.py b/python/grass/script/task.py index 35234ba65e6..758372938e3 100644 --- a/python/grass/script/task.py +++ b/python/grass/script/task.py @@ -90,8 +90,7 @@ def get_name(self): name, ext = os.path.splitext(self.name) if ext in {".py", ".sh"}: return name - else: - return self.name + return self.name return self.name @@ -103,10 +102,8 @@ def get_description(self, full=True): if self.label: if full: return self.label + " " + self.description - else: - return self.label - else: - return self.description + return self.label + return self.description def get_keywords(self): """Get module's keywords""" @@ -156,8 +153,7 @@ def get_param(self, value, element="name", raiseError=True): _("Parameter element '%(element)s' not found: '%(value)s'") % {"element": element, "value": value} ) - else: - return None + return None def get_flag(self, aFlag): """Find and return a flag by name @@ -247,11 +243,7 @@ def get_options(self): def has_required(self): """Check if command has at least one required parameter""" - for p in self.params: - if p.get("required", False): - return True - - return False + return any(p.get("required", False) for p in self.params) def set_param(self, aParam, aValue, element="value"): """Set param value/values.""" @@ -352,14 +344,8 @@ def _process_params(self): for ki in node_key_desc.findall("item"): key_desc.append(ki.text) - if p.get("multiple", "no") == "yes": - multiple = True - else: - multiple = False - if p.get("required", "no") == "yes": - required = True - else: - required = False + multiple = p.get("multiple", "no") == "yes" + required = p.get("required", "no") == "yes" if ( self.task.blackList["enabled"] diff --git a/python/grass/script/tests/grass_script_setup_test.py b/python/grass/script/tests/grass_script_setup_test.py index 62a0ca37b74..36dfbb77dbb 100644 --- a/python/grass/script/tests/grass_script_setup_test.py +++ b/python/grass/script/tests/grass_script_setup_test.py @@ -51,7 +51,7 @@ def test_init_session_finish(tmp_path): gs.run_command("g.region", flags="p", env=session.env) session_file = session.env["GISRC"] session.finish() - with pytest.raises(ValueError): + with pytest.raises(ValueError): # noqa: PT011 session.finish() assert not session.active assert not os.path.exists(session_file) diff --git a/python/grass/script/tests/test_script_task.py b/python/grass/script/tests/test_script_task.py index 6799885761e..cae8735827e 100644 --- a/python/grass/script/tests/test_script_task.py +++ b/python/grass/script/tests/test_script_task.py @@ -1,11 +1,11 @@ -from grass.script.task import grassTask as gtask +from grass.script.task import grassTask def test_mapcalc_simple_e_name(): - gt = gtask("r.mapcalc.simple") + gt = grassTask("r.mapcalc.simple") assert gt.get_param("e")["name"] == "e" def test_mapcalc_simple_expession_name(): - gt = gtask("r.mapcalc.simple") + gt = grassTask("r.mapcalc.simple") assert gt.get_param("expression")["name"] == "expression" diff --git a/python/grass/script/testsuite/data/script_using_temporary_region.py b/python/grass/script/testsuite/data/script_using_temporary_region.py index 5bb5a4cda26..839bf3d0a72 100755 --- a/python/grass/script/testsuite/data/script_using_temporary_region.py +++ b/python/grass/script/testsuite/data/script_using_temporary_region.py @@ -65,15 +65,9 @@ def main(): argument = sys.argv[1] sizes = argument.split(",", 1) size = sizes[0] - if len(sizes) > 1: - remaining = sizes[1] - else: - remaining = None + remaining = sizes[1] if len(sizes) > 1 else None nesting = int(sys.argv[2]) - if len(sys.argv) == 4: - map_name = sys.argv[3] - else: - map_name = None + map_name = sys.argv[3] if len(sys.argv) == 4 else None call_use_temp_region( script=this_file, size=size, diff --git a/python/grass/script/testsuite/test_start_command_functions.py b/python/grass/script/testsuite/test_start_command_functions.py index 414a68cd270..368669263a8 100644 --- a/python/grass/script/testsuite/test_start_command_functions.py +++ b/python/grass/script/testsuite/test_start_command_functions.py @@ -4,6 +4,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows from grass.script.core import start_command, PIPE, run_command, write_command from grass.script.core import read_command, find_program @@ -85,6 +86,7 @@ def setUpClass(cls): def tearDownClass(cls): cls.runModule("g.remove", type="raster", name=cls.raster, flags="f") + @xfail_windows def test_write_labels_unicode(self): """This tests if Python module works""" find_program("ls", "--version") @@ -99,6 +101,7 @@ def test_write_labels_unicode(self): self.assertEqual(res, "1:kůň\n2:kráva\n3:ovečka\n4:býk") self.assertIsInstance(res, str) + @xfail_windows def test_write_labels_bytes(self): """This tests if Python module works""" write_command( diff --git a/python/grass/script/testsuite/test_utils.py b/python/grass/script/testsuite/test_utils.py index db12041d66d..67d2c59dd69 100644 --- a/python/grass/script/testsuite/test_utils.py +++ b/python/grass/script/testsuite/test_utils.py @@ -2,6 +2,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows from grass.script import utils @@ -39,6 +40,7 @@ def test_bytes(self): def test_unicode(self): self.assertEqual(b"text", utils.encode("text")) + @xfail_windows def test_bytes_garbage_in_out(self): """If the input is bytes we should not touch it for encoding""" self.assertEqual( diff --git a/python/grass/script/utils.py b/python/grass/script/utils.py index 13d049412a4..0a32a9e7b4e 100644 --- a/python/grass/script/utils.py +++ b/python/grass/script/utils.py @@ -28,6 +28,8 @@ import random import string +from pathlib import Path + def float_or_dms(s): """Convert DMS to float. @@ -67,13 +69,13 @@ def separator(sep): """ if sep == "pipe": return "|" - elif sep == "comma": + if sep == "comma": return "," - elif sep == "space": + if sep == "space": return " " - elif sep in {"tab", "\\t"}: + if sep in {"tab", "\\t"}: return "\t" - elif sep in {"newline", "\\n"}: + if sep in {"newline", "\\n"}: return "\n" return sep @@ -89,8 +91,8 @@ def diff_files(filename_a, filename_b): import difflib differ = difflib.Differ() - fh_a = open(filename_a, "r") - fh_b = open(filename_b, "r") + fh_a = open(filename_a) + fh_b = open(filename_b) return list(differ.compare(fh_a.readlines(), fh_b.readlines())) @@ -188,10 +190,7 @@ def decode(bytes_, encoding=None): if isinstance(bytes_, str): return bytes_ if isinstance(bytes_, bytes): - if encoding is None: - enc = _get_encoding() - else: - enc = encoding + enc = _get_encoding() if encoding is None else encoding return bytes_.decode(enc) # only text should be used raise TypeError("can only accept types str and bytes") @@ -219,10 +218,7 @@ def encode(string, encoding=None): if isinstance(string, bytes): return string if isinstance(string, str): - if encoding is None: - enc = _get_encoding() - else: - enc = encoding + enc = _get_encoding() if encoding is None else encoding return string.encode(enc) # if something else than text raise TypeError("can only accept types str and bytes") @@ -274,10 +270,7 @@ def parse_key_val(s, sep="=", dflt=None, val_type=None, vsep=None): for line in lines: kv = line.split(sep, 1) k = decode(kv[0].strip()) - if len(kv) > 1: - v = decode(kv[1].strip()) - else: - v = dflt + v = decode(kv[1].strip()) if len(kv) > 1 else dflt if val_type: result[k] = val_type(v) @@ -328,7 +321,7 @@ def split(s): # source: -# http://stackoverflow.com/questions/4836710/ +# https://stackoverflow.com/questions/4836710/ # does-python-have-a-built-in-function-for-string-natural-sort/4836734#4836734 def natural_sort(items): """Returns sorted list using natural sort @@ -351,10 +344,7 @@ def convert(text): return int(text) if text.isdigit() else text.lower() def alphanum_key(actual_key): - if key: - sort_key = key(actual_key) - else: - sort_key = actual_key + sort_key = key(actual_key) if key else actual_key return [convert(c) for c in re.split("([0-9]+)", sort_key)] items.sort(key=alphanum_key) @@ -371,10 +361,9 @@ def get_lib_path(modname, libname=None): getenv("GRASS_ADDON_BASE") and libname and isdir(join(getenv("GRASS_ADDON_BASE"), "etc", modname, libname)) - ): - path = join(getenv("GRASS_ADDON_BASE"), "etc", modname) - elif getenv("GRASS_ADDON_BASE") and isdir( - join(getenv("GRASS_ADDON_BASE"), "etc", modname) + ) or ( + getenv("GRASS_ADDON_BASE") + and isdir(join(getenv("GRASS_ADDON_BASE"), "etc", modname)) ): path = join(getenv("GRASS_ADDON_BASE"), "etc", modname) elif getenv("GRASS_ADDON_BASE") and isdir( @@ -383,7 +372,7 @@ def get_lib_path(modname, libname=None): path = join(os.getenv("GRASS_ADDON_BASE"), modname, modname) else: # used by g.extension compilation process - cwd = os.getcwd() + cwd = str(Path.cwd()) idx = cwd.find(modname) if idx < 0: return None @@ -463,10 +452,10 @@ def set_path(modulename, dirname=None, path="."): import sys # TODO: why dirname is checked first - the logic should be revised - pathlib = None + _pathlib = None if dirname: - pathlib = os.path.join(path, dirname) - if pathlib and os.path.exists(pathlib): + _pathlib = os.path.join(path, dirname) + if _pathlib and os.path.exists(_pathlib): # we are running the script from the script directory, therefore # we add the path to sys.path to reach the directory (dirname) sys.path.append(os.path.abspath(path)) @@ -477,7 +466,7 @@ def set_path(modulename, dirname=None, path="."): pathname = os.path.join(modulename, dirname) if dirname else modulename raise ImportError( "Not able to find the path '%s' directory " - "(current dir '%s')." % (pathname, os.getcwd()) + "(current dir '%s')." % (pathname, Path.cwd()) ) sys.path.insert(0, path) diff --git a/python/grass/script/vector.py b/python/grass/script/vector.py index ca3caf18471..2d484f7d590 100644 --- a/python/grass/script/vector.py +++ b/python/grass/script/vector.py @@ -129,10 +129,7 @@ def vector_columns(map, layer=None, getDict=True, env=None, **kwargs): s = read_command( "v.info", flags="c", map=map, layer=layer, quiet=True, env=env, **kwargs ) - if getDict: - result = {} - else: - result = [] + result = {} if getDict else [] i = 0 for line in s.splitlines(): ctype, cname = line.split("|") @@ -377,10 +374,7 @@ def vector_what( if "LC_ALL" in env: env["LC_ALL"] = "C" - if isinstance(map, (bytes, str)): - map_list = [map] - else: - map_list = map + map_list = [map] if isinstance(map, (bytes, str)) else map if layer: if isinstance(layer, (tuple, list)): diff --git a/python/grass/semantic_label/__init__.py b/python/grass/semantic_label/__init__.py index 9f0b9b6caed..58bfe11a418 100644 --- a/python/grass/semantic_label/__init__.py +++ b/python/grass/semantic_label/__init__.py @@ -1 +1,3 @@ from .reader import SemanticLabelReader, SemanticLabelReaderError + +__all__ = ["SemanticLabelReader", "SemanticLabelReaderError"] diff --git a/python/grass/temporal/abstract_dataset.py b/python/grass/temporal/abstract_dataset.py index cfe3c83a841..6df2fa1f81e 100644 --- a/python/grass/temporal/abstract_dataset.py +++ b/python/grass/temporal/abstract_dataset.py @@ -10,6 +10,8 @@ :authors: Soeren Gebbert """ +from __future__ import annotations + from abc import ABCMeta, abstractmethod from .core import get_current_mapset, get_tgis_message_interface, init_dbif @@ -76,7 +78,7 @@ def get_number_of_relations(self): """ if self.is_temporal_topology_build() and not self.is_spatial_topology_build(): return self.get_number_of_temporal_relations() - elif self.is_spatial_topology_build() and not self.is_temporal_topology_build(): + if self.is_spatial_topology_build() and not self.is_temporal_topology_build(): self.get_number_of_spatial_relations() else: return ( @@ -504,25 +506,23 @@ def update_all(self, dbif=None, execute=True, ident=None): dbif.close() return statement - def is_time_absolute(self): + def is_time_absolute(self) -> bool | None: """Return True in case the temporal type is absolute :return: True if temporal type is absolute, False otherwise """ if "temporal_type" in self.base.D: return self.base.get_ttype() == "absolute" - else: - return None + return None - def is_time_relative(self): + def is_time_relative(self) -> bool | None: """Return True in case the temporal type is relative :return: True if temporal type is relative, False otherwise """ if "temporal_type" in self.base.D: return self.base.get_ttype() == "relative" - else: - return None + return None def get_temporal_extent(self): """Return the temporal extent of the correct internal type""" diff --git a/python/grass/temporal/abstract_map_dataset.py b/python/grass/temporal/abstract_map_dataset.py index f58bcb82d66..f6bec2bfef3 100644 --- a/python/grass/temporal/abstract_map_dataset.py +++ b/python/grass/temporal/abstract_map_dataset.py @@ -232,8 +232,7 @@ def build_id_from_search_path(name, element): if layer is not None: return f"{name}:{layer}@{mapset}" - else: - return f"{name}@{mapset}" + return f"{name}@{mapset}" @staticmethod def build_id(name, mapset, layer=None): @@ -258,8 +257,7 @@ def build_id(name, mapset, layer=None): if layer is not None: return f"{name}:{layer}@{mapset}" - else: - return f"{name}@{mapset}" + return f"{name}@{mapset}" def get_layer(self): """Return the layer of the map @@ -443,15 +441,11 @@ def set_absolute_time(self, start_time, end_time=None): } ) return False - else: - self.msgr.error( - _( - "Start time must be of type datetime for " - "%(type)s map <%(id)s>" - ) - % {"type": self.get_type(), "id": self.get_map_id()} - ) - return False + self.msgr.error( + _("Start time must be of type datetime for %(type)s map <%(id)s>") + % {"type": self.get_type(), "id": self.get_map_id()} + ) + return False if end_time and not isinstance(end_time, datetime): if self.get_layer(): @@ -467,12 +461,11 @@ def set_absolute_time(self, start_time, end_time=None): } ) return False - else: - self.msgr.error( - _("End time must be of type datetime for %(type)s map <%(id)s>") - % {"type": self.get_type(), "id": self.get_map_id()} - ) - return False + self.msgr.error( + _("End time must be of type datetime for %(type)s map <%(id)s>") + % {"type": self.get_type(), "id": self.get_map_id()} + ) + return False if start_time is not None and end_time is not None: if start_time > end_time: @@ -490,17 +483,16 @@ def set_absolute_time(self, start_time, end_time=None): } ) return False - else: - self.msgr.error( - _( - "End time must be greater than start " - "time for %(type)s map <%(id)s>" - ) - % {"type": self.get_type(), "id": self.get_map_id()} + self.msgr.error( + _( + "End time must be greater than start " + "time for %(type)s map <%(id)s>" ) - return False + % {"type": self.get_type(), "id": self.get_map_id()} + ) + return False # Do not create an interval in case start and end time are equal - elif start_time == end_time: + if start_time == end_time: end_time = None self.base.set_ttype("absolute") @@ -618,7 +610,7 @@ def set_relative_time(self, start_time, end_time, unit): ) return False # Do not create an interval in case start and end time are equal - elif start_time == end_time: + if start_time == end_time: end_time = None self.base.set_ttype("relative") @@ -828,10 +820,7 @@ def temporal_buffer(self, increment, update=False, dbif=None): else: start, end, unit = self.get_relative_time() new_start = start - increment - if end is None: - new_end = start + increment - else: - new_end = end + increment + new_end = start + increment if end is None else end + increment if update: self.update_relative_time(new_start, new_end, unit, dbif=dbif) diff --git a/python/grass/temporal/abstract_space_time_dataset.py b/python/grass/temporal/abstract_space_time_dataset.py index 515502ff3f1..8140a2da261 100644 --- a/python/grass/temporal/abstract_space_time_dataset.py +++ b/python/grass/temporal/abstract_space_time_dataset.py @@ -16,6 +16,7 @@ class that is the base class for all space time datasets. import uuid from abc import ABCMeta, abstractmethod from datetime import datetime +from pathlib import Path from .abstract_dataset import AbstractDataset, AbstractDatasetComparisonKeyStartTime from .core import ( @@ -395,9 +396,7 @@ def insert(self, dbif=None, execute=True): # %s;"%(stds_register_table + "_index", stds_register_table)) # Read the SQL template - sql = open( - os.path.join(sql_path, "stds_map_register_table_template.sql"), "r" - ).read() + sql = Path(sql_path, "stds_map_register_table_template.sql").read_text() # Create a raster, raster3d or vector tables sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table) @@ -780,10 +779,7 @@ def sample_by_dataset(self, stds, method=None, spatial=False, dbif=None): # print(relations) tb = SpatioTemporalTopologyBuilder() - if spatial: - spatial = "2D" - else: - spatial = None + spatial = "2D" if spatial else None mapsA = self.get_registered_maps_as_objects(dbif=dbif) mapsB = stds.get_registered_maps_as_objects_with_gaps(dbif=dbif) @@ -1430,10 +1426,7 @@ def get_registered_maps_as_objects_with_gaps( start1, end1 = maps[i].get_temporal_extent_as_tuple() start2, end2 = maps[i + 1].get_temporal_extent_as_tuple() end = start2 - if end1 is not None: - start = end1 - else: - start = start1 + start = end1 if end1 is not None else start1 map = self.get_new_map_instance(None) @@ -1627,8 +1620,7 @@ def leading_zero(value): try: if value.startswith("0"): return value.lstrip("0") - else: - return "{0:02d}".format(int(value)) + return "{0:02d}".format(int(value)) except ValueError: return None @@ -2025,7 +2017,7 @@ def shift(self, gran, dbif=None): ) if not check_granularity_string(gran, self.get_temporal_type()): - self.msgr.error(_("Wrong granularity format: %s" % (gran))) + self.msgr.error(_("Wrong granularity format: %s") % (gran)) return False dbif, connection_state_changed = init_dbif(dbif) @@ -2818,13 +2810,10 @@ def update_from_registered_maps(self, dbif=None): ) if old_sqlite_version: template_suffix = "_old" - sql = open( - os.path.join( - sql_path, - f"update_stds_spatial_temporal_extent_template{template_suffix}.sql", - ), - "r", - ).read() + sql = Path( + sql_path, + f"update_stds_spatial_temporal_extent_template{template_suffix}.sql", + ).read_text() sql = sql.replace("GRASS_MAP", self.get_new_map_instance(None).get_type()) sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table) sql = sql.replace("SPACETIME_ID", self.base.get_id()) @@ -2834,13 +2823,10 @@ def update_from_registered_maps(self, dbif=None): sql_script += "\n" # Update type specific metadata - sql = open( - os.path.join( - sql_path, - f"update_{self.get_type()}_metadata_template{template_suffix}.sql", - ), - "r", - ).read() + sql = Path( + sql_path, + f"update_{self.get_type()}_metadata_template{template_suffix}.sql", + ).read_text() # Comment out update of semantic labels for DB version < 3 if get_tgis_db_version_from_metadata() < 3: @@ -2853,10 +2839,9 @@ def update_from_registered_maps(self, dbif=None): "-- count(distinct semantic_label)", ) elif old_sqlite_version and self.get_type() == "strds": - semantic_label_sql = open( - os.path.join(sql_path, "update_strds_metadata_template_v3.sql"), - "r", - ).read() + semantic_label_sql = Path( + sql_path, "update_strds_metadata_template_v3.sql" + ).read_text() sql = sql + "\n" + semantic_label_sql sql = sql.replace("SPACETIME_REGISTER_TABLE", stds_register_table) diff --git a/python/grass/temporal/aggregation.py b/python/grass/temporal/aggregation.py index 1ea60eaeea1..354600855e0 100644 --- a/python/grass/temporal/aggregation.py +++ b/python/grass/temporal/aggregation.py @@ -154,16 +154,14 @@ def aggregate_raster_maps( _( "Raster map <%(name)s> is already in temporal " "database, use overwrite flag to overwrite" - % ({"name": new_map.get_name()}) ) + % ({"name": new_map.get_name()}) ) return msgr.verbose( - _( - "Computing aggregation of maps between %(st)s - %(end)s" - % {"st": str(start), "end": str(end)} - ) + _("Computing aggregation of maps between %(st)s - %(end)s") + % {"st": str(start), "end": str(end)} ) # Create the r.series input file @@ -356,8 +354,9 @@ def aggregate_by_topology( _( "Unable to perform aggregation. Output raster " "map <%(name)s> exists and overwrite flag was " - "not set" % ({"name": output_name}) + "not set" ) + % ({"name": output_name}) ) output_list.append(map_layer) @@ -380,8 +379,8 @@ def aggregate_by_topology( "reached (%i). The module r.series will " "be run with flag z, to avoid open " "files limit exceeding." - % (int(file_limit), len(aggregation_list)) ) + % (int(file_limit), len(aggregation_list)) ) mod(flags="z") process_queue.put(mod) diff --git a/python/grass/temporal/base.py b/python/grass/temporal/base.py index 9296a22dfa1..ebb4b715e29 100644 --- a/python/grass/temporal/base.py +++ b/python/grass/temporal/base.py @@ -466,10 +466,9 @@ def get_update_statement(self, ident=None): return self.serialize( "UPDATE", self.get_table_name(), "WHERE id = '" + str(ident) + "'" ) - else: - return self.serialize( - "UPDATE", self.get_table_name(), "WHERE id = '" + str(self.ident) + "'" - ) + return self.serialize( + "UPDATE", self.get_table_name(), "WHERE id = '" + str(self.ident) + "'" + ) def get_update_statement_mogrified(self, dbif=None, ident=None): """Return the update statement as mogrified string @@ -529,12 +528,11 @@ def get_update_all_statement(self, ident=None): return self.serialize( "UPDATE ALL", self.get_table_name(), "WHERE id = '" + str(ident) + "'" ) - else: - return self.serialize( - "UPDATE ALL", - self.get_table_name(), - "WHERE id = '" + str(self.ident) + "'", - ) + return self.serialize( + "UPDATE ALL", + self.get_table_name(), + "WHERE id = '" + str(self.ident) + "'", + ) def get_update_all_statement_mogrified(self, dbif=None, ident=None): """Return the update all statement as mogrified string @@ -749,8 +747,7 @@ def get_id(self): """ if "id" in self.D: return self.D["id"] - else: - return None + return None def get_map_id(self): """Convenient method to get the unique map identifier @@ -763,10 +760,8 @@ def get_map_id(self): if self.id.find(":") >= 0: # Remove the layer identifier from the id return self.id.split("@")[0].split(":")[0] + "@" + self.id.split("@")[1] - else: - return self.id - else: - return None + return self.id + return None def get_layer(self): """Convenient method to get the layer of the map (part of primary key) @@ -777,48 +772,42 @@ def get_layer(self): """ if "layer" in self.D: return self.D["layer"] - else: - return None + return None def get_name(self): """Get the name of the dataset :return: None if not found""" if "name" in self.D: return self.D["name"] - else: - return None + return None def get_mapset(self): """Get the name of mapset of this dataset :return: None if not found""" if "mapset" in self.D: return self.D["mapset"] - else: - return None + return None def get_creator(self): """Get the creator of the dataset :return: None if not found""" if "creator" in self.D: return self.D["creator"] - else: - return None + return None def get_ctime(self): """Get the creation time of the dataset, datatype is datetime :return: None if not found""" if "creation_time" in self.D: return self.D["creation_time"] - else: - return None + return None def get_ttype(self): """Get the temporal type of the map :return: None if not found""" if "temporal_type" in self.D: return self.D["temporal_type"] - else: - return None + return None # Properties of this class id = property(fget=get_id, fset=set_id) @@ -1027,8 +1016,7 @@ def get_semantic_type(self): """ if "semantic_type" in self.D: return self.D["semantic_type"] - else: - return None + return None def get_mtime(self): """Get the modification time of the space time dataset, datatype is @@ -1038,8 +1026,7 @@ def get_mtime(self): """ if "modification_time" in self.D: return self.D["modification_time"] - else: - return None + return None semantic_type = property(fget=get_semantic_type, fset=set_semantic_type) @@ -1201,8 +1188,7 @@ def get_id(self): """ if "id" in self.D: return self.D["id"] - else: - return None + return None def get_registered_stds(self): """Get the comma separated list of space time datasets ids @@ -1212,8 +1198,7 @@ def get_registered_stds(self): """ if "registered_stds" in self.D: return self.D["registered_stds"] - else: - return None + return None # Properties of this class id = property(fget=get_id, fset=set_id) diff --git a/python/grass/temporal/c_libraries_interface.py b/python/grass/temporal/c_libraries_interface.py index 6b67dfb9869..0d24fc0f732 100644 --- a/python/grass/temporal/c_libraries_interface.py +++ b/python/grass/temporal/c_libraries_interface.py @@ -256,11 +256,7 @@ def _get_driver_name(lock, conn, data): :returns: Name of the driver or None if no temporal database present """ mapset = data[1] - if not mapset: - mapset = libgis.G_mapset() - else: - mapset = encode(mapset) - + mapset = libgis.G_mapset() if not mapset else encode(mapset) drstring = libtgis.tgis_get_mapset_driver_name(mapset) conn.send(decode(drstring.data)) @@ -280,10 +276,7 @@ def _get_database_name(lock, conn, data): dbstring = None try: mapset = data[1] - if not mapset: - mapset = libgis.G_mapset() - else: - mapset = encode(mapset) + mapset = libgis.G_mapset() if not mapset else encode(mapset) dbstring = libtgis.tgis_get_mapset_database_name(mapset) dbstring = dbstring.data @@ -815,7 +808,7 @@ def _read_raster3d_info(name, mapset): ) if not g3map: - logging.error(_("Unable to open 3D raster map <%s>" % (name))) + logging.error(_("Unable to open 3D raster map <%s>"), (name)) return None maptype = libraster3d.Rast3d_file_type_map(g3map) @@ -830,7 +823,7 @@ def _read_raster3d_info(name, mapset): max = libgis.DCELL() ret = libraster3d.Rast3d_range_load(g3map) if not ret: - logging.error(_("Unable to load range of 3D raster map <%s>" % (name))) + logging.error(_("Unable to load range of 3D raster map <%s>"), (name)) return None libraster3d.Rast3d_range_min_max(g3map, byref(min), byref(max)) @@ -844,7 +837,7 @@ def _read_raster3d_info(name, mapset): kvp["max"] = float(max.value) if not libraster3d.Rast3d_close(g3map): - logging.error(_("Unable to close 3D raster map <%s>" % (name))) + logging.error(_("Unable to close 3D raster map <%s>"), (name)) return None return kvp @@ -887,10 +880,8 @@ def _read_vector_info(name, mapset): with_topo = False if libvector.Vect_open_old2(byref(Map), name, mapset, "1") < 1: logging.error( - _( - "Unable to open vector map <%s>" - % (libvector.Vect_get_full_name(byref(Map))) - ) + _("Unable to open vector map <%s>"), + (libvector.Vect_get_full_name(byref(Map))), ) return None @@ -1013,13 +1004,12 @@ def _read_raster_history(name, mapset): if ret < 0: logging.warning(_("Unable to read history file")) return None - else: - kvp["creation_time"] = decode( - libraster.Rast_get_history(byref(hist), libraster.HIST_MAPID) - ) - kvp["creator"] = decode( - libraster.Rast_get_history(byref(hist), libraster.HIST_CREATOR) - ) + kvp["creation_time"] = decode( + libraster.Rast_get_history(byref(hist), libraster.HIST_MAPID) + ) + kvp["creator"] = decode( + libraster.Rast_get_history(byref(hist), libraster.HIST_CREATOR) + ) return kvp @@ -1051,13 +1041,12 @@ def _read_raster3d_history(name, mapset): if ret < 0: logging.warning(_("Unable to read history file")) return None - else: - kvp["creation_time"] = decode( - libraster.Rast_get_history(byref(hist), libraster3d.HIST_MAPID) - ) - kvp["creator"] = decode( - libraster.Rast_get_history(byref(hist), libraster3d.HIST_CREATOR) - ) + kvp["creation_time"] = decode( + libraster.Rast_get_history(byref(hist), libraster3d.HIST_MAPID) + ) + kvp["creator"] = decode( + libraster.Rast_get_history(byref(hist), libraster3d.HIST_CREATOR) + ) return kvp @@ -1144,43 +1133,42 @@ def _convert_timestamp_from_grass(ts): # ATTENTION: We ignore the time zone # TODO: Write time zone support return (pdt1, pdt2) - else: - unit = None - start = None - end = None - if count.value >= 1: - if dt1.year > 0: - unit = "years" - start = dt1.year - elif dt1.month > 0: - unit = "months" - start = dt1.month - elif dt1.day > 0: - unit = "days" - start = dt1.day - elif dt1.hour > 0: - unit = "hours" - start = dt1.hour - elif dt1.minute > 0: - unit = "minutes" - start = dt1.minute - elif dt1.second > 0: - unit = "seconds" - start = dt1.second - if count.value == 2: - if dt2.year > 0: - end = dt2.year - elif dt2.month > 0: - end = dt2.month - elif dt2.day > 0: - end = dt2.day - elif dt2.hour > 0: - end = dt2.hour - elif dt2.minute > 0: - end = dt2.minute - elif dt2.second > 0: - end = dt2.second - return (start, end, unit) + unit = None + start = None + end = None + if count.value >= 1: + if dt1.year > 0: + unit = "years" + start = dt1.year + elif dt1.month > 0: + unit = "months" + start = dt1.month + elif dt1.day > 0: + unit = "days" + start = dt1.day + elif dt1.hour > 0: + unit = "hours" + start = dt1.hour + elif dt1.minute > 0: + unit = "minutes" + start = dt1.minute + elif dt1.second > 0: + unit = "seconds" + start = dt1.second + if count.value == 2: + if dt2.year > 0: + end = dt2.year + elif dt2.month > 0: + end = dt2.month + elif dt2.day > 0: + end = dt2.day + elif dt2.hour > 0: + end = dt2.hour + elif dt2.minute > 0: + end = dt2.minute + elif dt2.second > 0: + end = dt2.second + return (start, end, unit) ############################################################################### diff --git a/python/grass/temporal/core.py b/python/grass/temporal/core.py index dc74bff151d..321c73d5408 100644 --- a/python/grass/temporal/core.py +++ b/python/grass/temporal/core.py @@ -769,12 +769,12 @@ def init(raise_fatal_error=False, skip_db_version_check=False): "Temporal database version mismatch detected.\n{backup}" "Supported temporal database version is: {tdb}\n" "Your existing temporal database version: {ctdb}\n" - "Current temporal database info: {info}".format( - backup=backup_howto, - tdb=tgis_db_version, - ctdb=tgis_db_version_meta, - info=get_database_info_string(), - ) + "Current temporal database info: {info}" + ).format( + backup=backup_howto, + tdb=tgis_db_version, + ctdb=tgis_db_version_meta, + info=get_database_info_string(), ) if tgis_db_version_meta == 2 and tgis_db_version == 3: @@ -784,8 +784,8 @@ def init(raise_fatal_error=False, skip_db_version_check=False): msgr.fatal( _( "The format of your actual temporal database is " - "not supported any more. {m}".format(m=message) - ) + "not supported any more. {m}" + ).format(m=message) ) return @@ -862,7 +862,7 @@ def create_temporal_database(dbif): stvds_tables_sql = stds_tables_template_sql.replace("STDS", "stvds") str3ds_tables_sql = stds_tables_template_sql.replace("STDS", "str3ds") - msgr.message(_("Creating temporal database: %s" % (str(tgis_database_string)))) + msgr.message(_("Creating temporal database: %s") % (str(tgis_database_string))) if tgis_backend == "sqlite": # We need to create the sqlite3 database path if it does not exist @@ -875,8 +875,9 @@ def create_temporal_database(dbif): _( "Unable to create SQLite temporal database\n" "Exception: %s\nPlease use t.connect to set a " - "read- and writable temporal database path" % (e) + "read- and writable temporal database path" ) + % (e) ) # Set up the trigger that takes care of @@ -1375,7 +1376,7 @@ def mogrify_sql_statement(self, content): if self.dbmi.__name__ == "psycopg2": if len(args) == 0: return sql - elif self.connected: + if self.connected: try: return self.cursor.mogrify(sql, args) except Exception as exc: @@ -1390,57 +1391,56 @@ def mogrify_sql_statement(self, content): elif self.dbmi.__name__ == "sqlite3": if len(args) == 0: return sql - else: - # Unfortunately as sqlite does not support - # the transformation of sql strings and qmarked or - # named arguments we must make our hands dirty - # and do it by ourself. :( - # Doors are open for SQL injection because of the - # limited python sqlite3 implementation!!! - pos = 0 - count = 0 - maxcount = 100 - statement = sql - - while count < maxcount: - pos = statement.find("?", pos + 1) - if pos == -1: - break - - if args[count] is None: - statement = "%sNULL%s" % ( - statement[0:pos], - statement[pos + 1 :], - ) - elif isinstance(args[count], int): - statement = "%s%d%s" % ( - statement[0:pos], - args[count], - statement[pos + 1 :], - ) - elif isinstance(args[count], float): - statement = "%s%f%s" % ( - statement[0:pos], - args[count], - statement[pos + 1 :], - ) - elif isinstance(args[count], datetime): - statement = "%s'%s'%s" % ( - statement[0:pos], - str(args[count]), - statement[pos + 1 :], - ) - else: - # Default is a string, this works for datetime - # objects too - statement = "%s'%s'%s" % ( - statement[0:pos], - str(args[count]), - statement[pos + 1 :], - ) - count += 1 + # Unfortunately as sqlite does not support + # the transformation of sql strings and qmarked or + # named arguments we must make our hands dirty + # and do it by ourself. :( + # Doors are open for SQL injection because of the + # limited python sqlite3 implementation!!! + pos = 0 + count = 0 + maxcount = 100 + statement = sql + + while count < maxcount: + pos = statement.find("?", pos + 1) + if pos == -1: + break + + if args[count] is None: + statement = "%sNULL%s" % ( + statement[0:pos], + statement[pos + 1 :], + ) + elif isinstance(args[count], int): + statement = "%s%d%s" % ( + statement[0:pos], + args[count], + statement[pos + 1 :], + ) + elif isinstance(args[count], float): + statement = "%s%f%s" % ( + statement[0:pos], + args[count], + statement[pos + 1 :], + ) + elif isinstance(args[count], datetime): + statement = "%s'%s'%s" % ( + statement[0:pos], + str(args[count]), + statement[pos + 1 :], + ) + else: + # Default is a string, this works for datetime + # objects too + statement = "%s'%s'%s" % ( + statement[0:pos], + str(args[count]), + statement[pos + 1 :], + ) + count += 1 - return statement + return statement def check_table(self, table_name): """Check if a table exists in the temporal database @@ -1502,7 +1502,7 @@ def execute(self, statement, args=None): except: if connected: self.close() - self.msgr.error(_("Unable to execute :\n %(sql)s" % {"sql": statement})) + self.msgr.error(_("Unable to execute :\n %(sql)s") % {"sql": statement}) raise if connected: @@ -1546,7 +1546,7 @@ def execute_transaction(self, statement, mapset=None): if connected: self.close() self.msgr.error( - _("Unable to execute transaction:\n %(sql)s" % {"sql": statement}) + _("Unable to execute transaction:\n %(sql)s") % {"sql": statement} ) raise diff --git a/python/grass/temporal/datetime_math.py b/python/grass/temporal/datetime_math.py index 9b680760775..b986637162a 100644 --- a/python/grass/temporal/datetime_math.py +++ b/python/grass/temporal/datetime_math.py @@ -694,10 +694,7 @@ def compute_datetime_delta(start, end): else: d += 24 * 60 * day_diff elif d == 0: - if comp["hour"]: - d = 60 * comp["hour"] - else: - d = 24 * 60 * day_diff + d = 60 * comp["hour"] if comp["hour"] else 24 * 60 * day_diff comp["minute"] = d @@ -828,7 +825,7 @@ def check_datetime_string(time_string, use_dateutil=True): try: return datetime.strptime(time_string, time_format) except: - return _("Unable to parse time string: %s" % time_string) + return _("Unable to parse time string: %s") % time_string ############################################################################### @@ -914,10 +911,7 @@ def datetime_to_grass_datetime_string(dt): # Check for time zone info in the datetime object if dt.tzinfo is not None: tz = dt.tzinfo.utcoffset(0) - if tz.seconds > 86400 / 2: - tz = (tz.seconds - 86400) / 60 - else: - tz = tz.seconds / 60 + tz = (tz.seconds - 86400) / 60 if tz.seconds > 86400 / 2 else tz.seconds / 60 string = "%.2i %s %.2i %.2i:%.2i:%.2i %+.4i" % ( dt.day, @@ -999,10 +993,7 @@ def create_numeric_suffix(base, count, zeros): if len(spli) == 2: suff = spli[1] if suff.isdigit(): - if int(suff[0]) == 0: - zero = suff - else: - zero = "0{nu}".format(nu=suff) + zero = suff if int(suff[0]) == 0 else "0{nu}".format(nu=suff) else: zero = "05" else: diff --git a/python/grass/temporal/factory.py b/python/grass/temporal/factory.py index ba7f5e7d4f0..f246700ef44 100644 --- a/python/grass/temporal/factory.py +++ b/python/grass/temporal/factory.py @@ -1,23 +1,18 @@ """ Object factory -Usage: - -.. code-block:: python - - import grass.temporal as tgis - - tgis.register_maps_in_space_time_dataset(type, name, maps) - - -(C) 2012-2013 by the GRASS Development Team +(C) 2012-2024 by the GRASS Development Team This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details. -:authors: Soeren Gebbert +:authors: Soeren Gebbert, Edouard Choinière """ +from __future__ import annotations + +from typing import Literal, overload + from .core import get_tgis_message_interface from .space_time_datasets import ( Raster3DDataset, @@ -31,7 +26,65 @@ ############################################################################### -def dataset_factory(type, id): +@overload +def dataset_factory(type: Literal["strds"], id: str) -> SpaceTimeRasterDataset: + pass + + +@overload +def dataset_factory(type: Literal["str3ds"], id: str) -> SpaceTimeRaster3DDataset: + pass + + +@overload +def dataset_factory(type: Literal["stvds"], id: str) -> SpaceTimeVectorDataset: + pass + + +@overload +def dataset_factory(type: Literal["rast", "raster"], id: str) -> RasterDataset: + pass + + +@overload +def dataset_factory( + type: Literal["raster_3d", "rast3d", "raster3d"], + id: str, +) -> Raster3DDataset: + pass + + +@overload +def dataset_factory(type: Literal["vect", "vector"], id: str) -> VectorDataset: + pass + + +@overload +def dataset_factory( + type: str, id: str +) -> ( + SpaceTimeRasterDataset + | SpaceTimeRaster3DDataset + | SpaceTimeVectorDataset + | RasterDataset + | Raster3DDataset + | VectorDataset + | None +): + pass + + +def dataset_factory( + type: str, id: str | None +) -> ( + SpaceTimeRasterDataset + | SpaceTimeRaster3DDataset + | SpaceTimeVectorDataset + | RasterDataset + | Raster3DDataset + | VectorDataset + | None +): """A factory functions to create space time or map datasets :param type: the dataset type: rast or raster; rast3d, raster3d or raster_3d; @@ -39,20 +92,18 @@ def dataset_factory(type, id): :param id: The id of the dataset ("name@mapset") """ if type == "strds": - sp = SpaceTimeRasterDataset(id) - elif type == "str3ds": - sp = SpaceTimeRaster3DDataset(id) - elif type == "stvds": - sp = SpaceTimeVectorDataset(id) - elif type in {"rast", "raster"}: - sp = RasterDataset(id) - elif type in {"raster_3d", "rast3d", "raster3d"}: - sp = Raster3DDataset(id) - elif type in {"vect", "vector"}: - sp = VectorDataset(id) - else: - msgr = get_tgis_message_interface() - msgr.error(_("Unknown dataset type: %s") % type) - return None - - return sp + return SpaceTimeRasterDataset(id) + if type == "str3ds": + return SpaceTimeRaster3DDataset(id) + if type == "stvds": + return SpaceTimeVectorDataset(id) + if type in {"rast", "raster"}: + return RasterDataset(id) + if type in {"raster_3d", "rast3d", "raster3d"}: + return Raster3DDataset(id) + if type in {"vect", "vector"}: + return VectorDataset(id) + + msgr = get_tgis_message_interface() + msgr.error(_("Unknown dataset type: %s") % type) + return None diff --git a/python/grass/temporal/gui_support.py b/python/grass/temporal/gui_support.py index 41f22edc6b7..d2cbca13d68 100644 --- a/python/grass/temporal/gui_support.py +++ b/python/grass/temporal/gui_support.py @@ -37,16 +37,14 @@ def tlist_grouped(type, group_type=False, dbif=None): :return: directory of mapsets/elements """ result = {} + _type = type dbif, connection_state_changed = init_dbif(dbif) mapset = None - if type == "stds": - types = ["strds", "str3ds", "stvds"] - else: - types = [type] - for type in types: + types = ["strds", "str3ds", "stvds"] if _type == "stds" else [_type] + for _type in types: try: - tlist_result = tlist(type=type, dbif=dbif) + tlist_result = tlist(type=_type, dbif=dbif) except gs.ScriptError as e: gs.warning(e) continue @@ -65,10 +63,10 @@ def tlist_grouped(type, group_type=False, dbif=None): result[mapset] = [] if group_type: - if type in result[mapset]: - result[mapset][type].append(name) + if _type in result[mapset]: + result[mapset][_type].append(name) else: - result[mapset][type] = [ + result[mapset][_type] = [ name, ] else: @@ -90,19 +88,20 @@ def tlist(type, dbif=None): :return: a list of space time dataset ids """ + _type = type id = None - sp = dataset_factory(type, id) + sp = dataset_factory(_type, id) dbif, connection_state_changed = init_dbif(dbif) mapsets = get_available_temporal_mapsets() output = [] temporal_type = ["absolute", "relative"] - for type in temporal_type: + for _type in temporal_type: # For each available mapset for mapset in mapsets.keys(): # Table name - if type == "absolute": + if _type == "absolute": table = sp.get_type() + "_view_abs_time" else: table = sp.get_type() + "_view_rel_time" diff --git a/python/grass/temporal/list_stds.py b/python/grass/temporal/list_stds.py index 9f6b6867766..22a2708123d 100644 --- a/python/grass/temporal/list_stds.py +++ b/python/grass/temporal/list_stds.py @@ -325,10 +325,7 @@ def _get_get_registered_maps_as_objects_delta_gran( msgr.fatal(_("Empty entry in map list, this should not happen")) start, end = map_object.get_temporal_extent_as_tuple() - if end: - delta = end - start - else: - delta = None + delta = end - start if end else None delta_first = start - first_time if map_object.is_time_absolute(): diff --git a/python/grass/temporal/mapcalc.py b/python/grass/temporal/mapcalc.py index 5f29cd32747..8761e86160f 100644 --- a/python/grass/temporal/mapcalc.py +++ b/python/grass/temporal/mapcalc.py @@ -508,90 +508,72 @@ def _parse_start_operators(expr, is_time_absolute, current): if expr.find("start_year()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) expr = expr.replace("start_year()", str(start.year)) if expr.find("start_month()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) expr = expr.replace("start_month()", str(start.month)) if expr.find("start_week()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) expr = expr.replace("start_week()", str(start.isocalendar()[1])) if expr.find("start_day()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) expr = expr.replace("start_day()", str(start.day)) if expr.find("start_hour()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) expr = expr.replace("start_hour()", str(start.hour)) if expr.find("start_minute()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) expr = expr.replace("start_minute()", str(start.minute)) if expr.find("start_second()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) expr = expr.replace("start_second()", str(start.second)) if expr.find("start_dow()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) expr = expr.replace("start_dow()", str(start.isoweekday())) if expr.find("start_doy()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("start_*") - ) + _("The temporal operators <%s> support only absolute time.") + % ("start_*") ) year = datetime(start.year, 1, 1) delta = start - year @@ -628,10 +610,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_year()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_year()", "null()") @@ -641,10 +620,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_month()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_month()", "null()") @@ -654,10 +630,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_week()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_week()", "null()") @@ -667,10 +640,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_day()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_day()", "null()") @@ -680,10 +650,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_hour()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_hour()", "null()") @@ -693,10 +660,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_minute()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_minute()", "null()") @@ -706,10 +670,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_second()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_second()", "null()") @@ -719,10 +680,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_dow()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_dow()", "null()") @@ -732,10 +690,7 @@ def _parse_end_operators(expr, is_time_absolute, current): if expr.find("end_doy()") >= 0: if not is_time_absolute: msgr.fatal( - _( - "The temporal operators <%s> support only absolute " - "time." % ("end_*") - ) + _("The temporal operators <%s> support only absolute time.") % ("end_*") ) if not end: expr = expr.replace("end_doy()", "null()") diff --git a/python/grass/temporal/metadata.py b/python/grass/temporal/metadata.py index 6094bbbe146..4be4c568a76 100644 --- a/python/grass/temporal/metadata.py +++ b/python/grass/temporal/metadata.py @@ -174,72 +174,63 @@ def get_id(self): """ if "id" in self.D: return self.D["id"] - else: - return None + return None def get_datatype(self): """Get the map type :return: None if not found""" if "datatype" in self.D: return self.D["datatype"] - else: - return None + return None def get_cols(self): """Get number of cols :return: None if not found""" if "cols" in self.D: return self.D["cols"] - else: - return None + return None def get_rows(self): """Get number of rows :return: None if not found""" if "rows" in self.D: return self.D["rows"] - else: - return None + return None def get_number_of_cells(self): """Get number of cells :return: None if not found""" if "number_of_cells" in self.D: return self.D["number_of_cells"] - else: - return None + return None def get_nsres(self): """Get the north-south resolution :return: None if not found""" if "nsres" in self.D: return self.D["nsres"] - else: - return None + return None def get_ewres(self): """Get east-west resolution :return: None if not found""" if "ewres" in self.D: return self.D["ewres"] - else: - return None + return None def get_min(self): """Get the minimum cell value :return: None if not found""" if "min" in self.D: return self.D["min"] - else: - return None + return None def get_max(self): """Get the maximum cell value :return: None if not found""" if "max" in self.D: return self.D["max"] - else: - return None + return None # Properties datatype = property(fget=get_datatype, fset=set_datatype) @@ -251,6 +242,26 @@ def get_max(self): min = property(fget=get_min, fset=set_min) max = property(fget=get_max, fset=set_max) + def print_info(self): + """Print information about this class in human readable style""" + self._print_info_body(shell=False) + + def print_shell_info(self): + """Print information about this class in shell style""" + self._print_info_body(shell=True) + + def _print_info_head(self, shell=False): + """Print information about this class (head part). + + No header printed in shell style mode. + + :param bool shell: True for human readable style otherwise shell style + """ + if not shell: + print( + " +-------------------- Metadata information ----------------------------------+" # noqa: E501 + ) + def _print_info_body(self, shell=False): """Print information about this class (body part). @@ -331,6 +342,7 @@ class RasterMetadata(RasterMetadataBase): | East-west resolution:....... 0.1 | Minimum value:.............. 0.0 | Maximum value:.............. 100.0 + | Semantic label:............. None >>> meta.print_shell_info() datatype=CELL cols=100 @@ -340,6 +352,7 @@ class RasterMetadata(RasterMetadataBase): ewres=0.1 min=0.0 max=100.0 + semantic_label=None """ @@ -379,22 +392,23 @@ def get_semantic_label(self): :return: None if not found""" if "semantic_label" in self.D: return self.D["semantic_label"] - else: - return None + return None semantic_label = property(fget=get_semantic_label, fset=set_semantic_label) - def _print_info_body(self, shell=False): - """Print information about this class (body part). + def print_info(self): + """Print information about this class.""" + self._print_info_head(shell=False) + self._print_info_body(shell=False) + # semantic label section (raster specific only) + print(" | Semantic label:............. " + str(self.get_semantic_label())) - :param bool shell: True for human readable style otherwise shell style - """ - super()._print_info_body(shell) + def print_shell_info(self): + """Print information about this class in shell style""" + self._print_info_head(shell=True) + self._print_info_body(shell=True) # semantic label section (raster specific only) - if shell: - print("semantic_label=" + str(self.get_semantic_label())) - else: - print(" | Semantic label:............. " + str(self.get_semantic_label())) + print("semantic_label=" + str(self.get_semantic_label())) ############################################################################### @@ -525,32 +539,31 @@ def get_depths(self): :return: None if not found""" if "depths" in self.D: return self.D["depths"] - else: - return None + return None def get_tbres(self): """Get top-bottom resolution :return: None if not found""" if "tbres" in self.D: return self.D["tbres"] - else: - return None + return None depths = property(fget=get_depths, fset=set_depths) tbres = property(fget=get_tbres, fset=set_tbres) - def _print_info_body(self, shell=False): - """Print information about this class (body part). + def print_info(self): + """Print information about this class.""" + self._print_info_head(shell=False) + self._print_info_body(shell=False) + print(" | Number of depths:........... " + str(self.get_depths())) + print(" | Top-Bottom resolution:...... " + str(self.get_tbres())) - :param bool shell: True for human readable style otherwise shell style - """ - super()._print_info_body(shell) - if shell: - print("depths=" + str(self.get_depths())) - print("tbres=" + str(self.get_tbres())) - else: - print(" | Number of depths:........... " + str(self.get_depths())) - print(" | Top-Bottom resolution:...... " + str(self.get_tbres())) + def print_shell_info(self): + """Print information about this class in shell style""" + self._print_info_head(shell=True) + self._print_info_body(shell=True) + print("depths=" + str(self.get_depths())) + print("tbres=" + str(self.get_tbres())) ############################################################################### @@ -741,112 +754,98 @@ def get_id(self): """ if "id" in self.D: return self.D["id"] - else: - return None + return None def get_3d_info(self): """Return True if the map is three dimensional, False if not and None if not info was found""" if "is_3d" in self.D: return self.D["is_3d"] - else: - return None + return None def get_number_of_points(self): """Get the number of points of the vector map :return: None if not found""" if "points" in self.D: return self.D["points"] - else: - return None + return None def get_number_of_lines(self): """Get the number of lines of the vector map :return: None if not found""" if "lines" in self.D: return self.D["lines"] - else: - return None + return None def get_number_of_boundaries(self): """Get the number of boundaries of the vector map :return: None if not found""" if "boundaries" in self.D: return self.D["boundaries"] - else: - return None + return None def get_number_of_centroids(self): """Get the number of centroids of the vector map :return: None if not found""" if "centroids" in self.D: return self.D["centroids"] - else: - return None + return None def get_number_of_faces(self): """Get the number of faces of the vector map :return: None if not found""" if "faces" in self.D: return self.D["faces"] - else: - return None + return None def get_number_of_kernels(self): """Get the number of kernels of the vector map :return: None if not found""" if "kernels" in self.D: return self.D["kernels"] - else: - return None + return None def get_number_of_primitives(self): """Get the number of primitives of the vector map :return: None if not found""" if "primitives" in self.D: return self.D["primitives"] - else: - return None + return None def get_number_of_nodes(self): """Get the number of nodes of the vector map :return: None if not found""" if "nodes" in self.D: return self.D["nodes"] - else: - return None + return None def get_number_of_areas(self): """Get the number of areas of the vector map :return: None if not found""" if "areas" in self.D: return self.D["areas"] - else: - return None + return None def get_number_of_islands(self): """Get the number of islands of the vector map :return: None if not found""" if "islands" in self.D: return self.D["islands"] - else: - return None + return None def get_number_of_holes(self): """Get the number of holes of the vector map :return: None if not found""" if "holes" in self.D: return self.D["holes"] - else: - return None + return None def get_number_of_volumes(self): """Get the number of volumes of the vector map :return: None if not found""" if "volumes" in self.D: return self.D["volumes"] - else: - return None + return None # Set the properties id = property(fget=get_id, fset=set_id) @@ -870,53 +869,40 @@ def get_number_of_volumes(self): number_of_holes = property(fget=get_number_of_holes, fset=set_number_of_holes) number_of_volumes = property(fget=get_number_of_volumes, fset=set_number_of_volumes) - def _print_info_body(self, shell=False): - """Print information about this class (body part). + def print_info(self): + """Print information about this class in human readable style""" + print( + " +-------------------- Metadata information ----------------------------------+" # noqa: E501 + ) + print(" | Is map 3d .................. " + str(self.get_3d_info())) + print(" | Number of points ........... " + str(self.get_number_of_points())) + print(" | Number of lines ............ " + str(self.get_number_of_lines())) + print(" | Number of boundaries ....... " + str(self.get_number_of_boundaries())) + print(" | Number of centroids ........ " + str(self.get_number_of_centroids())) + print(" | Number of faces ............ " + str(self.get_number_of_faces())) + print(" | Number of kernels .......... " + str(self.get_number_of_kernels())) + print(" | Number of primitives ....... " + str(self.get_number_of_primitives())) + print(" | Number of nodes ............ " + str(self.get_number_of_nodes())) + print(" | Number of areas ............ " + str(self.get_number_of_areas())) + print(" | Number of islands .......... " + str(self.get_number_of_islands())) + print(" | Number of holes ............ " + str(self.get_number_of_holes())) + print(" | Number of volumes .......... " + str(self.get_number_of_volumes())) - :param bool shell: True for human readable style otherwise shell style - """ - if shell: - print("is_3d=" + str(self.get_3d_info())) - print("points=" + str(self.get_number_of_points())) - print("lines=" + str(self.get_number_of_lines())) - print("boundaries=" + str(self.get_number_of_boundaries())) - print("centroids=" + str(self.get_number_of_centroids())) - print("faces=" + str(self.get_number_of_faces())) - print("kernels=" + str(self.get_number_of_kernels())) - print("primitives=" + str(self.get_number_of_primitives())) - print("nodes=" + str(self.get_number_of_nodes())) - print("areas=" + str(self.get_number_of_areas())) - print("islands=" + str(self.get_number_of_islands())) - print("holes=" + str(self.get_number_of_holes())) - print("volumes=" + str(self.get_number_of_volumes())) - else: - print(" | Is map 3d .................. " + str(self.get_3d_info())) - print(" | Number of points ........... " + str(self.get_number_of_points())) - print(" | Number of lines ............ " + str(self.get_number_of_lines())) - print( - " | Number of boundaries ....... " - + str(self.get_number_of_boundaries()) - ) - print( - " | Number of centroids ........ " + str(self.get_number_of_centroids()) - ) - print(" | Number of faces ............ " + str(self.get_number_of_faces())) - print( - " | Number of kernels .......... " + str(self.get_number_of_kernels()) - ) - print( - " | Number of primitives ....... " - + str(self.get_number_of_primitives()) - ) - print(" | Number of nodes ............ " + str(self.get_number_of_nodes())) - print(" | Number of areas ............ " + str(self.get_number_of_areas())) - print( - " | Number of islands .......... " + str(self.get_number_of_islands()) - ) - print(" | Number of holes ............ " + str(self.get_number_of_holes())) - print( - " | Number of volumes .......... " + str(self.get_number_of_volumes()) - ) + def print_shell_info(self): + """Print information about this class in shell style""" + print("is_3d=" + str(self.get_3d_info())) + print("points=" + str(self.get_number_of_points())) + print("lines=" + str(self.get_number_of_lines())) + print("boundaries=" + str(self.get_number_of_boundaries())) + print("centroids=" + str(self.get_number_of_centroids())) + print("faces=" + str(self.get_number_of_faces())) + print("kernels=" + str(self.get_number_of_kernels())) + print("primitives=" + str(self.get_number_of_primitives())) + print("nodes=" + str(self.get_number_of_nodes())) + print("areas=" + str(self.get_number_of_areas())) + print("islands=" + str(self.get_number_of_islands())) + print("holes=" + str(self.get_number_of_holes())) + print("volumes=" + str(self.get_number_of_volumes())) ############################################################################### @@ -990,32 +976,28 @@ def get_id(self): """ if "id" in self.D: return self.D["id"] - else: - return None + return None def get_title(self): """Get the title :return: None if not found""" if "title" in self.D: return self.D["title"] - else: - return None + return None def get_description(self): """Get description :return: None if not found""" if "description" in self.D: return self.D["description"] - else: - return None + return None def get_command(self): """Get command :return: None if not found""" if "command" in self.D: return self.D["command"] - else: - return None + return None def get_number_of_maps(self): """Get the number of registered maps, @@ -1024,8 +1006,7 @@ def get_number_of_maps(self): :return: None if not found""" if "number_of_maps" in self.D: return self.D["number_of_maps"] - else: - return None + return None id = property(fget=get_id, fset=set_id) title = property(fget=get_title, fset=set_title) @@ -1034,13 +1015,11 @@ def get_number_of_maps(self): def print_info(self): """Print information about this class in human readable style""" - self._print_info_head(shell=False) self._print_info_body(shell=False) self._print_info_tail(shell=False) def print_shell_info(self): """Print information about this class in shell style""" - self._print_info_head(shell=True) self._print_info_body(shell=True) self._print_info_tail(shell=True) @@ -1056,6 +1035,12 @@ def _print_info_head(self, shell=False): " +-------------------- Metadata information ----------------------------------+" # noqa: E501 ) + def _print_info_body(self, shell=False): + """Print information about this class (body part). + + :param bool shell: True for human readable style otherwise shell style + """ + def _print_info_tail(self, shell=False): """Print information about this class (tail part). @@ -1204,8 +1189,7 @@ def get_aggregation_type(self): """ if "aggregation_type" in self.D: return self.D["aggregation_type"] - else: - return None + return None def get_max_min(self): """Get the minimal maximum of all registered maps, @@ -1214,8 +1198,7 @@ def get_max_min(self): :return: None if not found""" if "max_min" in self.D: return self.D["max_min"] - else: - return None + return None def get_min_min(self): """Get the minimal minimum of all registered maps, @@ -1224,8 +1207,7 @@ def get_min_min(self): :return: None if not found""" if "min_min" in self.D: return self.D["min_min"] - else: - return None + return None def get_max_max(self): """Get the maximal maximum of all registered maps, @@ -1234,8 +1216,7 @@ def get_max_max(self): :return: None if not found""" if "max_max" in self.D: return self.D["max_max"] - else: - return None + return None def get_min_max(self): """Get the maximal minimum of all registered maps, @@ -1244,8 +1225,7 @@ def get_min_max(self): :return: None if not found""" if "min_max" in self.D: return self.D["min_max"] - else: - return None + return None def get_nsres_min(self): """Get the minimal north-south resolution of all registered maps, @@ -1254,8 +1234,7 @@ def get_nsres_min(self): :return: None if not found""" if "nsres_min" in self.D: return self.D["nsres_min"] - else: - return None + return None def get_nsres_max(self): """Get the maximal north-south resolution of all registered maps, @@ -1264,8 +1243,7 @@ def get_nsres_max(self): :return: None if not found""" if "nsres_max" in self.D: return self.D["nsres_max"] - else: - return None + return None def get_ewres_min(self): """Get the minimal east-west resolution of all registered maps, @@ -1274,8 +1252,7 @@ def get_ewres_min(self): :return: None if not found""" if "ewres_min" in self.D: return self.D["ewres_min"] - else: - return None + return None def get_ewres_max(self): """Get the maximal east-west resolution of all registered maps, @@ -1284,8 +1261,7 @@ def get_ewres_max(self): :return: None if not found""" if "ewres_max" in self.D: return self.D["ewres_max"] - else: - return None + return None nsres_min = property(fget=get_nsres_min) nsres_max = property(fget=get_nsres_max) @@ -1419,8 +1395,7 @@ def get_raster_register(self): :return: None if not found""" if "raster_register" in self.D: return self.D["raster_register"] - else: - return None + return None def get_number_of_semantic_labels(self): """Get the number of registered semantic labels @@ -1428,8 +1403,7 @@ def get_number_of_semantic_labels(self): """ if "number_of_semantic_labels" in self.D: return self.D["number_of_semantic_labels"] - else: - return None + return None def get_semantic_labels(self): """Get the distinct semantic labels of registered maps @@ -1467,15 +1441,23 @@ def get_semantic_labels(self): if count > 0: return string - else: - return None - else: return None + return None raster_register = property(fget=get_raster_register, fset=set_raster_register) number_of_semantic_labels = property(fget=get_number_of_semantic_labels) semantic_labels = property(fget=get_semantic_labels) + def print_info(self): + """Print information about this class in human readable style""" + self._print_info_head(shell=False) + super().print_info() + + def print_shell_info(self): + """Print information about this class in shell style""" + self._print_info_head(shell=True) + super().print_shell_info() + def _print_info_body(self, shell=False): """Print information about this class (body part). @@ -1562,6 +1544,8 @@ class STR3DSMetadata(STDSRasterMetadataBase): | Command history: >>> meta.print_shell_info() raster3d_register=None + tbres_min=None + tbres_max=None nsres_min=None nsres_max=None ewres_min=None @@ -1570,8 +1554,6 @@ class STR3DSMetadata(STDSRasterMetadataBase): min_max=None max_min=None max_max=None - tbres_min=None - tbres_max=None aggregation_type=None number_of_maps=None @@ -1597,8 +1579,7 @@ def get_raster3d_register(self): :return: None if not found""" if "raster3d_register" in self.D: return self.D["raster3d_register"] - else: - return None + return None def get_tbres_min(self): """Get the minimal top-bottom resolution of all registered maps, @@ -1607,8 +1588,7 @@ def get_tbres_min(self): :return: None if not found""" if "tbres_min" in self.D: return self.D["tbres_min"] - else: - return None + return None def get_tbres_max(self): """Get the maximal top-bottom resolution of all registered maps, @@ -1617,13 +1597,22 @@ def get_tbres_max(self): :return: None if not found""" if "tbres_max" in self.D: return self.D["tbres_max"] - else: - return None + return None raster3d_register = property(fget=get_raster3d_register, fset=set_raster3d_register) tbres_min = property(fget=get_tbres_min) tbres_max = property(fget=get_tbres_max) + def print_info(self): + """Print information about this class in human readable style""" + self._print_info_head(shell=False) + super().print_info() + + def print_shell_info(self): + """Print information about this class in shell style""" + self._print_info_head(shell=True) + super().print_shell_info() + def _print_info_body(self, shell=False): """Print information about this class (body part). @@ -1751,8 +1740,7 @@ def get_vector_register(self): :return: None if not found""" if "vector_register" in self.D: return self.D["vector_register"] - else: - return None + return None def get_number_of_points(self): """Get the number of points of all registered maps, @@ -1761,8 +1749,7 @@ def get_number_of_points(self): :return: None if not found""" if "points" in self.D: return self.D["points"] - else: - return None + return None def get_number_of_lines(self): """Get the number of lines of all registered maps, @@ -1771,8 +1758,7 @@ def get_number_of_lines(self): :return: None if not found""" if "lines" in self.D: return self.D["lines"] - else: - return None + return None def get_number_of_boundaries(self): """Get the number of boundaries of all registered maps, @@ -1781,8 +1767,7 @@ def get_number_of_boundaries(self): :return: None if not found""" if "boundaries" in self.D: return self.D["boundaries"] - else: - return None + return None def get_number_of_centroids(self): """Get the number of centroids of all registered maps, @@ -1791,8 +1776,7 @@ def get_number_of_centroids(self): :return: None if not found""" if "centroids" in self.D: return self.D["centroids"] - else: - return None + return None def get_number_of_faces(self): """Get the number of faces of all registered maps, @@ -1801,8 +1785,7 @@ def get_number_of_faces(self): :return: None if not found""" if "faces" in self.D: return self.D["faces"] - else: - return None + return None def get_number_of_kernels(self): """Get the number of kernels of all registered maps, @@ -1811,8 +1794,7 @@ def get_number_of_kernels(self): :return: None if not found""" if "kernels" in self.D: return self.D["kernels"] - else: - return None + return None def get_number_of_primitives(self): """Get the number of primitives of all registered maps, @@ -1821,8 +1803,7 @@ def get_number_of_primitives(self): :return: None if not found""" if "primitives" in self.D: return self.D["primitives"] - else: - return None + return None def get_number_of_nodes(self): """Get the number of nodes of all registered maps, @@ -1831,8 +1812,7 @@ def get_number_of_nodes(self): :return: None if not found""" if "nodes" in self.D: return self.D["nodes"] - else: - return None + return None def get_number_of_areas(self): """Get the number of areas of all registered maps, @@ -1841,8 +1821,7 @@ def get_number_of_areas(self): :return: None if not found""" if "areas" in self.D: return self.D["areas"] - else: - return None + return None def get_number_of_islands(self): """Get the number of islands of all registered maps, @@ -1851,8 +1830,7 @@ def get_number_of_islands(self): :return: None if not found""" if "islands" in self.D: return self.D["islands"] - else: - return None + return None def get_number_of_holes(self): """Get the number of holes of all registered maps, @@ -1861,8 +1839,7 @@ def get_number_of_holes(self): :return: None if not found""" if "holes" in self.D: return self.D["holes"] - else: - return None + return None def get_number_of_volumes(self): """Get the number of volumes of all registered maps, @@ -1871,8 +1848,7 @@ def get_number_of_volumes(self): :return: None if not found""" if "volumes" in self.D: return self.D["volumes"] - else: - return None + return None # Set the properties vector_register = property(fget=get_vector_register, fset=set_vector_register) @@ -1889,6 +1865,16 @@ def get_number_of_volumes(self): number_of_holes = property(fget=get_number_of_holes) number_of_volumes = property(fget=get_number_of_volumes) + def print_info(self): + """Print information about this class in human readable style""" + self._print_info_head(shell=False) + super().print_info() + + def print_shell_info(self): + """Print information about this class in shell style""" + self._print_info_head(shell=True) + super().print_shell_info() + def _print_info_body(self, shell=False): """Print information about this class (body part). diff --git a/python/grass/temporal/register.py b/python/grass/temporal/register.py index 0cd339946b9..d8705765d02 100644 --- a/python/grass/temporal/register.py +++ b/python/grass/temporal/register.py @@ -158,10 +158,7 @@ def register_maps_in_space_time_dataset( # Read the map list from file if file: - if hasattr(file, "readline"): - fd = file - else: - fd = open(file, "r") + fd = file if hasattr(file, "readline") else open(file) line = True while True: @@ -264,10 +261,7 @@ def register_maps_in_space_time_dataset( end = row["end"] # Use the semantic label from file - if "semantic_label" in row: - semantic_label = row["semantic_label"] - else: - semantic_label = None + semantic_label = row.get("semantic_label", None) is_in_db = map_object.is_in_db(dbif, mapset) @@ -642,10 +636,7 @@ def register_map_object_list( string = f"{id}|{start}|{end}\n" register_file.write(string) - if output_stds: - output_stds_id = output_stds.get_id() - else: - output_stds_id = None + output_stds_id = output_stds.get_id() if output_stds else None register_maps_in_space_time_dataset( type, output_stds_id, unit=unit, file=filename, dbif=dbif diff --git a/python/grass/temporal/sampling.py b/python/grass/temporal/sampling.py index 425ca484da5..5209ce6a80c 100644 --- a/python/grass/temporal/sampling.py +++ b/python/grass/temporal/sampling.py @@ -82,19 +82,11 @@ def sample_stds_by_stds_topology( sts = [] for input in inputs: - if input.find("@") >= 0: - id = input - else: - id = input + "@" + mapset - + id = input if input.find("@") >= 0 else input + "@" + mapset st = dataset_factory(intype, id) sts.append(st) - if sampler.find("@") >= 0: - sid = sampler - else: - sid = sampler + "@" + mapset - + sid = sampler if sampler.find("@") >= 0 else sampler + "@" + mapset sst = dataset_factory(sampletype, sid) dbif = SQLDatabaseInterfaceConnection() @@ -156,10 +148,7 @@ def sample_stds_by_stds_topology( map = entry["granule"] start, end = map.get_temporal_extent_as_tuple() - if end: - delta = end - start - else: - delta = None + delta = end - start if end else None delta_first = start - first_time if map.is_time_absolute(): diff --git a/python/grass/temporal/space_time_datasets.py b/python/grass/temporal/space_time_datasets.py index a73e03fff46..92721277c9e 100644 --- a/python/grass/temporal/space_time_datasets.py +++ b/python/grass/temporal/space_time_datasets.py @@ -288,10 +288,8 @@ def read_timestamp_from_grass(self): if check < 1: self.msgr.error( - _( - "Unable to read timestamp file " - "for raster map <%s>" % (self.get_map_id()) - ) + _("Unable to read timestamp file for raster map <%s>") + % (self.get_map_id()) ) return False @@ -316,19 +314,15 @@ def write_timestamp_to_grass(self): if check == -1: self.msgr.error( - _( - "Unable to create timestamp file " - "for raster map <%s>" % (self.get_map_id()) - ) + _("Unable to create timestamp file for raster map <%s>") + % (self.get_map_id()) ) return False if check == -2: self.msgr.error( - _( - "Invalid datetime in timestamp for raster map " - "<%s>" % (self.get_map_id()) - ) + _("Invalid datetime in timestamp for raster map <%s>") + % (self.get_map_id()) ) return False @@ -350,7 +344,7 @@ def remove_timestamp_from_grass(self): if check == -1: self.msgr.error( - _("Unable to remove timestamp for raster map <%s>" % (self.get_name())) + _("Unable to remove timestamp for raster map <%s>") % (self.get_name()) ) return False @@ -390,10 +384,8 @@ def write_semantic_label_to_grass(self): ) if check == -1: self.msgr.error( - _( - "Unable to write semantic label for raster map <%s>" - % (self.get_name()) - ) + _("Unable to write semantic label for raster map <%s>") + % (self.get_name()) ) return False @@ -641,15 +633,13 @@ def spatial_overlapping(self, dataset): """Return True if the spatial extents overlap""" if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds": return self.spatial_extent.overlapping(dataset.spatial_extent) - else: - return self.spatial_extent.overlapping_2d(dataset.spatial_extent) + return self.spatial_extent.overlapping_2d(dataset.spatial_extent) def spatial_relation(self, dataset): """Return the two or three dimensional spatial relation""" if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds": return self.spatial_extent.spatial_relation(dataset.spatial_extent) - else: - return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent) + return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent) def spatial_intersection(self, dataset): """Return the three or two dimensional intersection as spatial_extent @@ -660,8 +650,7 @@ def spatial_intersection(self, dataset): """ if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds": return self.spatial_extent.intersect(dataset.spatial_extent) - else: - return self.spatial_extent.intersect_2d(dataset.spatial_extent) + return self.spatial_extent.intersect_2d(dataset.spatial_extent) def spatial_union(self, dataset): """Return the three or two dimensional union as spatial_extent @@ -672,8 +661,7 @@ def spatial_union(self, dataset): """ if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds": return self.spatial_extent.union(dataset.spatial_extent) - else: - return self.spatial_extent.union_2d(dataset.spatial_extent) + return self.spatial_extent.union_2d(dataset.spatial_extent) def spatial_disjoint_union(self, dataset): """Return the three or two dimensional union as spatial_extent object. @@ -683,8 +671,7 @@ def spatial_disjoint_union(self, dataset): """ if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds": return self.spatial_extent.disjoint_union(dataset.spatial_extent) - else: - return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent) + return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent) def get_np_array(self): """Return this 3D raster map as memmap numpy style array to access the @@ -741,10 +728,8 @@ def read_timestamp_from_grass(self): if check < 1: self.msgr.error( - _( - "Unable to read timestamp file " - "for 3D raster map <%s>" % (self.get_map_id()) - ) + _("Unable to read timestamp file for 3D raster map <%s>") + % (self.get_map_id()) ) return False @@ -769,19 +754,15 @@ def write_timestamp_to_grass(self): if check == -1: self.msgr.error( - _( - "Unable to create timestamp file " - "for 3D raster map <%s>" % (self.get_map_id()) - ) + _("Unable to create timestamp file for 3D raster map <%s>") + % (self.get_map_id()) ) return False if check == -2: self.msgr.error( - _( - "Invalid datetime in timestamp for 3D raster " - "map <%s>" % (self.get_map_id()) - ) + _("Invalid datetime in timestamp for 3D raster map <%s>") + % (self.get_map_id()) ) return False @@ -802,10 +783,7 @@ def remove_timestamp_from_grass(self): if check == -1: self.msgr.error( - _( - "Unable to remove timestamp for raster map " - "<%s>" % (self.get_name()) - ) + _("Unable to remove timestamp for raster map <%s>") % (self.get_name()) ) return False @@ -1091,10 +1069,8 @@ def read_timestamp_from_grass(self): if check < 1: self.msgr.error( - _( - "Unable to read timestamp file " - "for vector map <%s>" % (self.get_map_id()) - ) + _("Unable to read timestamp file for vector map <%s>") + % (self.get_map_id()) ) return False @@ -1120,19 +1096,15 @@ def write_timestamp_to_grass(self): if check == -1: self.msgr.error( - _( - "Unable to create timestamp file " - "for vector map <%s>" % (self.get_map_id()) - ) + _("Unable to create timestamp file for vector map <%s>") + % (self.get_map_id()) ) return False if check == -2: self.msgr.error( - _( - "Invalid datetime in timestamp for vector " - "map <%s>" % (self.get_map_id()) - ) + _("Invalid datetime in timestamp for vector map <%s>") + % (self.get_map_id()) ) return False @@ -1148,9 +1120,8 @@ def remove_timestamp_from_grass(self): if check == -1: self.msgr.error( - _( - "Unable to remove timestamp for vector " - "map <%s>" % (self.get_name()) + _("Unable to remove timestamp for vector map <%s>").format( + self.get_name() ) ) return False @@ -1410,16 +1381,14 @@ def spatial_overlapping(self, dataset): if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds": return self.spatial_extent.overlapping(dataset.spatial_extent) - else: - return self.spatial_extent.overlapping_2d(dataset.spatial_extent) + return self.spatial_extent.overlapping_2d(dataset.spatial_extent) def spatial_relation(self, dataset): """Return the two or three dimensional spatial relation""" if self.get_type() == dataset.get_type() or dataset.get_type() == "str3ds": return self.spatial_extent.spatial_relation(dataset.spatial_extent) - else: - return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent) + return self.spatial_extent.spatial_relation_2d(dataset.spatial_extent) def spatial_intersection(self, dataset): """Return the three or two dimensional intersection as spatial_extent @@ -1430,8 +1399,7 @@ def spatial_intersection(self, dataset): """ if self.get_type() == dataset.get_type() or dataset.get_type() == "raster3d": return self.spatial_extent.intersect(dataset.spatial_extent) - else: - return self.spatial_extent.intersect_2d(dataset.spatial_extent) + return self.spatial_extent.intersect_2d(dataset.spatial_extent) def spatial_union(self, dataset): """Return the three or two dimensional union as spatial_extent @@ -1442,8 +1410,7 @@ def spatial_union(self, dataset): """ if self.get_type() == dataset.get_type() or dataset.get_type() == "raster3d": return self.spatial_extent.union(dataset.spatial_extent) - else: - return self.spatial_extent.union_2d(dataset.spatial_extent) + return self.spatial_extent.union_2d(dataset.spatial_extent) def spatial_disjoint_union(self, dataset): """Return the three or two dimensional union as spatial_extent object. @@ -1453,8 +1420,7 @@ def spatial_disjoint_union(self, dataset): """ if self.get_type() == dataset.get_type() or dataset.get_type() == "raster3d": return self.spatial_extent.disjoint_union(dataset.spatial_extent) - else: - return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent) + return self.spatial_extent.disjoint_union_2d(dataset.spatial_extent) def reset(self, ident): """Reset the internal structure and set the identifier""" diff --git a/python/grass/temporal/spatial_extent.py b/python/grass/temporal/spatial_extent.py index 329a0a4a684..7bec3bc35e7 100644 --- a/python/grass/temporal/spatial_extent.py +++ b/python/grass/temporal/spatial_extent.py @@ -875,7 +875,7 @@ def cover_2d(self, extent) -> bool: if eS > S and eS < N: edge_count += 1 - return not edge_count == 0 + return edge_count != 0 def cover(self, extent) -> bool: """Return True if this extent covers the provided spatial @@ -956,7 +956,7 @@ def cover(self, extent) -> bool: if eB > B and eB < T: edge_count += 1 - return not edge_count == 0 + return edge_count != 0 def covered_2d(self, extent): """Return True if this extent is covered by the provided spatial @@ -1787,8 +1787,7 @@ def get_id(self): """ if "id" in self.D: return self.D["id"] - else: - return None + return None def get_projection(self): """Get the projection of the spatial extent""" @@ -1840,48 +1839,42 @@ def get_north(self): :return: None if not found""" if "north" in self.D: return self.D["north"] - else: - return None + return None def get_south(self): """Get the southern edge of the map :return: None if not found""" if "south" in self.D: return self.D["south"] - else: - return None + return None def get_east(self): """Get the eastern edge of the map :return: None if not found""" if "east" in self.D: return self.D["east"] - else: - return None + return None def get_west(self): """Get the western edge of the map :return: None if not found""" if "west" in self.D: return self.D["west"] - else: - return None + return None def get_top(self): """Get the top edge of the map :return: None if not found""" if "top" in self.D: return self.D["top"] - else: - return None + return None def get_bottom(self): """Get the bottom edge of the map :return: None if not found""" if "bottom" in self.D: return self.D["bottom"] - else: - return None + return None id = property(fget=get_id, fset=set_id) north = property(fget=get_north, fset=set_north) diff --git a/python/grass/temporal/stds_export.py b/python/grass/temporal/stds_export.py index 70dbdcada0f..a01b94e1071 100644 --- a/python/grass/temporal/stds_export.py +++ b/python/grass/temporal/stds_export.py @@ -127,7 +127,7 @@ def _export_raster_maps_as_gdal( except CalledModuleError: shutil.rmtree(new_cwd) tar.close() - gs.fatal(_("Unable to export raster map <%s>" % name)) + gs.fatal(_("Unable to export raster map <%s>") % name) tar.add(out_name) @@ -139,10 +139,7 @@ def _export_raster_maps_as_gdal( shutil.rmtree(new_cwd) tar.close() gs.fatal( - _( - "Unable to export color rules for raster " - "map <%s> r.out.gdal" % name - ) + _("Unable to export color rules for raster map <%s> r.out.gdal") % name ) tar.add(out_name) @@ -168,7 +165,7 @@ def _export_raster_maps(rows, tar, list_file, new_cwd, fs): except CalledModuleError: shutil.rmtree(new_cwd) tar.close() - gs.fatal(_("Unable to export raster map <%s> with r.pack" % name)) + gs.fatal(_("Unable to export raster map <%s> with r.pack") % name) tar.add(name + ".pack") @@ -201,7 +198,7 @@ def _export_vector_maps_as_gml(rows, tar, list_file, new_cwd, fs): except CalledModuleError: shutil.rmtree(new_cwd) tar.close() - gs.fatal(_("Unable to export vector map <%s> as GML with v.out.ogr" % name)) + gs.fatal(_("Unable to export vector map <%s> as GML with v.out.ogr") % name) tar.add(name + ".xml") tar.add(name + ".xsd") @@ -236,7 +233,7 @@ def _export_vector_maps_as_gpkg(rows, tar, list_file, new_cwd, fs): shutil.rmtree(new_cwd) tar.close() gs.fatal( - _("Unable to export vector map <%s> as GPKG with v.out.ogr" % name) + _("Unable to export vector map <%s> as GPKG with v.out.ogr") % name ) tar.add(name + ".gpkg") @@ -269,7 +266,7 @@ def _export_vector_maps(rows, tar, list_file, new_cwd, fs): except CalledModuleError: shutil.rmtree(new_cwd) tar.close() - gs.fatal(_("Unable to export vector map <%s> with v.pack" % name)) + gs.fatal(_("Unable to export vector map <%s> with v.pack") % name) tar.add(name + ".pack") @@ -295,7 +292,7 @@ def _export_raster3d_maps(rows, tar, list_file, new_cwd, fs): except CalledModuleError: shutil.rmtree(new_cwd) tar.close() - gs.fatal(_("Unable to export raster map <%s> with r3.pack" % name)) + gs.fatal(_("Unable to export raster map <%s> with r3.pack") % name) tar.add(name + ".pack") @@ -351,7 +348,7 @@ def export_stds( """ # Save current working directory path - old_cwd = os.getcwd() + old_cwd = Path.cwd() # Create the temporary directory and jump into it new_cwd = tempfile.mkdtemp(dir=directory) diff --git a/python/grass/temporal/stds_import.py b/python/grass/temporal/stds_import.py index 03810e49b89..006ee6a387e 100644 --- a/python/grass/temporal/stds_import.py +++ b/python/grass/temporal/stds_import.py @@ -254,10 +254,8 @@ def import_stds( # Check for important files msgr = get_tgis_message_interface() msgr.message( - _( - "Checking validity of input file (size: %0.1f MB). Make take a while..." - % (os.path.getsize(input) / (1024 * 1024.0)) - ) + _("Checking validity of input file (size: %0.1f MB). Make take a while...") + % (os.path.getsize(input) / (1024 * 1024.0)) ) members = tar.getnames() # Make sure that the basenames of the files are used for comparison @@ -288,7 +286,7 @@ def import_stds( # We use a new list file name for map registration new_list_file_name = list_file_name + "_new" # Save current working directory path - old_cwd = os.getcwd() + old_cwd = Path.cwd() # Switch into the data directory os.chdir(directory) @@ -374,7 +372,7 @@ def import_stds( fs = "|" maplist = [] mapset = get_current_mapset() - list_file = open(list_file_name, "r") + list_file = open(list_file_name) new_list_file = open(new_list_file_name, "w") # get number of lines to correctly form the suffix @@ -428,7 +426,7 @@ def import_stds( # Read the init file fs = "=" init = {} - init_file = open(init_file_name, "r") + init_file = open(init_file_name) while True: line = init_file.readline() if not line: diff --git a/python/grass/temporal/temporal_algebra.py b/python/grass/temporal/temporal_algebra.py index 3736a15315a..a27fa91cd1d 100644 --- a/python/grass/temporal/temporal_algebra.py +++ b/python/grass/temporal/temporal_algebra.py @@ -727,11 +727,11 @@ def get_type(self): and self.value is not None ): return "global" - elif self.boolean is not None: + if self.boolean is not None: return "boolean" - elif self.relationop is not None and self.topology != []: + if self.relationop is not None and self.topology != []: return "operator" - elif self.td is not None: + if self.td is not None: return "timediff" def get_type_value(self): @@ -992,10 +992,7 @@ def generate_map_name(self): same object for map name generation in multiple threads. """ self.count += 1 - if self.pid is not None: - pid = self.pid - else: - pid = os.getpid() + pid = self.pid if self.pid is not None else os.getpid() name = "tmp_map_name_%i_%i" % (pid, self.count) self.names[name] = name return name @@ -1159,11 +1156,7 @@ def set_temporal_extent_list(self, maplist, topolist=["EQUAL"], temporal="l"): if returncode == 0: break # Append map to result map list. - elif returncode == 1: - # print(map_new.get_id() + " " + - # str(map_new.get_temporal_extent_as_tuple())) - # print(map_new.condition_value) - # print(map_new.cmd_list) + if returncode == 1: # resultlist.append(map_new) resultdict[map_new.get_id()] = map_new @@ -1195,7 +1188,7 @@ def remove_maps(self): for key, value in map_names.items(): if value: - self.msgr.message(_("Removing un-needed or empty %s maps" % (key))) + self.msgr.message(_("Removing un-needed or empty %s maps") % (key)) self._remove_maps(value, key) def _remove_maps(self, namelist, map_type): @@ -1234,10 +1227,7 @@ def check_stds(self, input, clear=False, stds_type=None, check_type=True): """ if isinstance(input, str): # Check for mapset in given stds input. - if input.find("@") >= 0: - id_input = input - else: - id_input = input + "@" + self.mapset + id_input = input if input.find("@") >= 0 else input + "@" + self.mapset # Create empty spacetime dataset. if stds_type: stds = dataset_factory(stds_type, id_input) @@ -1249,48 +1239,41 @@ def check_stds(self, input, clear=False, stds_type=None, check_type=True): _("Space time %s dataset <%s> not found") % (stds.get_new_map_instance(None).get_type(), id_input) ) + # Select temporal dataset entry from database. + stds.select(dbif=self.dbif) + if self.use_granularity: + # We create the maplist out of the map array from none-gap objects + maplist = [] + map_array = stds.get_registered_maps_as_objects_by_granularity( + gran=self.granularity, dbif=self.dbif + ) + for entry in map_array: + # Ignore gap objects + if entry[0].get_id() is not None: + maplist.append(entry[0]) else: - # Select temporal dataset entry from database. - stds.select(dbif=self.dbif) - if self.use_granularity: - # We create the maplist out of the map array from none-gap objects - maplist = [] - map_array = stds.get_registered_maps_as_objects_by_granularity( - gran=self.granularity, dbif=self.dbif - ) - for entry in map_array: - # Ignore gap objects - if entry[0].get_id() is not None: - maplist.append(entry[0]) - else: - maplist = stds.get_registered_maps_as_objects(dbif=self.dbif) - # Create map_value as empty list item. - for map_i in maplist: - if "map_value" not in dir(map_i): - map_i.map_value = [] - if "condition_value" not in dir(map_i): - map_i.condition_value = [] - # Set and check global temporal type variable and map. - if map_i.is_time_absolute() and self.temporaltype is None: - self.temporaltype = "absolute" - elif map_i.is_time_relative() and self.temporaltype is None: - self.temporaltype = "relative" - elif map_i.is_time_absolute() and self.temporaltype == "relative": - self.msgr.fatal( - _( - "Wrong temporal type of space time dataset " - "<%s> <%s> time is required" - ) - % (id_input, self.temporaltype) - ) - elif map_i.is_time_relative() and self.temporaltype == "absolute": - self.msgr.fatal( - _( - "Wrong temporal type of space time dataset " - "<%s> <%s> time is required" - ) - % (id_input, self.temporaltype) + maplist = stds.get_registered_maps_as_objects(dbif=self.dbif) + # Create map_value as empty list item. + for map_i in maplist: + if "map_value" not in dir(map_i): + map_i.map_value = [] + if "condition_value" not in dir(map_i): + map_i.condition_value = [] + # Set and check global temporal type variable and map. + if map_i.is_time_absolute() and self.temporaltype is None: + self.temporaltype = "absolute" + elif map_i.is_time_relative() and self.temporaltype is None: + self.temporaltype = "relative" + elif (map_i.is_time_absolute() and self.temporaltype == "relative") or ( + map_i.is_time_relative() and self.temporaltype == "absolute" + ): + self.msgr.fatal( + _( + "Wrong temporal type of space time dataset " + "<%s> <%s> time is required" ) + % (id_input, self.temporaltype) + ) elif isinstance(input, self.mapclass): # Check if the input is a single map and return it as list with one entry. maplist = [input] @@ -1299,13 +1282,9 @@ def check_stds(self, input, clear=False, stds_type=None, check_type=True): maplist = input # Create map_value as empty list item. for map_i in maplist: - if "map_value" not in dir(map_i): + if ("map_value" not in dir(map_i)) or clear: map_i.map_value = [] - elif clear: - map_i.map_value = [] - if "condition_value" not in dir(map_i): - map_i.condition_value = [] - elif clear: + if ("condition_value" not in dir(map_i)) or clear: map_i.condition_value = [] else: self.msgr.fatal(_("Wrong type of input " + str(input))) @@ -1644,7 +1623,7 @@ def build_spatio_temporal_topology_list( def assign_bool_value( self, map_i, temporal_topo_list=["EQUAL"], spatial_topo_list=[] - ): + ) -> bool: """Function to assign boolean map value based on the map_values from the compared map list by topological relationships. @@ -1678,10 +1657,7 @@ def assign_bool_value( str(relationmap.get_temporal_extent_as_tuple()) + str(boolean), ) - if all(condition_value_list): - resultbool = True - else: - resultbool = False + resultbool = bool(all(condition_value_list)) map_i.condition_value = [resultbool] return resultbool @@ -2306,20 +2282,14 @@ def recurse_compare(conditionlist): ele_index = conditionlist.index(ele) right = conditionlist.pop(ele_index) left = conditionlist.pop(ele_index - 2) - if any([left, right]): - result = True - else: - result = False + result = bool(any([left, right])) conditionlist[ele_index - 2] = result recurse_compare(conditionlist) if ele == "&&": ele_index = conditionlist.index(ele) right = conditionlist.pop(ele_index) left = conditionlist.pop(ele_index - 2) - if all([left, right]): - result = True - else: - result = False + result = bool(all([left, right])) conditionlist[ele_index - 2] = result recurse_compare(conditionlist) @@ -2346,8 +2316,7 @@ def recurse_compare(conditionlist): inverselist.append(map_i) if inverse: return inverselist - else: - return resultlist + return resultlist def p_statement_assign(self, t): # The expression should always return a list of maps @@ -2392,8 +2361,8 @@ def p_statement_assign(self, t): _( "The resulting space time dataset type <%(a)s> " "is different from the requested type <%(b)s>" - % ({"a": maps_stds_type, "b": self.stdstype}) ) + % ({"a": maps_stds_type, "b": self.stdstype}) ) else: map_type_2 = map_i.get_type() @@ -2654,10 +2623,7 @@ def p_expr_tmap_function(self, t): input = t[3] if not isinstance(input, list): # Check for mapset in given stds input. - if input.find("@") >= 0: - id_input = input - else: - id_input = input + "@" + self.mapset + id_input = input if input.find("@") >= 0 else input + "@" + self.mapset # Create empty map dataset. map_i = dataset_factory(self.maptype, id_input) # Check for occurrence of space time dataset. @@ -2666,9 +2632,9 @@ def p_expr_tmap_function(self, t): _("%s map <%s> not found in GRASS spatial database") % (map_i.get_type(), id_input) ) - else: - # Select dataset entry from database. - map_i.select(dbif=self.dbif) + + # Select dataset entry from database. + map_i.select(dbif=self.dbif) else: raise FatalError( _( @@ -3090,10 +3056,7 @@ def p_expr_t_select_operator(self, t): # Evaluate temporal operator. operators = self.eval_toperator(t[2], optype="select") # Check for negative selection. - if operators[2] == "!:": - negation = True - else: - negation = False + negation = operators[2] == "!:" # Perform selection. selectlist = self.perform_temporal_selection( maplistA, maplistB, topolist=operators[0], inverse=negation @@ -3415,8 +3378,7 @@ def p_error(self, t): "syntax error on line %d, position %i token %s near '%s' expression " "'%s'" % (t.lineno, t.lexpos, t.type, t.value, self.expression) ) - else: - raise SyntaxError("Unexpected syntax error") + raise SyntaxError("Unexpected syntax error") if __name__ == "__main__": diff --git a/python/grass/temporal/temporal_extent.py b/python/grass/temporal/temporal_extent.py index 42cce4599b1..29594ea8b72 100644 --- a/python/grass/temporal/temporal_extent.py +++ b/python/grass/temporal/temporal_extent.py @@ -202,9 +202,9 @@ def intersect(self, extent): return RelativeTemporalExtent( start_time=start, end_time=end, unit=self.get_unit() ) - elif issubclass(type(self), AbsoluteTemporalExtent): + if issubclass(type(self), AbsoluteTemporalExtent): return AbsoluteTemporalExtent(start_time=start, end_time=end) - elif issubclass(type(self), TemporalExtent): + if issubclass(type(self), TemporalExtent): return TemporalExtent(start_time=start, end_time=end) def disjoint_union(self, extent): @@ -391,9 +391,9 @@ def disjoint_union(self, extent): return RelativeTemporalExtent( start_time=start, end_time=end, unit=self.get_unit() ) - elif issubclass(type(self), AbsoluteTemporalExtent): + if issubclass(type(self), AbsoluteTemporalExtent): return AbsoluteTemporalExtent(start_time=start, end_time=end) - elif issubclass(type(self), TemporalExtent): + if issubclass(type(self), TemporalExtent): return TemporalExtent(start_time=start, end_time=end) def union(self, extent): @@ -986,24 +986,21 @@ def get_id(self): """ if "id" in self.D: return self.D["id"] - else: - return None + return None def get_start_time(self): """Get the valid start time of the extent :return: None if not found""" if "start_time" in self.D: return self.D["start_time"] - else: - return None + return None def get_end_time(self): """Get the valid end time of the extent :return: None if not found""" if "end_time" in self.D: return self.D["end_time"] - else: - return None + return None # Set the properties id = property(fget=get_id, fset=set_id) @@ -1153,8 +1150,7 @@ def get_granularity(self): :return: None if not found""" if "granularity" in self.D: return self.D["granularity"] - else: - return None + return None def get_map_time(self): """Get the type of the map time @@ -1169,8 +1165,7 @@ def get_map_time(self): """ if "map_time" in self.D: return self.D["map_time"] - else: - return None + return None # Properties granularity = property(fget=get_granularity, fset=set_granularity) @@ -1277,8 +1272,7 @@ def get_unit(self): :return: None if not found""" if "unit" in self.D: return self.D["unit"] - else: - return None + return None def temporal_relation(self, map): """Returns the temporal relation between temporal objects @@ -1427,8 +1421,7 @@ def get_granularity(self): :return: None if not found""" if "granularity" in self.D: return self.D["granularity"] - else: - return None + return None def get_map_time(self): """Get the type of the map time @@ -1443,8 +1436,7 @@ def get_map_time(self): """ if "map_time" in self.D: return self.D["map_time"] - else: - return None + return None # Properties granularity = property(fget=get_granularity, fset=set_granularity) diff --git a/python/grass/temporal/temporal_granularity.py b/python/grass/temporal/temporal_granularity.py index c3920b8b00b..173e4e715ea 100644 --- a/python/grass/temporal/temporal_granularity.py +++ b/python/grass/temporal/temporal_granularity.py @@ -146,8 +146,7 @@ def _get_row_time_tuple(db_table_row): # Check if input is list of MapDataset objects or SQLite rows if issubclass(maps[0].__class__, AbstractMapDataset): return _get_map_time_tuple - else: - return _get_row_time_tuple + return _get_row_time_tuple def _is_after(start, start1, end1) -> bool: @@ -495,7 +494,7 @@ def compute_absolute_time_granularity(maps): # Keep the temporal extent to compare to the following/next map previous_start, previous_end = start, end - # Create a list with a single time unit only + # Create a set with a single time unit only dlist = set() assigned_time_unit = None time_unit_multipliers = { @@ -530,11 +529,8 @@ def compute_absolute_time_granularity(maps): if not dlist: return None - if len(dlist) > 1: - # Find greatest common divisor - granularity = gcd_list(dlist) - else: - granularity = dlist.pop() + # Find greatest common divisor to get a single time unit + granularity = gcd_list(dlist) if len(dlist) > 1 else dlist.pop() if granularity is None: return None @@ -777,8 +773,7 @@ def compute_common_absolute_time_granularity(gran_list, start_date_list=None): if int(num) > 60: if int(num) % 60 == 0: return "60 seconds" - else: - return "1 second" + return "1 second" if granule in {"minutes", "minute"}: # If the start minutes are different between the start dates @@ -790,8 +785,7 @@ def compute_common_absolute_time_granularity(gran_list, start_date_list=None): if int(num) > 60: if int(num) % 60 == 0: return "60 minutes" - else: - return "1 minute" + return "1 minute" if granule in {"hours", "hour"}: # If the start hours are different between the start dates @@ -803,8 +797,7 @@ def compute_common_absolute_time_granularity(gran_list, start_date_list=None): if int(num) > 24: if int(num) % 24 == 0: return "24 hours" - else: - return "1 hour" + return "1 hour" if granule in {"days", "day"}: # If the start days are different between the start dates @@ -816,8 +809,7 @@ def compute_common_absolute_time_granularity(gran_list, start_date_list=None): if int(num) > 365: if int(num) % 365 == 0: return "365 days" - else: - return "1 day" + return "1 day" if granule in {"months", "month"}: # If the start months are different between the start dates @@ -829,8 +821,7 @@ def compute_common_absolute_time_granularity(gran_list, start_date_list=None): if int(num) > 12: if int(num) % 12 == 0: return "12 months" - else: - return "1 month" + return "1 month" return common_granule @@ -1125,20 +1116,18 @@ def gran_singular_unit(gran): output, unit = gran.split(" ") if unit in PLURAL_GRAN: return unit[:-1] - elif unit in SINGULAR_GRAN: + if unit in SINGULAR_GRAN: return unit - else: - lists = "{gr}".format(gr=SUPPORTED_GRAN).replace("[", "").replace("]", "") - print( - _( - "Output granularity seems not to be valid. Please use " - "one of the following values : {gr}" - ).format(gr=lists) - ) - return False - else: - print(_("Invalid absolute granularity")) + lists = "{gr}".format(gr=SUPPORTED_GRAN).replace("[", "").replace("]", "") + print( + _( + "Output granularity seems not to be valid. Please use " + "one of the following values : {gr}" + ).format(gr=lists) + ) return False + print(_("Invalid absolute granularity")) + return False ####################################################################### @@ -1170,16 +1159,15 @@ def gran_plural_unit(gran): output, unit = gran.split(" ") if unit in PLURAL_GRAN: return unit - elif unit in SINGULAR_GRAN: + if unit in SINGULAR_GRAN: return f"{unit}s" - else: - lists = ", ".join(SUPPORTED_GRAN) - print( - _( - "Output granularity seems not to be valid. Please use " - "one of the following values : {gr}" - ).format(gr=lists) - ) + lists = ", ".join(SUPPORTED_GRAN) + print( + _( + "Output granularity seems not to be valid. Please use " + "one of the following values : {gr}" + ).format(gr=lists) + ) else: print(_("Invalid absolute granularity")) return False @@ -1234,8 +1222,7 @@ def _return(output, tounit, shell): if output == 1: return f"{output} {tounit}" - else: - return f"{output} {tounit}s" + return f"{output} {tounit}s" # TODO check the leap second if check_granularity_string(from_gran, "absolute"): @@ -1256,9 +1243,8 @@ def _return(output, tounit, shell): return _return(output, tounit, shell) print(_("Probably you need to invert 'from_gran' and 'to_gran'")) return False - else: - print(_("Invalid absolute granularity")) - return False + print(_("Invalid absolute granularity")) + return False ############################################################################### diff --git a/python/grass/temporal/temporal_operator.py b/python/grass/temporal/temporal_operator.py index 7d91ed0f65c..d99244c7c49 100644 --- a/python/grass/temporal/temporal_operator.py +++ b/python/grass/temporal/temporal_operator.py @@ -352,16 +352,16 @@ def p_relation_operator(self, t): # Check for correct type. if not self.optype == "relation": raise SyntaxError('Wrong optype "%s" must be "relation"' % self.optype) + + # Set three operator components. + if isinstance(t[2], list): + self.relations = t[2] else: - # Set three operator components. - if isinstance(t[2], list): - self.relations = t[2] - else: - self.relations = [t[2]] - self.temporal = None - self.function = None + self.relations = [t[2]] + self.temporal = None + self.function = None - t[0] = t[2] + t[0] = t[2] def p_relation_bool_operator(self, t): # {||, during} @@ -374,17 +374,17 @@ def p_relation_bool_operator(self, t): """ if not self.optype == "boolean": raise SyntaxError('Wrong optype "%s" must be "boolean"' % self.optype) + + # Set three operator components. + if isinstance(t[5], list): + self.relations = t[5] else: - # Set three operator components. - if isinstance(t[5], list): - self.relations = t[5] - else: - self.relations = [t[5]] - self.temporal = "l" - self.function = t[2] + t[3] - self.aggregate = t[2] + self.relations = [t[5]] + self.temporal = "l" + self.function = t[2] + t[3] + self.aggregate = t[2] - t[0] = t[2] + t[0] = t[2] def p_relation_bool_combi_operator(self, t): # {||, during, &} @@ -401,17 +401,17 @@ def p_relation_bool_combi_operator(self, t): """ if not self.optype == "boolean": raise SyntaxError('Wrong optype "%s" must be "boolean"' % self.optype) + + # Set three operator components. + if isinstance(t[5], list): + self.relations = t[5] else: - # Set three operator components. - if isinstance(t[5], list): - self.relations = t[5] - else: - self.relations = [t[5]] - self.temporal = "l" - self.function = t[2] + t[3] - self.aggregate = t[7] + self.relations = [t[5]] + self.temporal = "l" + self.function = t[2] + t[3] + self.aggregate = t[7] - t[0] = t[2] + t[0] = t[2] def p_relation_bool_combi_operator2(self, t): # {||, during, left} @@ -424,17 +424,17 @@ def p_relation_bool_combi_operator2(self, t): """ if not self.optype == "boolean": raise SyntaxError('Wrong optype "%s" must be "boolean"' % self.optype) + + # Set three operator components. + if isinstance(t[5], list): + self.relations = t[5] else: - # Set three operator components. - if isinstance(t[5], list): - self.relations = t[5] - else: - self.relations = [t[5]] - self.temporal = t[7] - self.function = t[2] + t[3] - self.aggregate = t[2] + self.relations = [t[5]] + self.temporal = t[7] + self.function = t[2] + t[3] + self.aggregate = t[2] - t[0] = t[2] + t[0] = t[2] def p_relation_bool_combi_operator3(self, t): # {||, during, |, left} @@ -451,17 +451,17 @@ def p_relation_bool_combi_operator3(self, t): """ if not self.optype == "boolean": raise SyntaxError('Wrong optype "%s" must be "relation"' % self.optype) + + # Set three operator components. + if isinstance(t[5], list): + self.relations = t[5] else: - # Set three operator components. - if isinstance(t[5], list): - self.relations = t[5] - else: - self.relations = [t[5]] - self.temporal = t[9] - self.function = t[2] + t[3] - self.aggregate = t[7] + self.relations = [t[5]] + self.temporal = t[9] + self.function = t[2] + t[3] + self.aggregate = t[7] - t[0] = t[2] + t[0] = t[2] def p_select_relation_operator(self, t): # {!:} @@ -477,27 +477,28 @@ def p_select_relation_operator(self, t): """ if not self.optype == "select": raise SyntaxError('Wrong optype "%s" must be "select"' % self.optype) - else: - if len(t) == 4: - # Set three operator components. - self.relations = ["equal", "equivalent"] - self.temporal = "l" - self.function = t[2] - elif len(t) == 6: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = "l" - self.function = t[2] - elif len(t) == 8: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = t[6] - self.function = t[2] - t[0] = t[2] + + if len(t) == 4: + # Set three operator components. + self.relations = ["equal", "equivalent"] + self.temporal = "l" + self.function = t[2] + elif len(t) == 6: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = "l" + self.function = t[2] + elif len(t) == 8: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = t[6] + self.function = t[2] + + t[0] = t[2] def p_hash_relation_operator(self, t): # {#} @@ -513,27 +514,28 @@ def p_hash_relation_operator(self, t): """ if not self.optype == "hash": raise SyntaxError('Wrong optype "%s" must be "hash"' % self.optype) - else: - if len(t) == 4: - # Set three operator components. - self.relations = ["equal"] - self.temporal = "l" - self.function = t[2] - elif len(t) == 6: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = "l" - self.function = t[2] - elif len(t) == 8: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = t[6] - self.function = t[2] - t[0] = t[2] + + if len(t) == 4: + # Set three operator components. + self.relations = ["equal"] + self.temporal = "l" + self.function = t[2] + elif len(t) == 6: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = "l" + self.function = t[2] + elif len(t) == 8: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = t[6] + self.function = t[2] + + t[0] = t[2] def p_raster_relation_operator(self, t): # {+} @@ -549,27 +551,28 @@ def p_raster_relation_operator(self, t): """ if not self.optype == "raster": raise SyntaxError('Wrong optype "%s" must be "raster"' % self.optype) - else: - if len(t) == 4: - # Set three operator components. - self.relations = ["equal"] - self.temporal = "l" - self.function = t[2] - elif len(t) == 6: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = "l" - self.function = t[2] - elif len(t) == 8: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = t[6] - self.function = t[2] - t[0] = t[2] + + if len(t) == 4: + # Set three operator components. + self.relations = ["equal"] + self.temporal = "l" + self.function = t[2] + elif len(t) == 6: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = "l" + self.function = t[2] + elif len(t) == 8: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = t[6] + self.function = t[2] + + t[0] = t[2] def p_overlay_relation_operator(self, t): # {+} @@ -585,27 +588,28 @@ def p_overlay_relation_operator(self, t): """ if not self.optype == "overlay": raise SyntaxError('Wrong optype "%s" must be "overlay"' % self.optype) - else: - if len(t) == 4: - # Set three operator components. - self.relations = ["equal"] - self.temporal = "l" - self.function = t[2] - elif len(t) == 6: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = "l" - self.function = t[2] - elif len(t) == 8: - if isinstance(t[4], list): - self.relations = t[4] - else: - self.relations = [t[4]] - self.temporal = t[6] - self.function = t[2] - t[0] = t[2] + + if len(t) == 4: + # Set three operator components. + self.relations = ["equal"] + self.temporal = "l" + self.function = t[2] + elif len(t) == 6: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = "l" + self.function = t[2] + elif len(t) == 8: + if isinstance(t[4], list): + self.relations = t[4] + else: + self.relations = [t[4]] + self.temporal = t[6] + self.function = t[2] + + t[0] = t[2] def p_relation(self, t): # The list of relations. Temporal and spatial relations are supported diff --git a/python/grass/temporal/temporal_raster_base_algebra.py b/python/grass/temporal/temporal_raster_base_algebra.py index 76517db30cc..bb58c8405f7 100644 --- a/python/grass/temporal/temporal_raster_base_algebra.py +++ b/python/grass/temporal/temporal_raster_base_algebra.py @@ -610,7 +610,7 @@ def set_temporal_extent_list( if returncode == 0: break # Append map to result map list. - elif returncode == 1: + if returncode == 1: # print(map_new.cmd_list) # resultlist.append(map_new) if cmd_bool: @@ -727,7 +727,7 @@ def build_condition_cmd_list( # Append map to result map list. resultlist.append(map_i) return resultlist - elif isinstance(conclusionlist, list): + if isinstance(conclusionlist, list): # Build result command map list between conditions and conclusions. if self.debug: print("build_condition_cmd_list", condition_topolist) @@ -873,7 +873,7 @@ def p_statement_assign(self, t): process_queue.put(m) else: - self.msgr.error(_("Error computing map <%s>" % map_i.get_id())) + self.msgr.error(_("Error computing map <%s>") % map_i.get_id()) count += 1 if self.dry_run is False: @@ -960,10 +960,7 @@ def p_expr_spmap_function(self, t): input = t[3] if not isinstance(input, list): # Check for mapset in given stds input. - if input.find("@") >= 0: - id_input = input - else: - id_input = input + "@" + self.mapset + id_input = input if input.find("@") >= 0 else input + "@" + self.mapset # Create empty map dataset. map_i = dataset_factory(self.maptype, id_input) # Check for occurrence of space time dataset. @@ -972,12 +969,11 @@ def p_expr_spmap_function(self, t): _("%s map <%s> not found in GRASS spatial database") % (map_i.get_type(), id_input) ) - else: - # Select dataset entry from database. - map_i.select(dbif=self.dbif) - # Create command list for map object. - cmdstring = "(%s)" % (map_i.get_map_id()) - map_i.cmd_list = cmdstring + # Select dataset entry from database. + map_i.select(dbif=self.dbif) + # Create command list for map object. + cmdstring = "(%s)" % (map_i.get_map_id()) + map_i.cmd_list = cmdstring # Return map object. t[0] = cmdstring else: diff --git a/python/grass/temporal/temporal_vector_algebra.py b/python/grass/temporal/temporal_vector_algebra.py index 551c69783f5..2f28da0c7e5 100644 --- a/python/grass/temporal/temporal_vector_algebra.py +++ b/python/grass/temporal/temporal_vector_algebra.py @@ -386,7 +386,7 @@ def set_temporal_extent_list(self, maplist, topolist=["EQUAL"], temporal="l"): if returncode == 0: break # Append map to result map list. - elif returncode == 1: + if returncode == 1: # resultlist.append(map_new) resultdict[map_new.get_id()] = map_new if returncode == 0: diff --git a/python/grass/temporal/testsuite/unittests_temporal_algebra_grs.py b/python/grass/temporal/testsuite/unittests_temporal_algebra_grs.py index 7e0db57a8ce..d7a81bcb34d 100644 --- a/python/grass/temporal/testsuite/unittests_temporal_algebra_grs.py +++ b/python/grass/temporal/testsuite/unittests_temporal_algebra_grs.py @@ -8,7 +8,6 @@ """ import datetime -import os import grass.temporal as tgis from grass.gunittest.case import TestCase diff --git a/python/grass/temporal/testsuite/unittests_temporal_algebra_mixed_stds.py b/python/grass/temporal/testsuite/unittests_temporal_algebra_mixed_stds.py index cf0e9c82bb7..ce911839049 100644 --- a/python/grass/temporal/testsuite/unittests_temporal_algebra_mixed_stds.py +++ b/python/grass/temporal/testsuite/unittests_temporal_algebra_mixed_stds.py @@ -8,7 +8,6 @@ """ import datetime -import os import grass.temporal as tgis from grass.gunittest.case import TestCase diff --git a/python/grass/temporal/testsuite/unittests_temporal_conditionals.py b/python/grass/temporal/testsuite/unittests_temporal_conditionals.py index ff0703aec1d..800c7d30bf6 100644 --- a/python/grass/temporal/testsuite/unittests_temporal_conditionals.py +++ b/python/grass/temporal/testsuite/unittests_temporal_conditionals.py @@ -8,7 +8,6 @@ """ import datetime -import os import grass.temporal as tgis from grass.gunittest.case import TestCase diff --git a/python/grass/temporal/testsuite/unittests_temporal_raster_algebra_equal_ts.py b/python/grass/temporal/testsuite/unittests_temporal_raster_algebra_equal_ts.py index 92397cd825c..f96ed12899f 100644 --- a/python/grass/temporal/testsuite/unittests_temporal_raster_algebra_equal_ts.py +++ b/python/grass/temporal/testsuite/unittests_temporal_raster_algebra_equal_ts.py @@ -12,6 +12,7 @@ import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows class TestTemporalRasterAlgebraImplicitAggregation(TestCase): @@ -64,6 +65,7 @@ def tearDownClass(cls): cls.runModule("t.unregister", maps="singletmap", quiet=True) cls.del_temp_region() + @xfail_windows def test_simple_operator(self): """Test implicit aggregation @@ -149,6 +151,7 @@ def test_single_map_complex_operator(self): self.assertEqual(D.check_temporal_topology(), True) self.assertEqual(D.get_granularity(), None) + @xfail_windows def test_single_map_simple_operator(self): """Test implicit aggregation diff --git a/python/grass/temporal/univar_statistics.py b/python/grass/temporal/univar_statistics.py index 9bf29f74eba..b6a9c1ac508 100755 --- a/python/grass/temporal/univar_statistics.py +++ b/python/grass/temporal/univar_statistics.py @@ -65,12 +65,9 @@ def compute_univar_stats(registered_map_info, stats_module, fs, rast_region=Fals if not univar_stats: gs.warning( - _( - "Unable to get statistics for {voxel}raster map " - "<{rmap}>".format( - rmap=id, voxel="" if stats_module.name == "r.univar" else "3d " - ) - ) + _("Unable to get statistics for raster map <%s>") % id + if stats_module.name == "r.univar" + else _("Unable to get statistics for 3d raster map <%s>") % id ) return None eol = "" @@ -106,7 +103,7 @@ def compute_univar_stats(registered_map_info, stats_module, fs, rast_region=Fals for perc in stats_module.inputs.percentile: perc_value = stats[ "percentile_" - f"{str(perc).rstrip('0').rstrip('.').replace('.','_')}" + f"{str(perc).rstrip('0').rstrip('.').replace('.', '_')}" ] string += f"{fs}{perc_value}" string += eol @@ -223,7 +220,7 @@ def print_gridded_dataset_univar_statistics( cols.extend( [ "percentile_" - f"{str(perc).rstrip('0').rstrip('.').replace('.','_')}" + f"{str(perc).rstrip('0').rstrip('.').replace('.', '_')}" for perc in percentile ] ) @@ -307,10 +304,7 @@ def print_vector_dataset_univar_statistics( mapset = get_current_mapset() - if input.find("@") >= 0: - id = input - else: - id = input + "@" + mapset + id = input if input.find("@") >= 0 else input + "@" + mapset sp = dataset_factory("stvds", id) diff --git a/python/libgrass_interface_generator/ctypesgen/parser/yacc.py b/python/libgrass_interface_generator/ctypesgen/parser/yacc.py index f30cadb7a1a..9b57d110231 100644 --- a/python/libgrass_interface_generator/ctypesgen/parser/yacc.py +++ b/python/libgrass_interface_generator/ctypesgen/parser/yacc.py @@ -311,7 +311,7 @@ def restart(self): # certain kinds of advanced parsing situations where the lexer and parser interact with # each other or change states (i.e., manipulation of scope, lexer states, etc.). # - # See: http://www.gnu.org/software/bison/manual/html_node/Default-Reductions.html#Default-Reductions + # See: https://www.gnu.org/software/bison/manual/html_node/Default-Reductions.html#Default-Reductions def set_defaulted_states(self): self.defaulted_states = {} for state, actions in self.action.items(): diff --git a/python/libgrass_interface_generator/ctypesgen/printer_json/printer.py b/python/libgrass_interface_generator/ctypesgen/printer_json/printer.py index ab88af4dc40..4a201aa5702 100755 --- a/python/libgrass_interface_generator/ctypesgen/printer_json/printer.py +++ b/python/libgrass_interface_generator/ctypesgen/printer_json/printer.py @@ -7,7 +7,7 @@ # From: -# http://stackoverflow.com/questions/1036409/recursively-convert-python-object-graph-to-dictionary +# https://stackoverflow.com/questions/1036409/recursively-convert-python-object-graph-to-dictionary def todict(obj, classkey="Klass"): if isinstance(obj, dict): for k in obj.keys(): diff --git a/raster/Makefile b/raster/Makefile index bcd07660238..91ff54d0863 100644 --- a/raster/Makefile +++ b/raster/Makefile @@ -45,6 +45,7 @@ SUBDIRS = \ r.lake \ r.li \ r.mapcalc \ + r.mask.status \ r.mfilter \ r.mode \ r.neighbors \ diff --git a/raster/r.basins.fill/testsuite/testrbf.py b/raster/r.basins.fill/testsuite/testrbf.py index b9937b05689..4077a2113a4 100644 --- a/raster/r.basins.fill/testsuite/testrbf.py +++ b/raster/r.basins.fill/testsuite/testrbf.py @@ -5,8 +5,8 @@ Author: Sunveer Singh Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ import unittest @@ -47,8 +47,8 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - def tearDown(cls): - cls.runModule("g.remove", flags="f", type="raster", name=cls.output) + def tearDown(self): + self.runModule("g.remove", flags="f", type="raster", name=self.output) def test_no1(self): lakes = "lakes" diff --git a/raster/r.buildvrt/r.buildvrt.html b/raster/r.buildvrt/r.buildvrt.html index d3a6d507bc1..d5118ba5150 100644 --- a/raster/r.buildvrt/r.buildvrt.html +++ b/raster/r.buildvrt/r.buildvrt.html @@ -12,6 +12,8 @@

    NOTES

    the original raster maps which is only valid if the original raster maps remain in the originally indicated mapset. A VRT can also be built from raster maps registered with r.external. +However, GRASS VRTs built from external registered data (see below) +are known to have performance issues.

    Reading the whole VRT is slower than reading the equivalent single @@ -20,7 +22,7 @@

    NOTES

    A GRASS virtual raster can be regarded as a simplified version of GDAL's -virtual raster format. +virtual raster format. The GRASS equivalent is simpler because issues like nodata, projection, resolution, resampling, masking are already handled by native GRASS raster routines. @@ -48,18 +50,29 @@

    VRT from a DEM in the North Carolina sample dataset

    r.buildvrt file=tilelist.csv output=elev_state_50m_vrt +

    KNOWN ISSUES

    + +Users may experience significant performance degradation with virtual rasters built +with r.buildvrt over GDAL-linked (r.external) raster maps, +especially on slower file systems with latency like NFS. Performance degradation +may also occur on local file systems, but is usually less severe. For such use cases +consider using the GRASS GIS addon +r.buildvrt.gdal +or building GDAL VRTs, e.g. with gdalbuildvrt. +

    SEE ALSO

    r.tile, r.patch, r.external +r.buildvrt.gdal

    The equivalent GDAL utility -gdalbuildvrt +gdalbuildvrt

    AUTHOR

    diff --git a/raster/r.carve/enforce_ds.c b/raster/r.carve/enforce_ds.c index ea4d7a1ae7a..7a71dc97def 100644 --- a/raster/r.carve/enforce_ds.c +++ b/raster/r.carve/enforce_ds.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "enforce.h" #ifndef MAX @@ -487,4 +488,6 @@ static void process_line_segment(const int npts, void *rbuf, Point2 *pgxypts, prevrow = row; prevcol = col; } + Vect_destroy_line_struct(points); + Vect_destroy_cats_struct(cats); } diff --git a/raster/r.circle/main.c b/raster/r.circle/main.c index 4b41a78c7c6..bd99a292f71 100644 --- a/raster/r.circle/main.c +++ b/raster/r.circle/main.c @@ -79,7 +79,9 @@ int main(int argc, char *argv[]) flag = G_define_flag(); flag->key = 'b'; - flag->description = _("Generate binary raster map"); + flag->label = _("Generate binary raster map"); + flag->description = + _("Generate binary pattern only (useful for creating mask)"); if (G_parser(argc, argv)) exit(EXIT_FAILURE); @@ -114,7 +116,7 @@ int main(int argc, char *argv[]) "using the binary flag")); if (flag->answer) - binary = 1; /* generate binary pattern only, useful for MASK */ + binary = 1; else binary = 0; diff --git a/raster/r.clump/clump.c b/raster/r.clump/clump.c index 052ad6ef034..cf94a5bf142 100644 --- a/raster/r.clump/clump.c +++ b/raster/r.clump/clump.c @@ -25,6 +25,8 @@ #include #include #include "local_proto.h" +#include +#include #define INCR 1024 @@ -92,7 +94,9 @@ static CELL do_renumber(int *in_fd, DCELL *rng, int nin, int diag, int minsize, G_percent(row, nrows, 2); coffset = (off_t)row * csize; - lseek(cfd, coffset, SEEK_SET); + if (lseek(cfd, coffset, SEEK_SET) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } if (read(cfd, cur_clump, csize) != csize) G_fatal_error(_("Unable to read from temp file")); @@ -108,7 +112,9 @@ static CELL do_renumber(int *in_fd, DCELL *rng, int nin, int diag, int minsize, temp_clump++; } if (do_write) { - lseek(cfd, coffset, SEEK_SET); + if (lseek(cfd, coffset, SEEK_SET) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } if (write(cfd, cur_clump, csize) != csize) G_fatal_error(_("Unable to write to temp file")); } diff --git a/raster/r.composite/r.composite.html b/raster/r.composite/r.composite.html index 4bd8e49cbe4..0ddd72592ea 100644 --- a/raster/r.composite/r.composite.html +++ b/raster/r.composite/r.composite.html @@ -47,7 +47,7 @@

    SEE ALSO

    r.rgb

    -Wikipedia Entry: Floyd-Steinberg dithering +Wikipedia Entry: Floyd-Steinberg dithering

    AUTHOR

    diff --git a/raster/r.contour/testsuite/test_r_contour.py b/raster/r.contour/testsuite/test_r_contour.py index 9fc0fc17469..49617ef043d 100644 --- a/raster/r.contour/testsuite/test_r_contour.py +++ b/raster/r.contour/testsuite/test_r_contour.py @@ -32,10 +32,11 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - cls.runModule("g.remove", type="vector", flags="f", name=cls.output) - cls.runModule("g.remove", type="vector", flags="f", name=cls.output + "_cut") cls.runModule( - "g.remove", type="vector", flags="f", name=cls.output + "_cut_flag_t" + "g.remove", + type="vector", + flags="f", + name=(cls.output, cls.output + "_cut", cls.output + "_cut_flag_t"), ) if os.path.isfile("testReport"): @@ -62,7 +63,7 @@ def test_raster_contour(self): self.assertModule("v.db.select", map=self.output, file="testReport") self.assertFileExists("testReport", msg="testReport file was not created") if os.path.isfile("testReport"): - file = open("testReport", "r") + file = open("testReport") fileData = file.read() self.assertMultiLineEqual(fileData, self.test_ref_str) file.close() @@ -87,7 +88,7 @@ def test_raster_contour_cut(self): self.assertModule("v.db.select", map=self.output + "_cut", file="testReportCut") self.assertFileExists("testReportCut", msg="testReportCut file was not created") if os.path.isfile("testReportCut"): - file = open("testReportCut", "r") + file = open("testReportCut") fileData = file.read() self.assertMultiLineEqual(fileData, self.test_ref_str) file.close() diff --git a/raster/r.external.out/r.external.out.html b/raster/r.external.out/r.external.out.html index baf48466ed3..c4b3bc65af1 100644 --- a/raster/r.external.out/r.external.out.html +++ b/raster/r.external.out/r.external.out.html @@ -70,7 +70,7 @@

    Complete workflow using only external geodata while processing in GRASS GIS<

    REFERENCES

    -GDAL Pages: http://www.gdal.org/
    +GDAL Pages: https://gdal.org/

    SEE ALSO

    diff --git a/raster/r.external/r.external.html b/raster/r.external/r.external.html index 797cc5ea605..1c69b2d3c3f 100644 --- a/raster/r.external/r.external.html +++ b/raster/r.external/r.external.html @@ -17,10 +17,12 @@

    NULL data handling

    NULL cells are those whose value matches the value reported by the GDALGetRasterNoDataValue() function. -To apply the GDAL-linked the user need to either create a MASK (e.g. -with r.mask) and then "apply" it using e.g. r.resample, +

    +To introduce additional NULL values to a computation based on a GDAL-linked +raster, the user needs to either create a mask with with r.mask and +then "apply" it using e.g. r.resample or r.mapcalc, or use r.mapcalc to create a copy with the appropriate categories -changed to NULL (if() condition). +changed to NULL (if() condition).

    EXAMPLES

    @@ -60,7 +62,7 @@

    Processing workflow without data import and export

    REFERENCES

    -GDAL Pages: http://www.gdal.org/
    +GDAL Pages: https://gdal.org/

    SEE ALSO

    diff --git a/raster/r.fill.dir/filldir.c b/raster/r.fill.dir/filldir.c index 55380b7dfc5..cfe0ae69586 100644 --- a/raster/r.fill.dir/filldir.c +++ b/raster/r.fill.dir/filldir.c @@ -145,14 +145,20 @@ void filldir(int fe, int fd, int nl, struct band3 *bnd) CELL *dir; /* fill single-cell depressions, except on outer rows and columns */ - lseek(fe, 0, SEEK_SET); + if (lseek(fe, 0, SEEK_SET) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } advance_band3(fe, bnd); advance_band3(fe, bnd); for (i = 1; i < nl - 1; i += 1) { - lseek(fe, (off_t)(i + 1) * bnd->sz, SEEK_SET); + if (lseek(fe, (off_t)(i + 1) * bnd->sz, SEEK_SET) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } advance_band3(fe, bnd); if (fill_row(nl, bnd->ns, bnd)) { - lseek(fe, (off_t)i * bnd->sz, SEEK_SET); + if (lseek(fe, (off_t)i * bnd->sz, SEEK_SET) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } if (write(fe, bnd->b[1], bnd->sz) < 0) G_fatal_error(_("File writing error in %s() %d:%s"), __func__, errno, strerror(errno)); @@ -172,8 +178,12 @@ void filldir(int fe, int fd, int nl, struct band3 *bnd) dir = G_calloc(bnd->ns, sizeof(CELL)); bufsz = bnd->ns * sizeof(CELL); - lseek(fe, 0, SEEK_SET); - lseek(fd, 0, SEEK_SET); + if (lseek(fe, 0, SEEK_SET) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } + if (lseek(fd, 0, SEEK_SET) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } advance_band3(fe, bnd); for (i = 0; i < nl; i += 1) { advance_band3(fe, bnd); diff --git a/raster/r.fill.dir/r.fill.dir.html b/raster/r.fill.dir/r.fill.dir.html index 6ad8eb8019c..17173ea3dd3 100644 --- a/raster/r.fill.dir/r.fill.dir.html +++ b/raster/r.fill.dir/r.fill.dir.html @@ -69,11 +69,11 @@

    DESCRIPTION

    attributes required by other hydrological models.

    -As any GRASS GIS module, r.fill.dir is sensitive to the -computational region settings. Thus +As any GRASS GIS module, r.fill.dir respects the +computational region settings. Thus, the module can be used to generate a flow direction map for any -sub-area within the full map layer. Also, r.fill.dir is -sensitive to any raster MASK in effect. +sub-area within the full raster map layer. Also, r.fill.dir +will take into account an active raster mask.

    NOTES

    diff --git a/raster/r.fill.stats/r.fill.stats.html b/raster/r.fill.stats/r.fill.stats.html index 3151d2c245a..fdc60119243 100644 --- a/raster/r.fill.stats/r.fill.stats.html +++ b/raster/r.fill.stats/r.fill.stats.html @@ -509,7 +509,7 @@

    SEE ALSO

    -Inverse Distance Weighting in Wikipedia +Inverse Distance Weighting in Wikipedia

    AUTHOR

    diff --git a/raster/r.geomorphon/r.geomorphon.html b/raster/r.geomorphon/r.geomorphon.html index 0eb675451f3..54af307b007 100644 --- a/raster/r.geomorphon/r.geomorphon.html +++ b/raster/r.geomorphon/r.geomorphon.html @@ -187,7 +187,7 @@

    REFERENCES

    109-112 (PDF)
  • Jasiewicz, J., Stepinski, T., 2013, Geomorphons - a pattern recognition approach to classification and mapping of landforms, -Geomorphology, vol. 182, 147-156 (DOI: 10.1016/j.geomorph.2012.11.005)
  • +Geomorphology, vol. 182, 147-156 (DOI: 10.1016/j.geomorph.2012.11.005)

    SEE ALSO

    diff --git a/raster/r.grow.distance/r.grow.distance.html b/raster/r.grow.distance/r.grow.distance.html index bc2788aae44..ee5e276a550 100644 --- a/raster/r.grow.distance/r.grow.distance.html +++ b/raster/r.grow.distance/r.grow.distance.html @@ -127,9 +127,9 @@

    SEE ALSO

    -Wikipedia Entry: +Wikipedia Entry: Euclidean Metric
    -Wikipedia Entry: +Wikipedia Entry: Manhattan Metric
    diff --git a/raster/r.his/testsuite/test_r_his.py b/raster/r.his/testsuite/test_r_his.py new file mode 100644 index 00000000000..da56d633b6d --- /dev/null +++ b/raster/r.his/testsuite/test_r_his.py @@ -0,0 +1,91 @@ +from grass.gunittest.case import TestCase +from grass.gunittest.main import test + + +class TestRHis(TestCase): + hue = "elevation" + intensity = "elevation_shaded_50" + saturation = "elevation" + red = "shadedmap_r" + green = "shadedmap_g" + blue = "shadedmap_b" + bgcolor = "none" + + @classmethod + def setUpClass(cls): + cls.use_temp_region() + cls.runModule("g.region", raster="elevation") + cls.elev_shade = "elevation_shaded_relief" + cls.runModule("r.relief", input="elevation", output=cls.elev_shade) + cls.runModule( + "r.mapcalc", expression=f"{cls.intensity} = {cls.elev_shade} * 1.5" + ) + cls.runModule("r.colors", map=cls.intensity, color="grey255") + + @classmethod + def tearDownClass(cls): + cls.runModule( + "g.remove", type="raster", flags="f", name=[cls.intensity, cls.elev_shade] + ) + cls.del_temp_region() + + def tearDown(self): + """Remove d.his generated rasters after each test method""" + self.runModule("g.remove", type="raster", flags="f", pattern="shadedmap_*") + + def test_bgcolor_none(self): + """Test r.his with bgcolor 'none'""" + self.runModule( + "r.his", + hue=self.hue, + intensity=self.intensity, + saturation=self.saturation, + red=self.red, + green=self.green, + blue=self.blue, + bgcolor=self.bgcolor, + ) + + red_value = "null_cells=5696\nmin=3\nmax=255\nmean=156.41168\nstddev=34.434612" + blue_value = "null_cells=5696\nmin=0\nmax=127\nmean=36.05560\nstddev=37.61216" + green_value = "null_cells=5696\nmin=1\nmax=255\nmean=129.62880\nstddev=34.48307" + + self.assertRasterFitsUnivar( + raster=self.red, reference=red_value, precision=1e-5 + ) + self.assertRasterFitsUnivar( + raster=self.blue, reference=blue_value, precision=1e-5 + ) + self.assertRasterFitsUnivar( + raster=self.green, reference=green_value, precision=1e-5 + ) + + def test_with_bgcolor_rgb(self): + """Test r.his with bgcolor '0:0:0'""" + self.runModule( + "r.his", + hue=self.hue, + intensity=self.intensity, + saturation=self.saturation, + red=self.red, + green=self.green, + blue=self.blue, + bgcolor="0:0:0", + ) + + red_value = "null_cells=0\nmin=0\nmax=255\nmean=155.97172\nstddev=35.36988" + blue_value = "null_cells=0\nmin=0\nmax=127\nmean=35.95417\nstddev=37.60774" + green_value = "null_cells=0\nmin=0\nmax=255\nmean=129.26418\nstddev=35.11225" + self.assertRasterFitsUnivar( + raster=self.red, reference=red_value, precision=1e-5 + ) + self.assertRasterFitsUnivar( + raster=self.blue, reference=blue_value, precision=1e-5 + ) + self.assertRasterFitsUnivar( + raster=self.green, reference=green_value, precision=1e-5 + ) + + +if __import__("__main__"): + test() diff --git a/raster/r.in.ascii/testsuite/test_r_in_ascii.py b/raster/r.in.ascii/testsuite/test_r_in_ascii.py index 20e0c2a8f9e..8db06f83517 100644 --- a/raster/r.in.ascii/testsuite/test_r_in_ascii.py +++ b/raster/r.in.ascii/testsuite/test_r_in_ascii.py @@ -5,13 +5,12 @@ Author: Sunveer Singh, Google Code-in 2017 Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase from grass.gunittest.main import test -from grass.script.core import read_command INPUT_NOQUOTES = """north: 4299000.00 south: 4247000.00 @@ -32,44 +31,6 @@ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 """ -INPUT_TSV = """north: 4299000.00 -south: 4247000.00 -east: 528000.00 -west: 500000.00 -rows: 10 -cols: 15 -null: -9999 - -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 -1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\ 10\ 11\ 12\ 13\ 14\ 15 """ - -INPUT_UNCOMMON = """north: 4299000.00 -south: 4247000.00 -east: 528000.00 -west: 500000.00 -rows: 10 -cols: 15 -null: -9999 - -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 -1@ 2@ 3@ 4@ 5@ 6@ 7@ 8@ 9@ 10@ 11@ 12@ 13@ 14@ 15 """ - class SimpleCsvTestCase(TestCase): ascii_test = "ascii" @@ -119,38 +80,6 @@ def test_text_delimeter(self): msg="ascii_test in degrees must be between 1 and 5", ) - def test_tsv(self): - """Test loading TSV""" - self.assertModule( - "r.in.ascii", - input="-", - output=self.ascii_test, - type="CELL", - stdin_=INPUT_TSV, - ) - self.assertRasterMinMax( - map=self.ascii_test, - refmin=1, - refmax=15, - msg="ascii_test in degrees must be between 1 and 15", - ) - - def test_uncommon_delims(self): - """Test loading with uncommon delimiters""" - self.assertModule( - "r.in.ascii", - input="-", - output=self.ascii_test, - type="CELL", - stdin_=INPUT_UNCOMMON, - ) - self.assertRasterMinMax( - map=self.ascii_test, - refmin=1, - refmax=15, - msg="ascii_test in degrees must be between 1 and 15", - ) - if __name__ == "__main__": test() diff --git a/raster/r.in.gdal/r.in.gdal.html b/raster/r.in.gdal/r.in.gdal.html index f21f5682226..5af167a78e0 100644 --- a/raster/r.in.gdal/r.in.gdal.html +++ b/raster/r.in.gdal/r.in.gdal.html @@ -20,7 +20,7 @@

    GDAL supported raster formats

    Full details on all GDAL supported formats are available at:

    -http://www.gdal.org/formats_list.html +https://gdal.org/formats_list.html

    Selected formats out of the more than 140 supported formats: @@ -363,7 +363,7 @@

    GLOBE DEM

    Raster file import over network

    Since GDAL 2.x it is possible to import raster data over the network -(see GDAL Virtual File Systems) +(see GDAL Virtual File Systems) including Cloud Optimized GeoTIFF, i.e. access uncompressed and compressed raster data via a http(s) or ftp connection. As an example the import of the global SRTMGL1 V003 tiles at 1 arc second (about 30 meters) @@ -398,7 +398,7 @@

    HDF

    REFERENCES

    -GDAL Pages: http://www.gdal.org/ +GDAL Pages: https://gdal.org/

    SEE ALSO

    diff --git a/raster/r.in.gdal/testsuite/test_r_in_gdal.py b/raster/r.in.gdal/testsuite/test_r_in_gdal.py index 355e9b74eda..477ffca89c8 100644 --- a/raster/r.in.gdal/testsuite/test_r_in_gdal.py +++ b/raster/r.in.gdal/testsuite/test_r_in_gdal.py @@ -4,6 +4,7 @@ """ import unittest +import sys from subprocess import check_output @@ -306,12 +307,13 @@ def test_netCDF_3d_5(self): test_gdal_import_map.0000000105 """ - text_from_file = open("map_names_file.txt", "r").read() + text_from_file = open("map_names_file.txt").read() self.assertLooksLike(map_list, text_from_file) @unittest.skipIf( - tuple( + not sys.platform.startswith("win") + and tuple( map( int, check_output(["gdal-config", "--version"]) diff --git a/raster/r.in.gridatb/file_io.c b/raster/r.in.gridatb/file_io.c index 256f9869473..52ad174df4d 100644 --- a/raster/r.in.gridatb/file_io.c +++ b/raster/r.in.gridatb/file_io.c @@ -12,6 +12,9 @@ void rdwr_gridatb(void) float idx; fp = fopen(file, "r"); + if (!fp) { + G_fatal_error(_("Unable to open file: %s"), file); + } buf[0] = 0; if (fscanf(fp, "%[^\n]", buf) != 1) diff --git a/raster/r.in.lidar/main.c b/raster/r.in.lidar/main.c index 68d3a0fcd1b..96f562167b6 100644 --- a/raster/r.in.lidar/main.c +++ b/raster/r.in.lidar/main.c @@ -51,8 +51,8 @@ int main(int argc, char *argv[]) struct PointBinning point_binning; void *base_array; void *raster_row; - struct Cell_head region; - struct Cell_head input_region; + struct Cell_head region = {0}; + struct Cell_head input_region = {0}; int rows, last_rows, row0, cols; /* scan box size */ int row; /* counters */ @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) int return_filter; const char *projstr; - struct Cell_head cellhd, loc_wind; + struct Cell_head cellhd = {0}, loc_wind = {0}; unsigned int n_filtered; diff --git a/raster/r.in.pdal/main.cpp b/raster/r.in.pdal/main.cpp index da32dcb5484..36d09558eea 100644 --- a/raster/r.in.pdal/main.cpp +++ b/raster/r.in.pdal/main.cpp @@ -69,8 +69,8 @@ int main(int argc, char *argv[]) SEGMENT base_segment; struct PointBinning point_binning; void *raster_row; - struct Cell_head region; - struct Cell_head input_region; + struct Cell_head region = {}; + struct Cell_head input_region = {}; int rows, cols; /* scan box size */ char buff[BUFFSIZE]; @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) bin_index_nodes.max_nodes = 0; bin_index_nodes.nodes = NULL; - struct Cell_head loc_wind; + struct Cell_head loc_wind = {}; G_gisinit(argv[0]); diff --git a/raster/r.in.pdal/testsuite/test_r_in_pdal_binning.py b/raster/r.in.pdal/testsuite/test_r_in_pdal_binning.py index a8a793f5bc7..c256224590d 100644 --- a/raster/r.in.pdal/testsuite/test_r_in_pdal_binning.py +++ b/raster/r.in.pdal/testsuite/test_r_in_pdal_binning.py @@ -68,8 +68,12 @@ def tearDown(self): This is executed after each test run. """ - self.runModule("g.remove", flags="f", type="raster", name=self.bin_raster) - self.runModule("g.remove", flags="f", type="raster", name=self.ref_raster) + self.runModule( + "g.remove", + flags="f", + type="raster", + name=(self.bin_raster, self.ref_raster), + ) @unittest.skipIf(shutil.which("r.in.pdal") is None, "Cannot find r.in.pdal") def test_method_n(self): diff --git a/raster/r.in.pdal/testsuite/test_r_in_pdal_selection.py b/raster/r.in.pdal/testsuite/test_r_in_pdal_selection.py index b7d5acd6b28..4796702d2f6 100644 --- a/raster/r.in.pdal/testsuite/test_r_in_pdal_selection.py +++ b/raster/r.in.pdal/testsuite/test_r_in_pdal_selection.py @@ -67,8 +67,12 @@ def tearDown(self): This is executed after each test run. """ - self.runModule("g.remove", flags="f", type="raster", name=self.imp_raster) - self.runModule("g.remove", flags="f", type="raster", name=self.ref_raster) + self.runModule( + "g.remove", + flags="f", + type="raster", + name=(self.imp_raster, self.ref_raster), + ) try: self.runModule("g.remove", flags="f", type="raster", name=self.base_raster) except AttributeError: diff --git a/raster/r.in.poly/poly2rast.c b/raster/r.in.poly/poly2rast.c index e81d6f421a3..bb707d03e25 100644 --- a/raster/r.in.poly/poly2rast.c +++ b/raster/r.in.poly/poly2rast.c @@ -90,6 +90,7 @@ int poly_to_rast(char *input_file, char *raster_map, char *title, int nrows, if (stat < 0) { Rast_unopen(rfd); + fclose(ifd); return 1; } @@ -98,6 +99,7 @@ int poly_to_rast(char *input_file, char *raster_map, char *title, int nrows, Rast_short_history(raster_map, "raster", &history); Rast_command_history(&history); Rast_write_history(raster_map, &history); + fclose(ifd); return 0; } diff --git a/raster/r.in.xyz/main.c b/raster/r.in.xyz/main.c index a4c7dfde6ed..b3c3fb380cf 100644 --- a/raster/r.in.xyz/main.c +++ b/raster/r.in.xyz/main.c @@ -112,7 +112,7 @@ int main(int argc, char *argv[]) char *n_array, *min_array, *max_array, *sum_array, *sumsq_array, *index_array; void *raster_row, *ptr; - struct Cell_head region; + struct Cell_head region = {0}; int rows, last_rows, row0, cols; /* scan box size */ int row, col; /* counters */ diff --git a/raster/r.in.xyz/r.in.xyz.html b/raster/r.in.xyz/r.in.xyz.html index 15d9f3565aa..42e5e1ee7f8 100644 --- a/raster/r.in.xyz/r.in.xyz.html +++ b/raster/r.in.xyz/r.in.xyz.html @@ -245,7 +245,7 @@

    Import of x,y,z ASCII into DEM

    Import of LiDAR data and DEM creation

    -Import the Jockey's +Import the Jockey's Ridge, NC, LIDAR dataset (compressed file "lidaratm2.txt.gz"), and process it into a clean DEM: diff --git a/raster/r.kappa/testsuite/test_r_kappa.py b/raster/r.kappa/testsuite/test_r_kappa.py index 56e356ca20b..ff11f477925 100644 --- a/raster/r.kappa/testsuite/test_r_kappa.py +++ b/raster/r.kappa/testsuite/test_r_kappa.py @@ -21,6 +21,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.checkers import keyvalue_equals +from grass.gunittest.utils import xfail_windows class MatrixCorrectnessTest(TestCase): @@ -50,8 +51,9 @@ def setUpClass(cls): def tearDownClass(cls): """Remove temporary data""" cls.del_temp_region() - cls.runModule("g.remove", flags="f", type="raster", name=cls.ref_1) - cls.runModule("g.remove", flags="f", type="raster", name=cls.class_1) + cls.runModule( + "g.remove", flags="f", type="raster", name=(cls.ref_1, cls.class_1) + ) def test_m(self): """Test printing matrix only @@ -118,8 +120,9 @@ def setUpClass(cls): def tearDownClass(cls): """Remove temporary data""" cls.del_temp_region() - cls.runModule("g.remove", flags="f", type="raster", name=cls.ref_1) - cls.runModule("g.remove", flags="f", type="raster", name=cls.class_1) + cls.runModule( + "g.remove", flags="f", type="raster", name=(cls.ref_1, cls.class_1) + ) def match(self, pat, ref): if pat == "NA" or ref == "NA": @@ -232,8 +235,9 @@ def setUpClass(cls): def tearDownClass(cls): """Remove temporary data""" cls.del_temp_region() - cls.runModule("g.remove", flags="f", type="raster", name=cls.ref_1) - cls.runModule("g.remove", flags="f", type="raster", name=cls.class_1) + cls.runModule( + "g.remove", flags="f", type="raster", name=(cls.ref_1, cls.class_1) + ) def match(self, pat, ref): if pat == "NA" or ref == "NA": @@ -474,6 +478,7 @@ def test_stdout(self): keyvalue_equals(self.expected_outputs[i], json_out, precision=4) ) + @xfail_windows def test_file(self): for i in range(len(self.references)): f = NamedTemporaryFile() diff --git a/raster/r.li/TODO b/raster/r.li/TODO index 61ddd6b0941..382195402a6 100644 --- a/raster/r.li/TODO +++ b/raster/r.li/TODO @@ -24,12 +24,13 @@ d.vect forests type=boundary ######## TODO: CHECK THIS: -# MASK test -g.copy rast=fields,MASK +# Test with raster mask +r.mask raster=fields r.li.patchdensity forests conf=movwindow7 output=forests_p_dens7mask --o d.erase d.rast.leg forests_p_dens7mask -# -> no negative values! but MASK is respected +r.mask -r +# -> no negative values! but mask is respected # zero data test r.mapcalc "forests = 0" diff --git a/raster/r.mask.status/Makefile b/raster/r.mask.status/Makefile new file mode 100644 index 00000000000..62c968d044e --- /dev/null +++ b/raster/r.mask.status/Makefile @@ -0,0 +1,10 @@ +MODULE_TOPDIR = ../.. + +PGM = r.mask.status + +LIBES = $(MANAGELIB) $(RASTERLIB) $(GISLIB) $(PARSONLIB) +DEPENDENCIES = $(MANAGEDEP) $(RASTERDEP) $(GISDEP) + +include $(MODULE_TOPDIR)/include/Make/Module.make + +default: cmd diff --git a/raster/r.mask.status/main.c b/raster/r.mask.status/main.c new file mode 100644 index 00000000000..b0a7b9185c0 --- /dev/null +++ b/raster/r.mask.status/main.c @@ -0,0 +1,178 @@ +/**************************************************************************** + * + * MODULE: r.mask.status + * AUTHORS: Vaclav Petras + * PURPOSE: Report status of raster mask + * COPYRIGHT: (C) 2024 by Vaclav Petras and the GRASS Development Team + * + * This program is free software under the GNU General Public + * License (>=v2). Read the file COPYING that comes with GRASS + * for details. + * + *****************************************************************************/ + +#include +#include +#include +#include + +#include +#include +#include +#include + +struct Parameters { + struct Option *format; + struct Flag *like_test; +}; + +void parse_parameters(struct Parameters *params, int argc, char **argv) +{ + struct GModule *module; + + module = G_define_module(); + G_add_keyword(_("raster")); + G_add_keyword(_("mask")); + G_add_keyword(_("reclassification")); + module->label = _("Reports presence or absence of a raster mask"); + module->description = + _("Provides information about the presence of a 2D raster mask" + " as text output or return code"); + + params->format = G_define_option(); + params->format->key = "format"; + params->format->type = TYPE_STRING; + params->format->required = NO; + params->format->answer = "plain"; + params->format->options = "plain,json,shell,yaml"; + params->format->descriptions = + "plain;Plain text output;" + "json;JSON (JavaScript Object Notation);" + "shell;Shell script style output;" + "yaml;YAML (human-friendly data serialization language)"; + params->format->description = _("Format for reporting"); + + params->like_test = G_define_flag(); + params->like_test->key = 't'; + params->like_test->label = + _("Return code 0 when mask present, 1 otherwise"); + params->like_test->description = + _("Behave like the test utility, 0 for true, 1 for false, no output"); + // suppress_required is not required given the default value for format. + // Both no parameters and only -t work as expected. + + if (G_parser(argc, argv)) + exit(EXIT_FAILURE); +} + +int report_status(struct Parameters *params) +{ + + char name[GNAME_MAX]; + char mapset[GMAPSET_MAX]; + char reclass_name[GNAME_MAX]; + char reclass_mapset[GMAPSET_MAX]; + + bool is_mask_reclass; + bool present = Rast_mask_status(name, mapset, &is_mask_reclass, + reclass_name, reclass_mapset); + + // This does not have to be exclusive with the printing, but leaving this + // to a different boolean flag which could do the return code and printing. + // The current implementation really behaves like the test utility which + // facilitates the primary usage of this which is prompt building + // (and there any output would be noise). + if (params->like_test->answer) { + if (present) + return 0; + return 1; + } + + // Mask raster + char *full_mask = Rast_mask_name(); + // Underlying raster if applicable + char *full_underlying = NULL; + if (is_mask_reclass) + full_underlying = G_fully_qualified_name(reclass_name, reclass_mapset); + + if (strcmp(params->format->answer, "json") == 0) { + JSON_Value *root_value = json_value_init_object(); + JSON_Object *root_object = json_object(root_value); + json_object_set_boolean(root_object, "present", present); + json_object_set_string(root_object, "name", full_mask); + if (is_mask_reclass) + json_object_set_string(root_object, "is_reclass_of", + full_underlying); + else + json_object_set_null(root_object, "is_reclass_of"); + char *serialized_string = json_serialize_to_string_pretty(root_value); + if (!serialized_string) + G_fatal_error(_("Failed to initialize pretty JSON string.")); + puts(serialized_string); + json_free_serialized_string(serialized_string); + json_value_free(root_value); + } + else if (strcmp(params->format->answer, "shell") == 0) { + printf("present="); + if (present) + printf("1"); + else + printf("0"); + printf("\nname=%s", full_mask); + printf("\nis_reclass_of="); + if (is_mask_reclass) + printf("%s", full_underlying); + printf("\n"); + } + else if (strcmp(params->format->answer, "yaml") == 0) { + printf("present: "); + if (present) + printf("true"); + else + printf("false"); + printf("\nname: "); + printf("|-\n %s", full_mask); + printf("\nis_reclass_of: "); + // Using block scalar with |- to avoid need for escaping. + // Alternatively, we could check mapset naming limits against YAML + // escaping needs for different types of strings and do the necessary + // escaping here. + // Null values in YAML can be an empty (no) value (rather than null), + // so we could use that, but using the explicit null as a reasonable + // starting point. + if (is_mask_reclass) + printf("|-\n %s", full_underlying); + else + printf("null"); + printf("\n"); + } + else { + if (present) { + printf(_("Mask is active")); + printf(_("Mask name: %s"), full_mask); + } + else { + printf(_("Mask is not present")); + printf(_("If activated, mask name will be: %s"), full_mask); + } + if (is_mask_reclass) { + printf("\n"); + printf(_("Mask is a raster reclassified from: %s"), + full_underlying); + } + printf("\n"); + } + + G_free(full_mask); + G_free(full_underlying); + return EXIT_SUCCESS; +} + +int main(int argc, char **argv) +{ + struct Parameters params; + + G_gisinit(argv[0]); + parse_parameters(¶ms, argc, argv); + return report_status(¶ms); +} diff --git a/raster/r.mask.status/r.mask.status.html b/raster/r.mask.status/r.mask.status.html new file mode 100644 index 00000000000..cb3897820f5 --- /dev/null +++ b/raster/r.mask.status/r.mask.status.html @@ -0,0 +1,75 @@ +

    DESCRIPTION

    + +The r.mask.status reports information about the 2D raster mask and its +status. The tool reports whether the mask is present or not. For both active +and inactive mask, the tool reports a full name of the raster (name including +the mapset) which represents or would represent the mask. +It can also report full name of the underlying raster if the mask is +reclassified from another raster. + +The tool can be used to check if the mask is currently set +(present boolean in JSON), what is raster name used to represent +the mask (name string in JSON), and whether the raster is +reclassifed from another (is_reclass_of string or null in JSON). +YAML and shell script style outputs are following the JSON output if possible. +The plain text format outputs multi-line human-readable information in natural +language. + +

    +With the -t flag, no output is printed, instead a return code is used to +indicate presence or absence. The convention is the same same the POSIX +test utility, so r.mask.status returns 0 when the mask is +present and 1 otherwise. + +

    EXAMPLES

    + +

    Generate JSON output

    + +To generate JSON output in Bash, use the format option: + +
    +r.mask.status format=json
    +
    + +In Python, use: + +
    +import grass.script as gs
    +gs.parse_command("r.mask.status", format="json")
    +
    + +This returns a dictionary with keys present, +full_name, and is_reclass_of. + +

    Use as the test utility

    + +The POSIX test utility uses return code 0 to indicate presence +and 1 to indicate absence of a file, so testing existence of a file with +test -f gives return code 0 when the file exists. +r.mask.status can be used in the same with the the -t flag: + +
    +r.mask.status -t
    +
    + +In a Bash script: + +
    +# Bash
    +if r.mask.status -t; then
    +    echo "Masking is active"
    +else
    +    echo "Masking is not active"
    +fi
    +
    + +

    SEE ALSO

    + + +r.mask, +g.region + + +

    AUTHORS

    + +Vaclav Petras, NC State University, Center for Geospatial Analytics diff --git a/raster/r.mask.status/tests/conftest.py b/raster/r.mask.status/tests/conftest.py new file mode 100644 index 00000000000..e8e27315845 --- /dev/null +++ b/raster/r.mask.status/tests/conftest.py @@ -0,0 +1,25 @@ +"""Fixtures for simple sessions""" + +import os +import pytest +import grass.script as gs + + +@pytest.fixture +def session_no_data(tmp_path): + """Set up a GRASS session for the tests.""" + project = "test_project" + gs.create_project(tmp_path, project) + with gs.setup.init(tmp_path / project, env=os.environ.copy()) as session: + yield session + + +@pytest.fixture +def session_with_data(tmp_path): + """Set up a GRASS session for the tests.""" + project = tmp_path / "test_project" + gs.create_project(project) + with gs.setup.init(project, env=os.environ.copy()) as session: + gs.run_command("g.region", rows=2, cols=2, env=session.env) + gs.mapcalc("a = 1", env=session.env) + yield session diff --git a/raster/r.mask.status/tests/r_mask_status_test.py b/raster/r.mask.status/tests/r_mask_status_test.py new file mode 100644 index 00000000000..a5d406ad581 --- /dev/null +++ b/raster/r.mask.status/tests/r_mask_status_test.py @@ -0,0 +1,129 @@ +"""Tests of r.mask.status""" + +import pytest + +try: + import yaml +except ImportError: + yaml = None + +import grass.script as gs + + +def test_json_no_mask(session_no_data): + """Check JSON format for no mask""" + session = session_no_data + data = gs.parse_command("r.mask.status", format="json", env=session.env) + assert "present" in data + assert "name" in data + assert data["name"], "Mask name needs to be always set" + assert data["name"] == "MASK@PERMANENT", "Default mask name and current mapset" + assert "is_reclass_of" in data + assert data["present"] is False + assert not data["is_reclass_of"] + + +def test_json_with_r_mask(session_with_data): + """Check JSON format for the r.mask case""" + session = session_with_data + gs.run_command("r.mask", raster="a", env=session.env) + data = gs.parse_command("r.mask.status", format="json", env=session.env) + assert data["present"] is True + assert data["name"] == "MASK@PERMANENT" + assert data["is_reclass_of"] == "a@PERMANENT" + # Now remove the mask. + gs.run_command("r.mask", flags="r", env=session.env) + data = gs.parse_command("r.mask.status", format="json", env=session.env) + assert data["present"] is False + assert data["name"] == "MASK@PERMANENT" + assert not data["is_reclass_of"] + + +def test_json_with_g_copy(session_with_data): + """Check JSON format for the low-level g.copy case""" + session = session_with_data + gs.run_command("g.copy", raster="a,MASK", env=session.env) + data = gs.parse_command("r.mask.status", format="json", env=session.env) + assert data["present"] is True + assert data["name"] == "MASK@PERMANENT" + assert not data["is_reclass_of"] + # Now remove the mask. + gs.run_command("g.remove", type="raster", name="MASK", flags="f", env=session.env) + data = gs.parse_command("r.mask.status", format="json", env=session.env) + assert data["present"] is False + assert data["name"] == "MASK@PERMANENT" + assert not data["is_reclass_of"] + + +def test_shell(session_with_data): + """Check shell format for the r.mask case""" + session = session_with_data + gs.run_command("r.mask", raster="a", env=session.env) + data = gs.parse_command("r.mask.status", format="shell", env=session.env) + assert int(data["present"]) + assert data["name"] == "MASK@PERMANENT" + assert data["is_reclass_of"] == "a@PERMANENT" + # Now remove the mask. + gs.run_command("r.mask", flags="r", env=session.env) + data = gs.parse_command("r.mask.status", format="shell", env=session.env) + assert not int(data["present"]) + assert data["name"] == "MASK@PERMANENT" + assert not data["is_reclass_of"] + + +@pytest.mark.skipif(yaml is None, reason="PyYAML package not available") +def test_yaml(session_with_data): + """Check YAML format for the r.mask case""" + session = session_with_data + gs.run_command("r.mask", raster="a", env=session.env) + text = gs.read_command("r.mask.status", format="yaml", env=session.env) + data = yaml.safe_load(text) + assert data["present"] is True + assert data["name"] == "MASK@PERMANENT" + assert data["is_reclass_of"] == "a@PERMANENT" + # Now remove the mask. + gs.run_command("r.mask", flags="r", env=session.env) + text = gs.read_command("r.mask.status", format="yaml", env=session.env) + data = yaml.safe_load(text) + assert data["present"] is False + assert data["name"] == "MASK@PERMANENT" + assert not data["is_reclass_of"] + + +def test_plain(session_with_data): + """Check plain text format for the r.mask case""" + session = session_with_data + gs.run_command("r.mask", raster="a", env=session.env) + text = gs.read_command("r.mask.status", format="plain", env=session.env) + assert text + assert "MASK@PERMANENT" in text + assert "a@PERMANENT" in text + # Now remove the mask. + gs.run_command("r.mask", flags="r", env=session.env) + text = gs.read_command("r.mask.status", format="plain", env=session.env) + assert text + assert "MASK@PERMANENT" in text + assert "a@PERMANENT" not in text + + +def test_without_parameters(session_no_data): + """Check output is generated with no parameters""" + session = session_no_data + text = gs.read_command("r.mask.status", env=session.env) + assert text + + +def test_behavior_mimicking_test_program(session_with_data): + """Check test program like behavior for the r.mask case""" + session = session_with_data + gs.run_command("r.mask", raster="a", env=session.env) + returncode = gs.run_command( + "r.mask.status", flags="t", env=session.env, errors="status" + ) + assert returncode == 0 + # Now remove the mask. + gs.run_command("r.mask", flags="r", env=session.env) + returncode = gs.run_command( + "r.mask.status", flags="t", env=session.env, errors="status" + ) + assert returncode == 1 diff --git a/raster/r.mfilter/benchmark/benchmark_r_mfilter_nprocs.py b/raster/r.mfilter/benchmark/benchmark_r_mfilter_nprocs.py index 2dc85b411d8..9a0591f7cfc 100644 --- a/raster/r.mfilter/benchmark/benchmark_r_mfilter_nprocs.py +++ b/raster/r.mfilter/benchmark/benchmark_r_mfilter_nprocs.py @@ -55,8 +55,7 @@ def benchmark(size, label, results): overwrite=True, ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=output) + Module("g.remove", quiet=True, flags="f", type="raster", name=(reference, output)) def generate_map(rows, cols, fname): diff --git a/raster/r.mfilter/main.c b/raster/r.mfilter/main.c index 17ecd2182be..ad0a9dd35ae 100644 --- a/raster/r.mfilter/main.c +++ b/raster/r.mfilter/main.c @@ -132,8 +132,8 @@ int main(int argc, char **argv) "threads setting.")); nprocs = 1; #endif - if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (nprocs > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); nprocs = 1; } out_name = opt2->answer; diff --git a/raster/r.mfilter/testsuite/test_r_mfilter.py b/raster/r.mfilter/testsuite/test_r_mfilter.py index 3d1764b4894..c18aa7c9273 100644 --- a/raster/r.mfilter/testsuite/test_r_mfilter.py +++ b/raster/r.mfilter/testsuite/test_r_mfilter.py @@ -1,6 +1,7 @@ from tempfile import NamedTemporaryFile from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows class TestNeighbors(TestCase): @@ -202,6 +203,7 @@ def tearDownClass(cls): "g.remove", flags="f", type="raster", name=",".join(cls.to_remove) ) + @xfail_windows def test_sequential(self): """Test output with sequential filter type.""" test_case = "test_sequential" @@ -235,6 +237,7 @@ def test_sequential(self): precision=1e-5, ) + @xfail_windows def test_parallel(self): """Test output with parallel filter type.""" test_case = "test_parallel" @@ -268,6 +271,7 @@ def test_parallel(self): precision=1e-5, ) + @xfail_windows def test_sequential_null(self): """Test output with sequential filter type with null mode enabled.""" test_case = "test_sequential_null" @@ -301,6 +305,7 @@ def test_sequential_null(self): precision=1e-5, ) + @xfail_windows def test_parallel_null(self): """Test output with parallel filter type with null mode enabled.""" test_case = "test_parallel_null" @@ -361,6 +366,7 @@ def test_parallel_null(self): precision=1e-5, ) + @xfail_windows def test_multiple_filters(self): """Test output with multiple filters.""" test_case = "test_multiple_filters" @@ -394,6 +400,7 @@ def test_multiple_filters(self): precision=1e-5, ) + @xfail_windows def test_repeated_filters(self): """Test output with repeated filters.""" test_case = "test_repeated_filters" diff --git a/raster/r.neighbors/benchmark/benchmark_r_neighbors_nprocs.py b/raster/r.neighbors/benchmark/benchmark_r_neighbors_nprocs.py index d355792a734..e7b3196c246 100644 --- a/raster/r.neighbors/benchmark/benchmark_r_neighbors_nprocs.py +++ b/raster/r.neighbors/benchmark/benchmark_r_neighbors_nprocs.py @@ -38,8 +38,7 @@ def benchmark(size, label, results): overwrite=True, ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=output) + Module("g.remove", quiet=True, flags="f", type="raster", name=(reference, output)) def generate_map(rows, cols, fname): diff --git a/raster/r.neighbors/main.c b/raster/r.neighbors/main.c index 93cbaa9e3da..8885460a564 100644 --- a/raster/r.neighbors/main.c +++ b/raster/r.neighbors/main.c @@ -310,8 +310,8 @@ int main(int argc, char *argv[]) "threads setting.")); ncb.threads = 1; #endif - if (ncb.threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (ncb.threads > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); ncb.threads = 1; } if (strcmp(parm.weighting_function->answer, "none") && flag.circle->answer) diff --git a/raster/r.null/r.null.html b/raster/r.null/r.null.html index 0a98907af5f..4d92b027d65 100644 --- a/raster/r.null/r.null.html +++ b/raster/r.null/r.null.html @@ -49,10 +49,12 @@

    External maps

    From the r.external documentation: GDAL-linked (r.external) maps do not have or use a NULL bitmap, hence r.null cannot manipulate them directly. Here NULL cells are those whose value matches -the value reported by the GDALGetRasterNoDataValue() function. To apply the -GDAL-linked the user need to either create a MASK (e.g. with r.mask) and -then "apply" it using e.g. r.resample, or use r.mapcalc to create a copy -with the appropriate categories changed to NULL (if() condition). +the value reported by the GDALGetRasterNoDataValue() function. +To introduce additional NULL values to a computation based on a GDAL-linked +raster, the user needs to either create a mask with with r.mask and +then "apply" it using e.g. r.resample or r.mapcalc, +or use r.mapcalc to create a copy with the appropriate categories +changed to NULL (if() condition).

    EXAMPLES

    diff --git a/raster/r.object.geometry/testsuite/test_r_object_geometry.py b/raster/r.object.geometry/testsuite/test_r_object_geometry.py index 419df4d780b..279d46ae4f0 100644 --- a/raster/r.object.geometry/testsuite/test_r_object_geometry.py +++ b/raster/r.object.geometry/testsuite/test_r_object_geometry.py @@ -6,11 +6,9 @@ import json import os -from sys import stderr from grass.gunittest.case import TestCase from grass.gunittest.main import test -from grass.gunittest.gmodules import call_module from grass.gunittest.gmodules import SimpleModule diff --git a/raster/r.out.gdal/r.out.gdal.html b/raster/r.out.gdal/r.out.gdal.html index 9cb5b9d8156..06d269944c5 100644 --- a/raster/r.out.gdal/r.out.gdal.html +++ b/raster/r.out.gdal/r.out.gdal.html @@ -9,7 +9,7 @@

    DESCRIPTION

    (createopt="TFW=YES,COMPRESS=DEFLATE").

    For possible createopt and metaopt parameters please consult the individual -supported formats +supported formats pages on the GDAL website. The createopt parameter may be used to create TFW or World files ("TFW=YES","WORLDFILE=ON"). @@ -25,7 +25,7 @@

    DESCRIPTION

    SUPPORTED RASTER FORMATS

    -The set of supported +The set of supported raster formats written by r.out.gdal depends on the local GDAL installation, printed with the -l flag. Available may be (incomplete list):

    @@ -66,9 +66,9 @@

    NOTES

    Moreover, some GDAL-supported formats do not support all the data types possible in GDAL and GRASS. Use r.info to check the data type and range for your GRASS raster, refer to specific -format documentation (on the GDAL website), +format documentation (on the GDAL website), format vendor's documentation, and e.g. the Wikipedia article - + Typical boundaries of primitive integral types for details. @@ -368,7 +368,7 @@

    GDAL RELATED ERROR MESSAGES

    REFERENCES

    -GDAL Pages: https://gdal.org +GDAL Pages: https://gdal.org

    SEE ALSO

    diff --git a/raster/r.out.mpeg/r.out.mpeg.html b/raster/r.out.mpeg/r.out.mpeg.html index e035fce04c5..eb282acbbd9 100644 --- a/raster/r.out.mpeg/r.out.mpeg.html +++ b/raster/r.out.mpeg/r.out.mpeg.html @@ -2,7 +2,7 @@

    DESCRIPTION

    r.out.mpeg is a tool for combining a series of GRASS raster maps into a single MPEG-1 -(Motion +(Motion Pictures Experts Group) format file. MPEG-1 is a "lossy" video compression format, so the quality of each resulting frame of the animation will be much diminished from the diff --git a/raster/r.patch/main.c b/raster/r.patch/main.c index 3835e287440..c54482db13a 100644 --- a/raster/r.patch/main.c +++ b/raster/r.patch/main.c @@ -113,8 +113,8 @@ int main(int argc, char *argv[]) "threads setting.")); nprocs = 1; #endif - if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (nprocs > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); nprocs = 1; } diff --git a/raster/r.proj/testsuite/test_rproj.py b/raster/r.proj/testsuite/test_rproj.py index 5f3834be881..678e8b7cd06 100644 --- a/raster/r.proj/testsuite/test_rproj.py +++ b/raster/r.proj/testsuite/test_rproj.py @@ -57,7 +57,7 @@ def run_rproj_test(self, method, statics): The expected statics of the output raster """ output = method - ## Get the boundary and set up region for the projected map + # Get the boundary and set up region for the projected map stdout = call_module( "r.proj", project=src_project, @@ -80,7 +80,7 @@ def run_rproj_test(self, method, statics): res=1, ) - ## Project the map + # Project the map self.assertModule( "r.proj", project=src_project, @@ -91,13 +91,13 @@ def run_rproj_test(self, method, statics): quiet=True, ) - ## Validate the output + # Validate the output self.assertRasterFitsUnivar(output, reference=statics, precision=1e-7) self.assertRasterFitsInfo(output, reference=raster_info, precision=1e-7) def test_nearest(self): """Testing method nearest""" - ## Set up variables and validation values + # Set up variables and validation values method = "nearest" statics = """n=40930 min=55.5787925720215 @@ -109,7 +109,7 @@ def test_nearest(self): def test_bilinear(self): """Testing method bilinear""" - ## Set up variables and validation values + # Set up variables and validation values method = "bilinear" statics = """n=40845 min=56.3932914733887 @@ -121,7 +121,7 @@ def test_bilinear(self): def test_bicubic(self): """Testing method bicubic""" - ## Set up variables and validation values + # Set up variables and validation values method = "bicubic" statics = """n=40677 min=56.2407836914062 @@ -133,7 +133,7 @@ def test_bicubic(self): def test_lanczos(self): """Testing method lanczos""" - ## Set up variables and validation values + # Set up variables and validation values method = "lanczos" statics = """n=40585 min=56.2350921630859 @@ -145,7 +145,7 @@ def test_lanczos(self): def test_bilinear_f(self): """Testing method bilinear_f""" - ## Set up variables and validation values + # Set up variables and validation values method = "bilinear_f" statics = """n=40930 min=55.5787925720215 @@ -157,7 +157,7 @@ def test_bilinear_f(self): def test_bicubic_f(self): """Testing method bicubic_f""" - ## Set up variables and validation values + # Set up variables and validation values method = "bicubic_f" statics = """n=40930 min=55.5787925720215 @@ -169,7 +169,7 @@ def test_bicubic_f(self): def test_lanczos_f(self): """Testing method lanczos_f""" - ## Set up variables and validation values + # Set up variables and validation values method = "lanczos_f" statics = """n=40930 min=55.5787925720215 diff --git a/raster/r.random/testsuite/test_r_random.py b/raster/r.random/testsuite/test_r_random.py index ce12c719c8e..16aae357ebf 100644 --- a/raster/r.random/testsuite/test_r_random.py +++ b/raster/r.random/testsuite/test_r_random.py @@ -28,30 +28,30 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - cls.runModule("g.remove", type="raster", flags="f", name=cls.raster) - cls.runModule("g.remove", type="raster", flags="f", name=cls.raster + "_null") - cls.runModule( - "g.remove", type="raster", flags="f", name=cls.raster + "_without_topology" - ) - cls.runModule("g.remove", type="raster", flags="f", name=cls.raster + "_3D") cls.runModule( "g.remove", type="raster", flags="f", - name=cls.raster + "_cover_landcover_1m", + name=( + cls.raster, + cls.raster + "_null", + cls.raster + "_without_topology", + cls.raster + "_3D", + cls.raster + "_cover_landcover_1m", + ), ) - cls.runModule("g.remove", type="vector", flags="f", name=cls.vector) - cls.runModule("g.remove", type="vector", flags="f", name=cls.vector + "_null") - cls.runModule( - "g.remove", type="vector", flags="f", name=cls.vector + "_without_topology" - ) - cls.runModule("g.remove", type="vector", flags="f", name=cls.vector + "_3D") cls.runModule( "g.remove", type="vector", flags="f", - name=cls.vector + "_cover_landcover_1m", + name=( + cls.vector, + cls.vector + "_null", + cls.vector + "_without_topology", + cls.vector + "_3D", + cls.vector + "_cover_landcover_1m", + ), ) def test_random_raster(self): diff --git a/raster/r.reclass/testsuite/test_r_reclass.py b/raster/r.reclass/testsuite/test_r_reclass.py index 3f4ecfdf6a3..8b1eb2e523a 100644 --- a/raster/r.reclass/testsuite/test_r_reclass.py +++ b/raster/r.reclass/testsuite/test_r_reclass.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2017 Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/raster/r.report/testsuite/test_r_report.py b/raster/r.report/testsuite/test_r_report.py index 53e49fdc174..86a16c27adb 100644 --- a/raster/r.report/testsuite/test_r_report.py +++ b/raster/r.report/testsuite/test_r_report.py @@ -17,6 +17,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows class TestRasterreport(TestCase): @@ -294,6 +295,7 @@ def test_json(self): data = json.loads(module.outputs.stdout) self._assert_report_equal(reference, data) + @xfail_windows def test_json2(self): """Test JSON format with more options""" reference = { diff --git a/raster/r.resamp.filter/benchmark/benchmark_r_resamp_filter.py b/raster/r.resamp.filter/benchmark/benchmark_r_resamp_filter.py index 8c7799e74fc..9ec46132c81 100644 --- a/raster/r.resamp.filter/benchmark/benchmark_r_resamp_filter.py +++ b/raster/r.resamp.filter/benchmark/benchmark_r_resamp_filter.py @@ -40,8 +40,7 @@ def benchmark(size, label, results): overwrite=True, ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=8, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=output) + Module("g.remove", quiet=True, flags="f", type="raster", name=(reference, output)) def generate_map(rows, cols, fname): diff --git a/raster/r.resamp.filter/main.c b/raster/r.resamp.filter/main.c index b1f6ed3e530..e74f3598629 100644 --- a/raster/r.resamp.filter/main.c +++ b/raster/r.resamp.filter/main.c @@ -494,8 +494,8 @@ int main(int argc, char *argv[]) "threads setting.")); nprocs = 1; #endif - if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (nprocs > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active make.")); nprocs = 1; } if (parm.radius->answer) { diff --git a/raster/r.resamp.filter/r.resamp.filter.html b/raster/r.resamp.filter/r.resamp.filter.html index 0690a090b74..2872efd8774 100644 --- a/raster/r.resamp.filter/r.resamp.filter.html +++ b/raster/r.resamp.filter/r.resamp.filter.html @@ -14,7 +14,7 @@

    DESCRIPTION

    r.resamp.filter implements FIR (finite impulse response) filtering. All of the functions are low-pass filters, as they are symmetric. See -Wikipedia: Window function +Wikipedia: Window function for examples of common window functions and their frequency responses.

    @@ -63,7 +63,7 @@

    NOTES

    cover 3 times as large a time interval) as lanczos1 in order to get a similar frequency response (higher-order filters will fall off faster, but the frequency at which the fall-off starts should be the same). See -Wikipedia: Lanczos-kernel.svg +Wikipedia: Lanczos-kernel.svg for an illustration. If both graphs were drawn on the same axes, they would have roughly the same shape, but the a=3 window would have a longer tail. By scaling the axes to the same width, the a=3 window has a narrower diff --git a/raster/r.resamp.interp/benchmark/benchmark_r_resamp_interp.py b/raster/r.resamp.interp/benchmark/benchmark_r_resamp_interp.py index 20196bc44bc..616dc045aa3 100644 --- a/raster/r.resamp.interp/benchmark/benchmark_r_resamp_interp.py +++ b/raster/r.resamp.interp/benchmark/benchmark_r_resamp_interp.py @@ -38,8 +38,7 @@ def benchmark(size, label, results): overwrite=True, ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=output) + Module("g.remove", quiet=True, flags="f", type="raster", name=(reference, output)) def generate_map(rows, cols, fname): diff --git a/raster/r.resamp.interp/main.c b/raster/r.resamp.interp/main.c index 734f3306bf8..2319400b0fc 100644 --- a/raster/r.resamp.interp/main.c +++ b/raster/r.resamp.interp/main.c @@ -132,8 +132,8 @@ int main(int argc, char *argv[]) "threads setting.")); threads = 1; #endif - if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (threads > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); threads = 1; } bufrows = atoi(memory->answer) * (((1 << 20) / sizeof(DCELL)) / dst_w.cols); diff --git a/raster/r.resamp.interp/r.resamp.interp.html b/raster/r.resamp.interp/r.resamp.interp.html index e4b77ac0d34..3c3eecc68a9 100644 --- a/raster/r.resamp.interp/r.resamp.interp.html +++ b/raster/r.resamp.interp/r.resamp.interp.html @@ -28,7 +28,7 @@

    NOTES

    Note that for bilinear, bicubic and lanczos interpolation, cells of the output raster that cannot be bounded by the appropriate number of input cell centers are set to NULL (NULL propagation). This could occur -due to the input cells being outside the current region, being NULL or MASKed. +due to the input cells being outside the current region, being NULL or masked.

    For longitude-latitude coordinate reference systems, diff --git a/raster/r.series/benchmark/benchmark_r_series.py b/raster/r.series/benchmark/benchmark_r_series.py index ecf4432f2dd..72c9c3bd23c 100644 --- a/raster/r.series/benchmark/benchmark_r_series.py +++ b/raster/r.series/benchmark/benchmark_r_series.py @@ -37,8 +37,7 @@ def benchmark(size, label, results): overwrite=True, ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=output) + Module("g.remove", quiet=True, flags="f", type="raster", name=(reference, output)) def generate_map(rows, cols, fname): diff --git a/raster/r.series/main.c b/raster/r.series/main.c index bfecbf117c0..ade93d8f185 100644 --- a/raster/r.series/main.c +++ b/raster/r.series/main.c @@ -227,8 +227,8 @@ int main(int argc, char *argv[]) "threads setting.")); nprocs = 1; #endif - if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (nprocs > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); nprocs = 1; } lo = -INFINITY; diff --git a/raster/r.series/testsuite/test_r_series.py b/raster/r.series/testsuite/test_r_series.py index 93bfd129242..e067a26e1da 100644 --- a/raster/r.series/testsuite/test_r_series.py +++ b/raster/r.series/testsuite/test_r_series.py @@ -18,13 +18,13 @@ def setUpClass(cls): call_module("r.mapcalc", expression=f"{cls.sum_mapcalc} = {cls.elevation} * 4") @classmethod - def tearDownClass(self): - self.del_temp_region() + def tearDownClass(cls): + cls.del_temp_region() call_module( "g.remove", flags="f", type_="raster", - name=self.sum_mapcalc, + name=cls.sum_mapcalc, ) def tearDown(self): diff --git a/raster/r.sim/r.sim.sediment/Makefile b/raster/r.sim/r.sim.sediment/Makefile index 4bc07478ec9..13ca19d09dc 100644 --- a/raster/r.sim/r.sim.sediment/Makefile +++ b/raster/r.sim/r.sim.sediment/Makefile @@ -4,8 +4,8 @@ PGM=r.sim.sediment EXTRA_CLEAN_DIRS=doxygenhtml -LIBES = $(SIMLIB) $(GMATHLIB) $(GISLIB) $(OPENMP_LIBPATH) $(OPENMP_LIB) -DEPENDENCIES = $(SIMDEP) $(GMATHDEP) $(GISDEP) +LIBES = $(SIMLIB) $(GMATHLIB) $(GISLIB) $(RASTERLIB) $(OPENMP_LIBPATH) $(OPENMP_LIB) +DEPENDENCIES = $(SIMDEP) $(GMATHDEP) $(GISDEP) $(RASTERDEP) EXTRA_INC = $(OPENMP_INCPATH) $(VECT_INC) EXTRA_CFLAGS = -I ../simlib $(VECT_CFLAGS) $(OPENMP_CFLAGS) diff --git a/raster/r.sim/r.sim.sediment/main.c b/raster/r.sim/r.sim.sediment/main.c index fcdd9e98f89..d0197c2abb1 100644 --- a/raster/r.sim/r.sim.sediment/main.c +++ b/raster/r.sim/r.sim.sediment/main.c @@ -70,6 +70,7 @@ #endif #include #include +#include #include #include #include @@ -380,8 +381,8 @@ int main(int argc, char *argv[]) #else threads = 1; #endif - if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (threads > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); threads = 1; } G_message(_("Number of threads: %d"), threads); @@ -416,6 +417,8 @@ int main(int argc, char *argv[]) G_message(_("Using metric conversion factor %f, step=%f"), wp.conv, wp.step); + wp.observation = parm.observation->answer; + wp.logfile = parm.logfile->answer; init_library_globals(&wp); if ((wp.tc == NULL) && (wp.et == NULL) && (wp.conc == NULL) && diff --git a/raster/r.sim/r.sim.sediment/r.sim.sediment.html b/raster/r.sim/r.sim.sediment/r.sim.sediment.html index 025fa3f72b1..caebb9c308c 100644 --- a/raster/r.sim/r.sim.sediment/r.sim.sediment.html +++ b/raster/r.sim/r.sim.sediment/r.sim.sediment.html @@ -71,7 +71,7 @@

    REFERENCES

    In: Landscape erosion and landscape evolution modeling, Harmon R. and Doe W. eds., Kluwer Academic/Plenum Publishers, pp. 321-347.

    - + Neteler, M. and Mitasova, H., 2008, Open Source GIS: A GRASS GIS Approach. Third Edition. The International Series in Engineering and Computer Science: Volume 773. Springer New York Inc, p. 406. diff --git a/raster/r.sim/r.sim.water/Makefile b/raster/r.sim/r.sim.water/Makefile index 36121ebf82e..47037823fae 100644 --- a/raster/r.sim/r.sim.water/Makefile +++ b/raster/r.sim/r.sim.water/Makefile @@ -4,8 +4,8 @@ PGM=r.sim.water EXTRA_CLEAN_DIRS=doxygenhtml -LIBES = $(SIMLIB) $(GMATHLIB) $(GISLIB) $(OPENMP_LIBPATH) $(OPENMP_LIB) -DEPENDENCIES = $(SIMDEP) $(GMATHDEP) $(GISDEP) +LIBES = $(SIMLIB) $(GMATHLIB) $(GISLIB) $(RASTERLIB) $(OPENMP_LIBPATH) $(OPENMP_LIB) +DEPENDENCIES = $(SIMDEP) $(GMATHDEP) $(GISDEP) $(RASTERDEP) EXTRA_INC = $(VECT_INC) $(OPENMP_INCPATH) EXTRA_CFLAGS = -I ../simlib $(VECT_CFLAGS) $(OPENMP_CFLAGS) diff --git a/raster/r.sim/r.sim.water/main.c b/raster/r.sim/r.sim.water/main.c index 3998e5524ac..209be3e33d9 100644 --- a/raster/r.sim/r.sim.water/main.c +++ b/raster/r.sim/r.sim.water/main.c @@ -77,6 +77,7 @@ #endif #include #include +#include #include #include #include @@ -219,7 +220,7 @@ int main(int argc, char *argv[]) parm.logfile->required = NO; parm.logfile->description = _("Name for sampling points output text file. For each observation " - "vector point the time series of sediment transport is stored."); + "vector point the time series of water discharge is stored."); parm.logfile->guisection = _("Output"); parm.nwalk = G_define_option(); @@ -407,8 +408,8 @@ int main(int argc, char *argv[]) #else threads = 1; #endif - if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (threads > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); threads = 1; } G_message(_("Number of threads: %d"), threads); @@ -524,6 +525,8 @@ int main(int argc, char *argv[]) G_message(_("Using metric conversion factor %f, step=%f"), wp.conv, wp.step); + wp.observation = parm.observation->answer; + wp.logfile = parm.logfile->answer; init_library_globals(&wp); if ((wp.depth == NULL) && (wp.disch == NULL) && (wp.err == NULL)) diff --git a/raster/r.sim/r.sim.water/r.sim.water.html b/raster/r.sim/r.sim.water/r.sim.water.html index 3c920473ca9..79cef1bfadc 100644 --- a/raster/r.sim/r.sim.water/r.sim.water.html +++ b/raster/r.sim/r.sim.water/r.sim.water.html @@ -237,7 +237,7 @@

    REFERENCES

    April 2015
  • Neteler, M. and Mitasova, H., 2008, -Open Source GIS: A GRASS GIS Approach. Third Edition. +Open Source GIS: A GRASS GIS Approach. Third Edition. The International Series in Engineering and Computer Science: Volume 773. Springer New York Inc, p. 406. diff --git a/raster/r.sim/r.sim.water/testsuite/data/depth_complex.pack b/raster/r.sim/r.sim.water/testsuite/data/depth_complex.pack new file mode 100644 index 00000000000..60f9de2be64 Binary files /dev/null and b/raster/r.sim/r.sim.water/testsuite/data/depth_complex.pack differ diff --git a/raster/r.sim/r.sim.water/testsuite/data/depth_default.pack b/raster/r.sim/r.sim.water/testsuite/data/depth_default.pack new file mode 100644 index 00000000000..579863ecca9 Binary files /dev/null and b/raster/r.sim/r.sim.water/testsuite/data/depth_default.pack differ diff --git a/raster/r.sim/r.sim.water/testsuite/data/discharge_complex.pack b/raster/r.sim/r.sim.water/testsuite/data/discharge_complex.pack new file mode 100644 index 00000000000..01810de0cb6 Binary files /dev/null and b/raster/r.sim/r.sim.water/testsuite/data/discharge_complex.pack differ diff --git a/raster/r.sim/r.sim.water/testsuite/data/discharge_default.pack b/raster/r.sim/r.sim.water/testsuite/data/discharge_default.pack new file mode 100644 index 00000000000..914eabcda47 Binary files /dev/null and b/raster/r.sim/r.sim.water/testsuite/data/discharge_default.pack differ diff --git a/raster/r.sim/r.sim.water/testsuite/test_r_sim_water.py b/raster/r.sim/r.sim.water/testsuite/test_r_sim_water.py new file mode 100644 index 00000000000..44ea662276a --- /dev/null +++ b/raster/r.sim/r.sim.water/testsuite/test_r_sim_water.py @@ -0,0 +1,201 @@ +import unittest + +from grass.gunittest.case import TestCase + + +class TestRSimWater(TestCase): + """Test r.sim.water""" + + # Set up the necessary raster maps for testing + elevation = "elevation" + dx = "tmp_dx" + dy = "tmp_dy" + depth = "tmp_depth" + discharge = "tmp_discharge" + rain = "tmp_rain" + mannings = "tmp_mannings" + infil = "tmp_infil" + reference_depth_default = "depth_default" + reference_discharge_default = "discharge_default" + reference_depth_complex = "depth_complex" + reference_discharge_complex = "discharge_complex" + + @classmethod + def setUpClass(cls): + """Set up region, create necessary data""" + cls.runModule("g.region", n=224000, s=223000, e=637000, w=636000, res=10) + cls.runModule("r.slope.aspect", elevation=cls.elevation, dx=cls.dx, dy=cls.dy) + cls.runModule( + "r.unpack", + input="data/depth_default.pack", + output=cls.reference_depth_default, + ) + cls.runModule( + "r.unpack", + input="data/discharge_default.pack", + output=cls.reference_discharge_default, + ) + cls.runModule( + "r.random.surface", output=cls.rain, distance=200, seed=1, high=100 + ) + cls.runModule( + "r.mapcalc", + expression=f"{cls.mannings} = if (x() > 636500 && y() > 223500, 0.3, 0.01)", + ) + cls.runModule( + "r.mapcalc", + expression=f"{cls.infil} = if (x() < 636500 && y() > 223500, 0.001, 0)", + ) + cls.runModule( + "r.unpack", + input="data/depth_complex.pack", + output=cls.reference_depth_complex, + ) + cls.runModule( + "r.unpack", + input="data/discharge_complex.pack", + output=cls.reference_discharge_complex, + ) + + @classmethod + def tearDownClass(cls): + """Clean up test environment""" + cls.runModule( + "g.remove", + flags="f", + type="raster", + name=[ + cls.elevation, + cls.dx, + cls.dy, + cls.reference_depth_default, + cls.reference_discharge_default, + cls.rain, + cls.mannings, + cls.infil, + cls.reference_depth_complex, + cls.reference_discharge_complex, + ], + ) + + def tearDown(self): + """Clean up test environment""" + self.runModule( + "g.remove", + flags="f", + type="raster", + pattern=f"{self.depth}*,{self.discharge}*", + ) + + def test_default(self): + """Test r.sim.water execution with defaults""" + # Run the r.sim.water simulation + self.assertModule( + "r.sim.water", + elevation=self.elevation, + dx=self.dx, + dy=self.dy, + depth=self.depth, + discharge=self.discharge, + random_seed=1, + ) + + # Assert that the output rasters exist + self.assertRasterExists(self.depth) + self.assertRasterExists(self.discharge) + # Assert that the output rasters are the same + self.assertRastersEqual( + self.depth, reference=self.reference_depth_default, precision="0.000001" + ) + self.assertRastersEqual( + self.discharge, + reference=self.reference_discharge_default, + precision="0.000001", + ) + + def test_complex(self): + """Test r.sim.water execution with more complex inputs""" + # Run the r.sim.water simulation + self.assertModule( + "r.sim.water", + flags="t", + elevation=self.elevation, + dx=self.dx, + dy=self.dy, + rain=self.rain, + man=self.mannings, + infil=self.infil, + depth=self.depth, + discharge=self.discharge, + niterations=15, + output_step=5, + diffusion_coeff=0.9, + hmax=0.25, + halpha=3.9, + hbeta=0.6, + random_seed=1, + ) + + # Assert that the output rasters exist + self.assertRasterExists(f"{self.depth}.05") + self.assertRasterExists(f"{self.depth}.10") + self.assertRasterExists(f"{self.depth}.15") + # Assert that the output rasters are the same + self.assertRastersEqual( + f"{self.depth}.15", + reference=self.reference_depth_complex, + precision="0.000001", + ) + self.assertRastersEqual( + f"{self.discharge}.15", + reference=self.reference_discharge_complex, + precision="0.000001", + ) + + +@unittest.skip("runs too long") +class TestRSimWaterLarge(TestCase): + """Test r.sim.water with large region""" + + # Set up the necessary raster maps for testing + elevation = "elevation" + dx = "tmp_dx" + dy = "tmp_dy" + depth = "tmp_depth" + + @classmethod + def setUpClass(cls): + """Set up region, create necessary data""" + cls.runModule("g.region", raster=cls.elevation) + cls.runModule("r.slope.aspect", elevation=cls.elevation, dx=cls.dx, dy=cls.dy) + + @classmethod + def tearDownClass(cls): + """Clean up test environment""" + cls.runModule( + "g.remove", + flags="f", + type="raster", + name=[cls.elevation, cls.dx, cls.dy, cls.depth], + ) + + def test_default(self): + """Test r.sim.water execution with defaults""" + # Run the r.sim.water simulation + self.assertModule( + "r.sim.water", + elevation=self.elevation, + dx=self.dx, + dy=self.dy, + depth=self.depth, + random_seed=1, + ) + self.assertRasterFitsUnivar( + self.depth, reference="sum=30364.327529", precision=1e-6 + ) + + +if __name__ == "__main__": + from grass.gunittest.main import test + + test() diff --git a/raster/r.sim/simlib/hydro.c b/raster/r.sim/simlib/hydro.c index 74145ec9bff..eb7649763e9 100644 --- a/raster/r.sim/simlib/hydro.c +++ b/raster/r.sim/simlib/hydro.c @@ -151,9 +151,6 @@ void main_loop(void) maxwa = maxwa / nblock; } - /* Create the observation points */ - create_observation_points(); - G_debug(2, " maxwa, nblock %d %d", maxwa, nblock); for (iblock = 1; iblock <= nblock; iblock++) { diff --git a/raster/r.slope.aspect/benchmark/benchmark_r_slope_aspect.py b/raster/r.slope.aspect/benchmark/benchmark_r_slope_aspect.py index 220b813e323..522a938f26c 100644 --- a/raster/r.slope.aspect/benchmark/benchmark_r_slope_aspect.py +++ b/raster/r.slope.aspect/benchmark/benchmark_r_slope_aspect.py @@ -42,11 +42,13 @@ def benchmark(size, label, results): overwrite=True, ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=slope) - Module("g.remove", quiet=True, flags="f", type="raster", name=aspect) - Module("g.remove", quiet=True, flags="f", type="raster", name=pcurv) - Module("g.remove", quiet=True, flags="f", type="raster", name=tcurv) + Module( + "g.remove", + quiet=True, + flags="f", + type="raster", + name=(reference, slope, aspect, pcurv, tcurv), + ) def generate_map(rows, cols, fname): diff --git a/raster/r.slope.aspect/benchmark/benchmark_r_slope_aspect_memory.py b/raster/r.slope.aspect/benchmark/benchmark_r_slope_aspect_memory.py index c8f5ac09f00..31824233bbc 100644 --- a/raster/r.slope.aspect/benchmark/benchmark_r_slope_aspect_memory.py +++ b/raster/r.slope.aspect/benchmark/benchmark_r_slope_aspect_memory.py @@ -46,10 +46,13 @@ def benchmark(memory, label, results, reference): ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=20, repeat=10)) - Module("g.remove", quiet=True, flags="f", type="raster", name=slope) - Module("g.remove", quiet=True, flags="f", type="raster", name=aspect) - Module("g.remove", quiet=True, flags="f", type="raster", name=pcurv) - Module("g.remove", quiet=True, flags="f", type="raster", name=tcurv) + Module( + "g.remove", + quiet=True, + flags="f", + type="raster", + name=(slope, aspect, pcurv, tcurv), + ) def generate_map(rows, cols, fname): diff --git a/raster/r.slope.aspect/main.c b/raster/r.slope.aspect/main.c index 86b4d5f5607..d302e02b22c 100644 --- a/raster/r.slope.aspect/main.c +++ b/raster/r.slope.aspect/main.c @@ -305,8 +305,8 @@ int main(int argc, char *argv[]) "threads setting.")); nprocs = 1; #endif - if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (nprocs > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); nprocs = 1; } radians_to_degrees = 180.0 / M_PI; diff --git a/raster/r.stream.extract/r.stream.extract.html b/raster/r.stream.extract/r.stream.extract.html index e1c427599e8..acc9030d0b0 100644 --- a/raster/r.stream.extract/r.stream.extract.html +++ b/raster/r.stream.extract/r.stream.extract.html @@ -126,7 +126,9 @@

    Defining a region of interest

    The stream extraction procedure can be restricted to a certain region of interest, e.g. a subbasin, by setting the computational region with -g.region and/or creating a MASK. Such region of interest should +g.region and/or creating a mask +with r.mask. +Such region of interest should be a complete catchment area, complete in the sense that the complete area upstream of an outlet point is included and buffered with at least one cell. @@ -256,7 +258,7 @@

    REFERENCES

  • Holmgren, P. (1994). Multiple flow direction algorithms for runoff modelling in grid based elevation models: An empirical evaluation. -Hydrological Processes Vol 8(4), pp 327-334. DOI: 10.1002/hyp.3360080405
  • +Hydrological Processes Vol 8(4), pp 327-334. DOI: 10.1002/hyp.3360080405
  • Montgomery, D.R., Foufoula-Georgiou, E. (1993). Channel network source representation using digital elevation models. Water Resources Research Vol 29(12), pp 3925-3934.
  • diff --git a/raster/r.sun/TODO b/raster/r.sun/TODO index 3e54873977e..4d31c0314df 100644 --- a/raster/r.sun/TODO +++ b/raster/r.sun/TODO @@ -16,10 +16,10 @@ Update https://grasswiki.osgeo.org/wiki/R.sun #### -Fix http://trac.osgeo.org/grass/ticket/498 +Fix https://trac.osgeo.org/grass/ticket/498 pseudo-data test-case -http://trac.osgeo.org/grass/ticket/498#comment:22 +https://trac.osgeo.org/grass/ticket/498#comment:22 #spearfish (further north than NC so more defined shadows) g.region -d r.mapcalc "undulates = (2 + sin( row() * 2 ) + cos( col() * 2 )) * 500" diff --git a/raster/r.sun/main.c b/raster/r.sun/main.c index 9e45e184dac..e325cb637f0 100644 --- a/raster/r.sun/main.c +++ b/raster/r.sun/main.c @@ -591,8 +591,8 @@ int main(int argc, char *argv[]) #else threads = 1; #endif - if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (threads > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); threads = 1; } G_message(_("Number of threads <%d>"), threads); diff --git a/raster/r.sun/r.sun.html b/raster/r.sun/r.sun.html index 189633f9f48..ec43813d51c 100644 --- a/raster/r.sun/r.sun.html +++ b/raster/r.sun/r.sun.html @@ -345,7 +345,7 @@

    REFERENCES

  • Neteler, M., Mitasova, H. (2002): Open Source GIS: A GRASS GIS Approach, Kluwer Academic Publishers. (Appendix explains formula; -r.sun script download) +r.sun script download)
  • Page, J. ed. (1986). Prediction of solar radiation on inclined surfaces. Solar energy R&D in the European Community, series F - Solar radiation data, diff --git a/raster/r.support/r.support.html b/raster/r.support/r.support.html index 111e46f653d..13fdf2a26af 100644 --- a/raster/r.support/r.support.html +++ b/raster/r.support/r.support.html @@ -5,12 +5,13 @@

    DESCRIPTION

    history, semantic label elements and title is supported. Category labels can also be copied from another raster map. -

    Raster band management

    +

    Raster semantic labels and band management

    + Raster semantic label concept is similar to dimension name in other GIS and -remote sensing applications. Most common usage will be assigning a -remote sensing platform sensor band ID to the raster, although any -identifier is supported. Raster semantic label is suggested to work with -imagery classification tools.
    +remote sensing applications. Most common usage will be assigning a remote +sensing platform sensor band identifier to the raster map metadata, although +any identifier is supported (see i.band.library). +Raster semantic label is suggested to work with imagery classification tools.

    EXAMPLES

    @@ -57,12 +58,14 @@

    NOTES

    SEE ALSO

    +i.band.library, r.category, r.describe, r.info, r.null, r.region, r.report, +r.semantic.label, r.timestamp diff --git a/raster/r.surf.fractal/r.surf.fractal.html b/raster/r.surf.fractal/r.surf.fractal.html index d564cbec4e1..2a2a3e3a060 100644 --- a/raster/r.surf.fractal/r.surf.fractal.html +++ b/raster/r.surf.fractal/r.surf.fractal.html @@ -11,7 +11,7 @@

    DESCRIPTION

    NOTE

    -This module requires the FFTW library +This module requires the FFTW library for computing Discrete Fourier Transforms.

    EXAMPLE

    diff --git a/raster/r.terraflow/fill.cpp b/raster/r.terraflow/fill.cpp index ab1629a3b7f..c7b54cd0a47 100644 --- a/raster/r.terraflow/fill.cpp +++ b/raster/r.terraflow/fill.cpp @@ -518,7 +518,7 @@ void assignFinalDirections(AMI_STREAM *statstr, continue; } } -}; +} /* ********************************************************************** */ class directionElevationMerger { diff --git a/raster/r.terraflow/genericWindow.cpp b/raster/r.terraflow/genericWindow.cpp index 92b0852cd71..9b114773e2a 100644 --- a/raster/r.terraflow/genericWindow.cpp +++ b/raster/r.terraflow/genericWindow.cpp @@ -36,4 +36,4 @@ void fillPit(ElevationWindow &win) if (win.get(4) < min) { win.set(4, min); } -}; +} diff --git a/raster/r.terraflow/sweep.cpp b/raster/r.terraflow/sweep.cpp index 2f7fba8bb13..c98b844b016 100644 --- a/raster/r.terraflow/sweep.cpp +++ b/raster/r.terraflow/sweep.cpp @@ -65,7 +65,7 @@ sweepOutput::sweepOutput() #ifdef OUTPUT_TCI tci = (tci_type)nodataType::ELEVATION_NODATA; #endif -}; +} /* ------------------------------------------------------------ */ /* computes output parameters of cell (i,j) given the flow value, the diff --git a/raster/r.terraflow/testsuite/test_r_terraflow.py b/raster/r.terraflow/testsuite/test_r_terraflow.py index 62ee0eee15d..4085151a337 100644 --- a/raster/r.terraflow/testsuite/test_r_terraflow.py +++ b/raster/r.terraflow/testsuite/test_r_terraflow.py @@ -23,25 +23,25 @@ def tearDownClass(cls): """!Remove the temporary region""" cls.del_temp_region() - def setUp(cls): + def setUp(self): """Create input data for steady state groundwater flow computation""" - if not os.path.exists(cls.testdir): - os.mkdir(cls.testdir) + if not os.path.exists(self.testdir): + os.mkdir(self.testdir) - def test_univar_mfd(cls): + def test_univar_mfd(self): # compute a steady state groundwater flow - cls.assertModule( + self.assertModule( "r.terraflow", overwrite=True, verbose=True, - elevation=cls.elevation, + elevation=self.elevation, filled="terra_flooded", direction="terra_flowdir", swatershed="terra_sink", accumulation="terra_flowaccum", tci="terra_tci", - directory=cls.testdir, - stats=cls.teststats, + directory=self.testdir, + stats=self.teststats, ) # Output of r.univar -g @@ -111,16 +111,16 @@ def test_univar_mfd(cls): sum=8341670.75914752""" # cls.assertRasterFitsUnivar(raster="terra_flooded", reference=terra_flooded_univar, precision=3) - cls.assertRasterFitsUnivar( + self.assertRasterFitsUnivar( raster="terra_flowdir", reference=terra_flowdir_univar, precision=3 ) - cls.assertRasterFitsUnivar( + self.assertRasterFitsUnivar( raster="terra_sink", reference=terra_sink_univar, precision=3 ) - cls.assertRasterFitsUnivar( + self.assertRasterFitsUnivar( raster="terra_flowaccum", reference=terra_flowaccum_univar, precision=3 ) - cls.assertRasterFitsUnivar( + self.assertRasterFitsUnivar( raster="terra_tci", reference=terra_tci_univar, precision=3 ) diff --git a/raster/r.terraflow/weightWindow.cpp b/raster/r.terraflow/weightWindow.cpp index ccf55a82ca9..760dccc6b5c 100644 --- a/raster/r.terraflow/weightWindow.cpp +++ b/raster/r.terraflow/weightWindow.cpp @@ -229,7 +229,7 @@ void weightWindow::compute(const dimension_type i, const dimension_type j, cout << form("%3.2f ", weight.get(l)); cout << "]\n"; #endif -}; +} /* Find the dominant direction. Set corresponding weight to 1, and sets all other weights to 0. Set sumweight and sumcontour.*/ diff --git a/raster/r.thin/io.c b/raster/r.thin/io.c index d5ba76245c3..3b2d0bd8aa3 100644 --- a/raster/r.thin/io.c +++ b/raster/r.thin/io.c @@ -67,13 +67,17 @@ int put_a_row(int row, CELL *buf) static int read_row(int file, void *buf, int row, int buf_len) { - lseek(file, ((off_t)row) * buf_len, 0); + if (lseek(file, ((off_t)row) * buf_len, 0) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } return (read(file, buf, buf_len) == buf_len); } static int write_row(int file, const void *buf, int row, int buf_len) { - lseek(file, ((off_t)row) * buf_len, 0); + if (lseek(file, ((off_t)row) * buf_len, 0) == -1) { + G_fatal_error(_("Unable to seek: %s"), strerror(errno)); + } return (write(file, buf, buf_len) == buf_len); } diff --git a/raster/r.tile/testsuite/test_r_tile.py b/raster/r.tile/testsuite/test_r_tile.py index f1dd3afcd3b..c2e62b60dd2 100644 --- a/raster/r.tile/testsuite/test_r_tile.py +++ b/raster/r.tile/testsuite/test_r_tile.py @@ -28,42 +28,20 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): cls.del_temp_region() - cls.runModule( - "g.remove", type="raster", flags="f", name=cls.output_prefix + "-000-000" - ) - cls.runModule( - "g.remove", type="raster", flags="f", name=cls.output_prefix + "-000-001" - ) - cls.runModule( - "g.remove", type="raster", flags="f", name=cls.output_prefix + "-001-000" - ) - cls.runModule( - "g.remove", type="raster", flags="f", name=cls.output_prefix + "-001-001" - ) - - cls.runModule( - "g.remove", - type="raster", - flags="f", - name=cls.output_prefix + "overlap" + "-000-000", - ) - cls.runModule( - "g.remove", - type="raster", - flags="f", - name=cls.output_prefix + "overlap" + "-000-001", - ) - cls.runModule( - "g.remove", - type="raster", - flags="f", - name=cls.output_prefix + "overlap" + "-001-000", - ) cls.runModule( "g.remove", type="raster", flags="f", - name=cls.output_prefix + "overlap" + "-001-001", + name=( + cls.output_prefix + "-000-000", + cls.output_prefix + "-000-001", + cls.output_prefix + "-001-000", + cls.output_prefix + "-001-001", + cls.output_prefix + "overlap" + "-000-000", + cls.output_prefix + "overlap" + "-000-001", + cls.output_prefix + "overlap" + "-001-000", + cls.output_prefix + "overlap" + "-001-001", + ), ) def test_raster_tile(self): diff --git a/raster/r.tile/testsuite/testrt.py b/raster/r.tile/testsuite/testrt.py index 6cb5a91c296..a26ff967d33 100644 --- a/raster/r.tile/testsuite/testrt.py +++ b/raster/r.tile/testsuite/testrt.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2018 Copyright: (C) 2018 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/raster/r.to.vect/testsuite/test_r_to_vect.py b/raster/r.to.vect/testsuite/test_r_to_vect.py index fbd27af6a33..7826bf44084 100644 --- a/raster/r.to.vect/testsuite/test_r_to_vect.py +++ b/raster/r.to.vect/testsuite/test_r_to_vect.py @@ -28,8 +28,8 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - def tearDown(cls): - cls.runModule("g.remove", type="vector", flags="f", name=cls.output) + def tearDown(self): + self.runModule("g.remove", type="vector", flags="f", name=self.output) def test_flags(self): """Testing flag s""" diff --git a/raster/r.topidx/arc_to_gridatb.py b/raster/r.topidx/arc_to_gridatb.py index 17e49365697..3eba7114430 100755 --- a/raster/r.topidx/arc_to_gridatb.py +++ b/raster/r.topidx/arc_to_gridatb.py @@ -9,9 +9,8 @@ def match(pattern, string): if m: match.value = m.group(1) return True - else: - match.value = None - return False + match.value = None + return False if len(sys.argv) != 3 or re.match("^-*help", sys.argv[1]): diff --git a/raster/r.topidx/r.topidx.html b/raster/r.topidx/r.topidx.html index 56dd001f20a..75938e6a231 100644 --- a/raster/r.topidx/r.topidx.html +++ b/raster/r.topidx/r.topidx.html @@ -10,12 +10,14 @@

    DESCRIPTION

    the local surface topographic slope (delta vertical) / (delta horizontal).
    -

    Input maps may have NULL values. For example, if you have a MASK for a -watershed (basin map from r.water.outlet), the following command will -create a masked elevation map (belev): +

    Input maps may have NULL values. For example, if you have a raster mask set +for a watershed (using basin map from r.water.outlet), the following +command will create a masked elevation map (belev): +

     r.mapcalc "belev = if(isnull(basin), basin, elev)"
     
    +

    r.stats -Anc prints out averaged statistics for topographic index. diff --git a/raster/r.univar/benchmark/benchmark_r_univar.py b/raster/r.univar/benchmark/benchmark_r_univar.py index 507e6b4b23e..58d607645c7 100644 --- a/raster/r.univar/benchmark/benchmark_r_univar.py +++ b/raster/r.univar/benchmark/benchmark_r_univar.py @@ -35,8 +35,7 @@ def benchmark(size, label, results): overwrite=True, ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=16, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=output) + Module("g.remove", quiet=True, flags="f", type="raster", name=(reference, output)) def generate_map(rows, cols, fname): diff --git a/raster/r.univar/r.univar.html b/raster/r.univar/r.univar.html index 5220bc64a44..debde03a1d6 100644 --- a/raster/r.univar/r.univar.html +++ b/raster/r.univar/r.univar.html @@ -53,7 +53,7 @@

    PERFORMANCE

    r.univar supports parallel processing using OpenMP. The user can specify the number of threads to be used with the nprocs parameter. -However, parallelization is disabled when the MASK is set. +However, parallelization is disabled when the raster mask is set.

    Due to the differences in summation order, users may encounter small floating points diff --git a/raster/r.univar/r.univar_main.c b/raster/r.univar/r.univar_main.c index 805acfff27b..e56301a1364 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -192,8 +192,8 @@ int main(int argc, char *argv[]) sscanf(param.nprocs->answer, "%d", &nprocs); if (nprocs < 1) G_fatal_error(_("<%d> is not valid number of nprocs."), nprocs); - if (nprocs > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (nprocs > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); nprocs = 1; } #if defined(_OPENMP) diff --git a/raster/r.univar/testsuite/test_r_univar.py b/raster/r.univar/testsuite/test_r_univar.py index de28f0753d5..c2ae6669df6 100644 --- a/raster/r.univar/testsuite/test_r_univar.py +++ b/raster/r.univar/testsuite/test_r_univar.py @@ -23,11 +23,12 @@ def tearDownClass(cls): cls.del_temp_region() def tearDown(self): - self.runModule("g.remove", flags="f", type="raster", name="map_a") - self.runModule("g.remove", flags="f", type="raster", name="map_b") - self.runModule("g.remove", flags="f", type="raster", name="map_negative") - self.runModule("g.remove", flags="f", type="raster", name="zone_map") - self.runModule("g.remove", flags="f", type="raster", name="zone_map_with_gap") + self.runModule( + "g.remove", + flags="f", + type="raster", + name="map_a,map_b,map_negative,zone_map,zone_map_with_gap", + ) def setUp(self): """Create input data""" diff --git a/raster/r.viewshed/testsuite/test_r_viewshed.py b/raster/r.viewshed/testsuite/test_r_viewshed.py index b6825c62018..a341d8e97b5 100644 --- a/raster/r.viewshed/testsuite/test_r_viewshed.py +++ b/raster/r.viewshed/testsuite/test_r_viewshed.py @@ -1,6 +1,5 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test -from grass.gunittest.gmodules import call_module class TestViewshed(TestCase): @@ -15,10 +14,10 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - def tearDown(cls): + def tearDown(self): """Remove viewshed map after each test method""" # TODO: eventually, removing maps should be handled through testing framework functions - cls.runModule("g.remove", flags="f", type="raster", name=cls.viewshed) + self.runModule("g.remove", flags="f", type="raster", name=self.viewshed) def test_limits(self): """Test if results is in expected limits""" diff --git a/raster/r.viewshed/viewshed.cpp b/raster/r.viewshed/viewshed.cpp index 17ef21b7811..3ce07fa4652 100644 --- a/raster/r.viewshed/viewshed.cpp +++ b/raster/r.viewshed/viewshed.cpp @@ -261,6 +261,7 @@ MemoryVisibilityGrid *viewshed_in_memory(char *inputfname, GridHeader *hd, e.elev[0] = data[0][i]; e.elev[1] = data[1][i]; e.elev[2] = data[2][i]; + e.angle = -1.0; if (!is_nodata(visgrid->grid->hd, data[1][i]) && !is_point_outside_max_dist(*vp, *hd, sn.row, sn.col, @@ -499,6 +500,7 @@ IOVisibilityGrid *viewshed_external(char *inputfname, GridHeader *hd, e.elev[0] = data[0][i]; e.elev[1] = data[1][i]; e.elev[2] = data[2][i]; + e.angle = -1.0; if (!is_nodata(visgrid->hd, data[1][i]) && !is_point_outside_max_dist(*vp, *hd, sn.row, sn.col, viewOptions.maxDist)) { diff --git a/raster/r.watershed/front/r.watershed.html b/raster/r.watershed/front/r.watershed.html index abe352a6948..d9a226412af 100644 --- a/raster/r.watershed/front/r.watershed.html +++ b/raster/r.watershed/front/r.watershed.html @@ -520,7 +520,7 @@

    REFERENCES

  • Holmgren P. (1994). Multiple flow direction algorithms for runoff modelling in grid based elevation models: An empirical evaluation. Hydrological Processes Vol 8(4), 327-334.
    -DOI: 10.1002/hyp.3360080405 +DOI: 10.1002/hyp.3360080405
  • Kinner D., Mitasova H., Harmon R., Toma L., Stallard R. (2005). GIS-based Stream Network Analysis for The Chagres River Basin, @@ -535,19 +535,19 @@

    REFERENCES

  • Metz M., Mitasova H., Harmon R. (2011). Efficient extraction of drainage networks from massive, radar-based elevation models with least cost path search, Hydrol. Earth Syst. Sci. Vol 15, 667-678.
    -DOI: 10.5194/hess-15-667-2011 +DOI: 10.5194/hess-15-667-2011
  • Moore I.D., Grayson R.B., Ladson A.R. (1991). Digital terrain modelling: a review of hydrogical, geomorphological, and biological applications, Hydrological Processes, Vol 5(1), 3-30
    -DOI: 10.1002/hyp.3360050103 +DOI: 10.1002/hyp.3360050103
  • Quinn P., K. Beven K., Chevallier P., Planchon O. (1991). The prediction of hillslope flow paths for distributed hydrological modelling using Digital Elevation Models, Hydrological Processes Vol 5(1), p.59-79.
    -DOI: 10.1002/hyp.3360050106 +DOI: 10.1002/hyp.3360050106
  • Weltz M. A., Renard K.G., Simanton J. R. (1987). Revised Universal Soil Loss Equation for Western Rangelands, U.S.A./Mexico Symposium of diff --git a/raster/r.watershed/seg/close_maps.c b/raster/r.watershed/seg/close_maps.c index 1669bbd89c3..56320428c32 100644 --- a/raster/r.watershed/seg/close_maps.c +++ b/raster/r.watershed/seg/close_maps.c @@ -325,6 +325,8 @@ int close_maps(void) } Rast_close(fd); + G_free(afbuf); + G_free(cbuf); Rast_init_colors(&colors); Rast_make_aspect_colors(&colors, -8, 8); diff --git a/raster/r.what/testsuite/test_r_what.py b/raster/r.what/testsuite/test_r_what.py index fcc312e6284..68bfdeea376 100644 --- a/raster/r.what/testsuite/test_r_what.py +++ b/raster/r.what/testsuite/test_r_what.py @@ -510,7 +510,7 @@ def test_raster_what_csv(self): ) self.assertFileExists(filename="result.csv", msg="CSV file was not created") if os.path.isfile("result.csv"): - file = open("result.csv", "r") + file = open("result.csv") fileData = file.read() self.assertLooksLike( actual=fileData, diff --git a/raster/r.what/testsuite/testrw.py b/raster/r.what/testsuite/testrw.py index 8184f534720..fdaf7eec98c 100644 --- a/raster/r.what/testsuite/testrw.py +++ b/raster/r.what/testsuite/testrw.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2018 Copyright: (C) 2018 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/raster3d/r3.flow/r3.flow.html b/raster3d/r3.flow/r3.flow.html index f4f9510e7df..7a7c60fd21d 100644 --- a/raster3d/r3.flow/r3.flow.html +++ b/raster3d/r3.flow/r3.flow.html @@ -41,7 +41,7 @@

    Attributes

    NOTES

    r3.flow uses Runge-Kutta with adaptive step size -(Cash-Karp method). +(Cash-Karp method).

    EXAMPLES

    diff --git a/raster3d/r3.in.lidar/main.c b/raster3d/r3.in.lidar/main.c index 6170a3f50ba..3cf91189d24 100644 --- a/raster3d/r3.in.lidar/main.c +++ b/raster3d/r3.in.lidar/main.c @@ -361,13 +361,12 @@ int main(int argc, char *argv[]) /* for the CRS info */ const char *projstr; - struct Cell_head current_region; - struct Cell_head file_region; - + struct Cell_head current_region = {0}; + struct Cell_head file_region = {0}; G_get_set_window(¤t_region); /* extent for all data */ - struct Cell_head data_region; + struct Cell_head data_region = {0}; long unsigned header_count = 0; int i; diff --git a/raster3d/r3.in.v5d/binio.c b/raster3d/r3.in.v5d/binio.c index f8582e97313..b47723a2929 100644 --- a/raster3d/r3.in.v5d/binio.c +++ b/raster3d/r3.in.v5d/binio.c @@ -147,7 +147,7 @@ static void if_to_c(long *t, const long *f) { if (*f != 0) { *t = (((*f & 0x8000000000000000) | - ((*f & 0x7f80000000000000) >> 7) + (16258 << 48)) | + ((*f & 0x7f80000000000000) >> 7) + (16258L << 48)) | (((*f & 0x007fffff00000000) >> 8) | (0x0000800000000000))); if ((*f << 1) == 0) *t = 0; @@ -160,7 +160,7 @@ static void if_to_c(long *t, const long *f) #define IF_TO_C(T, F) \ if (F != 0) { \ T = (((F & 0x8000000000000000) | \ - ((F & 0x7f80000000000000) >> 7) + (16258 << 48)) | \ + ((F & 0x7f80000000000000) >> 7) + (16258L << 48)) | \ (((F & 0x007fffff00000000) >> 8) | (0x0000800000000000))); \ if ((F << 1) == 0) \ T = 0; \ diff --git a/raster3d/r3.in.v5d/v5d.c b/raster3d/r3.in.v5d/v5d.c index 445d6f29b9f..54f75f2361a 100644 --- a/raster3d/r3.in.v5d/v5d.c +++ b/raster3d/r3.in.v5d/v5d.c @@ -63,6 +63,9 @@ #include #include #include +#include +#include + #include "binio.h" #include "v5d.h" #include "vis5d.h" @@ -1232,7 +1235,10 @@ static int read_comp_header(int f, v5dstruct *v) unsigned int id; /* reset file position to start of file */ - lseek(f, 0, SEEK_SET); + if (lseek(f, 0, SEEK_SET) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } /* read file ID */ read_int4(f, (int *)&id); @@ -1334,8 +1340,8 @@ static int read_comp_header(int f, v5dstruct *v) /* skip ahead by 'gridsize' bytes */ if (lseek(f, gridsize, SEEK_CUR) == -1) { - printf("Error: Unexpected end of file, "); - printf("file may be corrupted.\n"); + G_warning(_("Error: Unexpected end of file, file may be " + "corrupted.")); return 0; } min = -(125.0 + gb) / ga; @@ -1478,7 +1484,10 @@ static int read_comp_grid(v5dstruct *v, int time, int var, float *ga, float *gb, /* move to position in file */ pos = grid_position(v, time, var); - lseek(f, pos, SEEK_SET); + if (lseek(f, pos, SEEK_SET) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } if (v->FileFormat == 0x80808083) { /* read McIDAS grid and file numbers */ @@ -1551,7 +1560,13 @@ static int read_comp_grid(v5dstruct *v, int time, int var, float *ga, float *gb, */ static int read_v5d_header(v5dstruct *v) { -#define SKIP(N) lseek(f, N, SEEK_CUR) +#define SKIP(N) \ + do { \ + if (lseek(f, N, SEEK_CUR) == -1) { \ + G_warning(_("Unable to seek: %s"), strerror(errno)); \ + return 0; \ + } \ + } while (0) int end_of_header = 0; unsigned int id; int idlen, var, numargs; @@ -1870,13 +1885,19 @@ static int read_v5d_header(v5dstruct *v) case TAG_END: /* end of header */ end_of_header = 1; - lseek(f, length, SEEK_CUR); + if (lseek(f, length, SEEK_CUR) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } break; default: /* unknown tag, skip to next tag */ printf("Unknown tag: %d length=%d\n", tag, length); - lseek(f, length, SEEK_CUR); + if (lseek(f, length, SEEK_CUR) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } break; } } @@ -1966,7 +1987,10 @@ int v5dReadCompressedGrid(v5dstruct *v, int time, int var, float *ga, float *gb, /* move to position in file */ pos = grid_position(v, time, var); - lseek(v->FileDesc, pos, SEEK_SET); + if (lseek(v->FileDesc, pos, SEEK_SET) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } /* read ga, gb arrays */ read_float4_array(v->FileDesc, ga, v->Nl[var]); @@ -2118,7 +2142,10 @@ static int write_v5d_header(v5dstruct *v) } /* set file pointer to start of file */ - lseek(f, 0, SEEK_SET); + if (lseek(f, 0, SEEK_SET) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } v->CurPos = 0; /* @@ -2222,7 +2249,10 @@ static int write_v5d_header(v5dstruct *v) /* We're writing to a brand new file. Reserve 10000 bytes */ /* for future header growth. */ WRITE_TAG(v, TAG_END, 10000); - lseek(f, 10000, SEEK_CUR); + if (lseek(f, 10000, SEEK_CUR) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } /* Let file pointer indicate where first grid is stored */ v->FirstGridPos = ltell(f); @@ -2336,7 +2366,7 @@ int v5dWriteCompressedGrid(const v5dstruct *v, int time, int var, pos = grid_position(v, time, var); if (lseek(v->FileDesc, pos, SEEK_SET) < 0) { /* lseek failed, return error */ - printf("Error in v5dWrite[Compressed]Grid: seek failed, disk full?\n"); + G_warning(_("Unable to seek: %s"), strerror(errno)); return 0; } @@ -2452,9 +2482,15 @@ int v5dCloseFile(v5dstruct *v) if (v->Mode == 'w') { /* rewrite header because writing grids updates the minval and */ /* maxval fields */ - lseek(v->FileDesc, 0, SEEK_SET); + if (lseek(v->FileDesc, 0, SEEK_SET) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } status = write_v5d_header(v); - lseek(v->FileDesc, 0, SEEK_END); + if (lseek(v->FileDesc, 0, SEEK_END) == -1) { + G_warning(_("Unable to seek: %s"), strerror(errno)); + return 0; + } close(v->FileDesc); } else if (v->Mode == 'r') { diff --git a/raster3d/r3.null/testsuite/test.r3.null.sh b/raster3d/r3.null/testsuite/test.r3.null.sh index 1cf93110b24..d6a6ec35810 100755 --- a/raster3d/r3.null/testsuite/test.r3.null.sh +++ b/raster3d/r3.null/testsuite/test.r3.null.sh @@ -56,14 +56,7 @@ diff data/test_volume_double_null_1.ref test_volume_double_null_1.txt diff data/test_volume_double_null_2.ref test_volume_double_null_2.txt # Cleanup -g.remove -f type=raster_3d name=test_volume_float_1 -g.remove -f type=raster_3d name=test_volume_float_2 -g.remove -f type=raster_3d name=test_volume_float_null_1 -g.remove -f type=raster_3d name=test_volume_float_null_2 -g.remove -f type=raster_3d name=test_volume_double_1 -g.remove -f type=raster_3d name=test_volume_double_2 -g.remove -f type=raster_3d name=test_volume_double_null_1 -g.remove -f type=raster_3d name=test_volume_double_null_2 +g.remove -f type=raster_3d name=test_volume_float_1,test_volume_float_2,test_volume_float_null_1,test_volume_float_null_2,test_volume_double_1,test_volume_double_2,test_volume_double_null_1,test_volume_double_null_2 rm test_volume_float_1.txt rm test_volume_float_2.txt rm test_volume_float_null_1.txt diff --git a/raster3d/r3.out.netcdf/main.c b/raster3d/r3.out.netcdf/main.c index 6bcdcbaf9f5..144c9085eef 100644 --- a/raster3d/r3.out.netcdf/main.c +++ b/raster3d/r3.out.netcdf/main.c @@ -17,7 +17,7 @@ * here: * http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.6/cf-conventions.html#coordinate-system * https://cf-pcmdi.llnl.gov/trac/wiki/Cf2CrsWkt - * http://trac.osgeo.org/gdal/wiki/NetCDF_ProjectionTestingStatus + * https://trac.osgeo.org/gdal/wiki/NetCDF_ProjectionTestingStatus * *****************************************************************************/ diff --git a/raster3d/r3.out.netcdf/r3.out.netcdf.html b/raster3d/r3.out.netcdf/r3.out.netcdf.html index 9fb256a06d3..2dc69701d4d 100644 --- a/raster3d/r3.out.netcdf/r3.out.netcdf.html +++ b/raster3d/r3.out.netcdf/r3.out.netcdf.html @@ -22,7 +22,7 @@

    NOTES

    Spatial coordinates are exported as cell centered coordinates. The projection can be optionally stored in the metadata as crs attributes . The netCDF projection metadata storage follows the spatial_ref GDAL/netCDF suggestion -here +here and the netCDF CF 1.6 convention here using WKT projection information. Additional a PROJ string is diff --git a/raster3d/r3.showdspf/main_ogl.c b/raster3d/r3.showdspf/main_ogl.c index 55b3097e2cf..da6e90a3721 100644 --- a/raster3d/r3.showdspf/main_ogl.c +++ b/raster3d/r3.showdspf/main_ogl.c @@ -1159,7 +1159,7 @@ void do__draw(file_info *Headp, struct dspec *D_spec) fdraw_polys(D_spec); break; case 2: - case3: + case 3: gdraw_polys(D_spec); break; } diff --git a/raster3d/raster3dintro.html b/raster3d/raster3dintro.html index ac476b974b2..b51748b4dd8 100644 --- a/raster3d/raster3dintro.html +++ b/raster3d/raster3dintro.html @@ -115,7 +115,7 @@

    Conversion from 2D raster maps

    2D rasters are considered as slices in this case and merged into one 3D raster map (r.to.rast3). -

    3D region settings and 3D MASK

    +

    3D region settings and 3D mask

    GRASS GIS 3D raster map processing is always performed in the current 3D region settings (see g.region, -p3 flags), i.e. diff --git a/rpm/grass.spec b/rpm/grass.spec index a68453145bc..90c79bc939f 100644 --- a/rpm/grass.spec +++ b/rpm/grass.spec @@ -320,7 +320,7 @@ fi %{_docdir}/%{name}%{shortver} %files libs -%license AUTHORS COPYING GPL.TXT CHANGES +%license AUTHORS COPYING GPL.TXT %{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf %{_libdir}/%{name}%{shortver}/lib/*.so %dir %{_libdir}/%{name}%{shortver}/driver diff --git a/scripts/d.correlate/d.correlate.py b/scripts/d.correlate/d.correlate.py index af681cce545..1068733a11b 100755 --- a/scripts/d.correlate/d.correlate.py +++ b/scripts/d.correlate/d.correlate.py @@ -73,7 +73,7 @@ def main(): gcore.run_command("r.stats", flags="cnA", input=(i, j), stdout=ofile) ofile.close() - ifile = open(tmpfile, "r") + ifile = open(tmpfile) first = True for line in ifile: f = line.rstrip("\r\n").split(" ") @@ -95,7 +95,7 @@ def main(): p = gcore.feed_command("d.graph", color=color) ofile = p.stdin - ifile = open(tmpfile, "r") + ifile = open(tmpfile) for line in ifile: f = line.rstrip("\r\n").split(" ") x = float(f[0]) diff --git a/scripts/d.frame/d.frame.py b/scripts/d.frame/d.frame.py index e9b44b21650..165dd712648 100755 --- a/scripts/d.frame/d.frame.py +++ b/scripts/d.frame/d.frame.py @@ -91,7 +91,7 @@ def check_monitor(): def read_monitor_file(monitor, ftype="env"): mfile = check_monitor_file(monitor, ftype) try: - fd = open(mfile, "r") + fd = open(mfile) except OSError as e: fatal(_("Unable to get monitor info. %s"), e) @@ -206,7 +206,7 @@ def calculate_frame(frame, at, width, height): """ try: b, t, l, r = list(map(float, at.split(","))) - except: + except ValueError: fatal(_("Invalid frame position: %s") % at) top = round(height - (t / 100.0 * height)) @@ -238,7 +238,7 @@ def create_frame(monitor, frame, at, overwrite=False): width = int(line.split("=", 1)[1].rsplit(" ", 1)[0]) elif "HEIGHT" in line: height = int(line.split("=", 1)[1].rsplit(" ", 1)[0]) - except: + except (ValueError, IndexError): pass if width < 0 or height < 0: diff --git a/scripts/d.polar/d.polar.html b/scripts/d.polar/d.polar.html index fad50649371..d1bbc2e6586 100644 --- a/scripts/d.polar/d.polar.html +++ b/scripts/d.polar/d.polar.html @@ -62,7 +62,7 @@

    REFERENCES

    J. Hofierka, H. Mitasova, and M. Neteler (2009): Terrain parameterization in GRASS. In T. Hengl and H.I. Reuter, editors, Geomorphometry: concepts, software, applications. Elsevier -(DOI) +(DOI)

    AUTHORS

    diff --git a/scripts/d.polar/d.polar.py b/scripts/d.polar/d.polar.py index f592dd89b63..d7e67486a0e 100755 --- a/scripts/d.polar/d.polar.py +++ b/scripts/d.polar/d.polar.py @@ -112,7 +112,7 @@ def plot_dgraph(): 50 * (1 + ring * math.sin(math.radians(i))), 50 * (1 + ring * math.cos(math.radians(i))), ) - for i in range(0, 361) + for i in range(361) ] # trend vector @@ -425,8 +425,8 @@ def main(): gcore.fatal( _( "EPS output file path <{}>, doesn't exists. " - "Set new output file path.".format(eps) - ) + "Set new output file path." + ).format(eps) ) else: eps = basename(eps, "eps") + ".eps" @@ -436,8 +436,8 @@ def main(): gcore.fatal( _( "option : <{}> exists. To overwrite, " - "use the --overwrite flag.".format(eps) - ) + "use the --overwrite flag." + ).format(eps) ) # check if we have xgraph (if no EPS output requested) @@ -512,7 +512,7 @@ def main(): outercircle = [] outercircle.append('"All Data incl. NULLs') scale = 1.0 * totalnumber / totalvalidnumber * maxradius - for i in range(0, 361): + for i in range(361): a = math.radians(i) x = math.cos(a) * scale y = math.sin(a) * scale diff --git a/scripts/d.rast.edit/d.rast.edit.py b/scripts/d.rast.edit/d.rast.edit.py index 6519d10c7a1..102d7e447d8 100755 --- a/scripts/d.rast.edit/d.rast.edit.py +++ b/scripts/d.rast.edit/d.rast.edit.py @@ -77,6 +77,8 @@ import sys import math import atexit +from string import digits + import grass.script as gs from grass.script.setup import set_gui_path @@ -293,10 +295,7 @@ def paint_cell(self, dc, r, c): px, py = -dy, dx r, g, b, a = wx.Colour(fill).Get() - if r + g + b > 384: - line = "black" - else: - line = "white" + line = "black" if r + g + b > 384 else "white" dc.SetPen(wx.Pen(line)) dc.DrawLine(x0, y0, x1, y1) @@ -448,7 +447,7 @@ def OnClose(self, ev): def OnReturn(self, ev): self.app.brush = self.newval.GetValue() - if self.app.brush != "*" and self.app.brush.strip("0123456789") != "": + if self.app.brush != "*" and self.app.brush.strip(digits) != "": self.app.brush = "*" self.brush_update() @@ -645,28 +644,9 @@ def update_status(self, row, col): if self.angles: self.status["aspect"] = self.angles[row][col] - def force_color(self, val): - run("g.region", rows=1, cols=1) - run("r.mapcalc", expression="%s = %d" % (self.tempmap, val)) - run("r.colors", map=self.tempmap, rast=self.inmap) - run("r.out.ppm", input=self.tempmap, out=self.tempfile) - run("g.remove", flags="f", type="raster", name=self.tempmap) - - tempimg = wx.Image(self.tempfile) - gs.try_remove(self.tempfile) - - rgb = tempimg.get(0, 0) - color = "#%02x%02x%02x" % rgb - self.colors[val] = color - tempimg.delete() - def get_color(self, val): if val not in self.colors: - try: - self.force_color(val) - except: - self.colors[val] = "#ffffff" - + self.colors[val] = "#ffffff" return self.colors[val] def refresh_canvas(self): diff --git a/scripts/d.rast.leg/d.rast.leg.py b/scripts/d.rast.leg/d.rast.leg.py index 85cb423f9e9..74576113577 100755 --- a/scripts/d.rast.leg/d.rast.leg.py +++ b/scripts/d.rast.leg/d.rast.leg.py @@ -132,16 +132,10 @@ def main(): if not nlines: nlines = None - if rast: - lmap = rast - else: - lmap = map + lmap = rast or map kv = gs.raster_info(map=lmap) - if kv["datatype"] == "CELL": - leg_at = None - else: - leg_at = "%f,95,5,10" % VSpacing + leg_at = None if kv["datatype"] == "CELL" else "%f,95,5,10" % VSpacing # checking for histogram causes more problems than it solves # histfiledir = grass.find_file(lmap, 'cell_misc')['file'] diff --git a/scripts/db.droptable/db.droptable.py b/scripts/db.droptable/db.droptable.py index 571638748cf..39408221acc 100755 --- a/scripts/db.droptable/db.droptable.py +++ b/scripts/db.droptable/db.droptable.py @@ -56,14 +56,8 @@ def main(): gs.run_command("db.connect", flags="c", quiet=True) kv = gs.db_connection() - if options["database"]: - database = options["database"] - else: - database = kv["database"] - if options["driver"]: - driver = options["driver"] - else: - driver = kv["driver"] + database = options["database"] or kv["database"] + driver = options["driver"] or kv["driver"] # schema needed for PG? if force: diff --git a/scripts/db.in.ogr/db.in.ogr.html b/scripts/db.in.ogr/db.in.ogr.html index 322f22840f0..70e7dddc1b1 100644 --- a/scripts/db.in.ogr/db.in.ogr.html +++ b/scripts/db.in.ogr/db.in.ogr.html @@ -1,7 +1,7 @@

    DESCRIPTION

    db.in.ogr imports attribute tables in various formats as -supported by the OGR library +supported by the OGR library on the local system (DBF, CSV, PostgreSQL, SQLite, MySQL, ODBC, etc.). Optionally a unique key (ID) column can be added to the table. @@ -12,7 +12,7 @@

    Import CSV file

    Limited type recognition can be done for Integer, Real, String, Date, Time and DateTime columns through a descriptive file with same name as the CSV file, but .csvt extension -(see details here). +(see details here).
     # NOTE: create koeppen_gridcode.csvt first for automated type recognition
    diff --git a/scripts/db.in.ogr/db.in.ogr.py b/scripts/db.in.ogr/db.in.ogr.py
    index a95919f4936..b7d7b01b51e 100755
    --- a/scripts/db.in.ogr/db.in.ogr.py
    +++ b/scripts/db.in.ogr/db.in.ogr.py
    @@ -115,8 +115,7 @@ def main():
                         "db.execute", input="-", stdin="DROP TABLE %s" % output
                     )
                     break
    -            else:
    -                gs.fatal(_("Table <%s> already exists") % output)
    +            gs.fatal(_("Table <%s> already exists") % output)
     
         # treat DB as real vector map...
         layer = db_table or None
    diff --git a/scripts/db.in.ogr/testsuite/test_db_in_ogr.py b/scripts/db.in.ogr/testsuite/test_db_in_ogr.py
    index 423917e1b93..b79efa1f096 100644
    --- a/scripts/db.in.ogr/testsuite/test_db_in_ogr.py
    +++ b/scripts/db.in.ogr/testsuite/test_db_in_ogr.py
    @@ -8,7 +8,6 @@
     from grass.gunittest.main import test
     from grass.gunittest.gmodules import SimpleModule
     
    -from grass.script.core import run_command
     from grass.script.utils import decode
     
     import os
    diff --git a/scripts/db.out.ogr/db.out.ogr.py b/scripts/db.out.ogr/db.out.ogr.py
    index 4a840755b20..4fe5b4f9854 100755
    --- a/scripts/db.out.ogr/db.out.ogr.py
    +++ b/scripts/db.out.ogr/db.out.ogr.py
    @@ -67,15 +67,11 @@ def main():
         layer = options["layer"]
         format = options["format"]
         output = options["output"]
    -    table = options["table"]
     
         if format.lower() == "dbf":
             format = "ESRI_Shapefile"
     
    -    if format.lower() == "csv":
    -        olayer = basename(output, "csv")
    -    else:
    -        olayer = None
    +    olayer = basename(output, "csv") if format.lower() == "csv" else None
     
         # is there a simpler way of testing for --overwrite?
         dbffile = input + ".dbf"
    diff --git a/scripts/db.univar/db.univar.py b/scripts/db.univar/db.univar.py
    index f941be42140..4654e3011a0 100755
    --- a/scripts/db.univar/db.univar.py
    +++ b/scripts/db.univar/db.univar.py
    @@ -77,7 +77,7 @@ def cleanup():
     
     
     def sortfile(infile, outfile):
    -    inf = open(infile, "r")
    +    inf = open(infile)
         outf = open(outfile, "w")
     
         if gs.find_program("sort", "--help"):
    @@ -118,10 +118,7 @@ def main():
         perc = [float(p) for p in perc.split(",")]
     
         if not output_format:
    -        if shellstyle:
    -            output_format = "shell"
    -        else:
    -            output_format = "plain"
    +        output_format = "shell" if shellstyle else "plain"
         elif shellstyle:
             # This can be a message or warning in future versions.
             # In version 9, -g may be removed.
    diff --git a/scripts/g.extension.all/g.extension.all.py b/scripts/g.extension.all/g.extension.all.py
    index 026589cca10..1b0a2a88108 100644
    --- a/scripts/g.extension.all/g.extension.all.py
    +++ b/scripts/g.extension.all/g.extension.all.py
    @@ -64,7 +64,7 @@ def get_extensions():
             return []
     
         # read XML file
    -    fo = open(fXML, "r")
    +    fo = open(fXML)
         try:
             tree = ET.fromstring(fo.read())
         except Exception as e:
    @@ -104,18 +104,18 @@ def download_modules_xml_file(url, response_format, *args, **kwargs):
         try:
             response = urlopen(url, *args, **kwargs)
     
    -        if not response.code == 200:
    +        if response.code != 200:
                 index = HTTP_STATUS_CODES.index(response.code)
                 desc = HTTP_STATUS_CODES[index].description
                 gs.fatal(
                     _(
                         "Download file from <{url}>, "
                         "return status code {code}, "
    -                    "{desc}".format(
    -                        url=url,
    -                        code=response.code,
    -                        desc=desc,
    -                    ),
    +                    "{desc}"
    +                ).format(
    +                    url=url,
    +                    code=response.code,
    +                    desc=desc,
                     ),
                 )
             if response_format not in response.getheader("Content-Type"):
    @@ -123,10 +123,10 @@ def download_modules_xml_file(url, response_format, *args, **kwargs):
                     _(
                         "Wrong file format downloaded. "
                         "Check url <{url}>. Allowed file format is "
    -                    "{response_format}.".format(
    -                        url=url,
    -                        response_format=response_format,
    -                    ),
    +                    "{response_format}."
    +                ).format(
    +                    url=url,
    +                    response_format=response_format,
                     ),
                 )
             return response
    @@ -138,8 +138,8 @@ def download_modules_xml_file(url, response_format, *args, **kwargs):
                         "The download of the modules.xml file "
                         "from the server was not successful. "
                         "File on the server <{url}> doesn't "
    -                    "exists.".format(url=url),
    -                ),
    +                    "exists."
    +                ).format(url=url),
                 )
             else:
                 return download_modules_xml_file(
    @@ -148,11 +148,8 @@ def download_modules_xml_file(url, response_format, *args, **kwargs):
                 )
         except URLError:
             gs.fatal(
    -            _(
    -                "Download file from <{url}>, "
    -                "failed. Check internet connection.".format(
    -                    url=url,
    -                ),
    +            _("Download file from <{url}>, failed. Check internet connection.").format(
    +                url=url,
                 ),
             )
     
    @@ -199,9 +196,8 @@ def find_addon_name(addons):
                 gs.warning(
                     _(
                         "The <{}> addon cannot be reinstalled. "
    -                    "Addon wasn't found among the official "
    -                    "addons.".format(addon)
    -                ),
    +                    "Addon wasn't found among the official addons."
    +                ).format(addon),
                 )
         return set(result)
     
    diff --git a/scripts/g.extension/g.extension.py b/scripts/g.extension/g.extension.py
    index 3b0c15c0bfc..f14a742ca06 100644
    --- a/scripts/g.extension/g.extension.py
    +++ b/scripts/g.extension/g.extension.py
    @@ -470,9 +470,10 @@ def replace_shebang_win(python_file):
         cur_dir = os.path.dirname(python_file)
         tmp_name = os.path.join(cur_dir, gs.tempname(12))
     
    -    with codecs.open(python_file, "r", encoding="utf8") as in_file, codecs.open(
    -        tmp_name, "w", encoding="utf8"
    -    ) as out_file:
    +    with (
    +        codecs.open(python_file, "r", encoding="utf8") as in_file,
    +        codecs.open(tmp_name, "w", encoding="utf8") as out_file,
    +    ):
             for line in in_file:
                 new_line = line.replace(
                     "#!/usr/bin/env python\n", "#!/usr/bin/env python3\n"
    @@ -507,24 +508,23 @@ def get_version_branch(major_version):
         version_branch = f"grass{major_version}"
         if sys.platform == "win32":
             return version_branch
    -    else:
    -        branch = gs.Popen(
    -            ["git", "ls-remote", "--heads", GIT_URL, f"refs/heads/{version_branch}"],
    -            stdout=PIPE,
    -            stderr=PIPE,
    -        )
    -        branch, stderr = branch.communicate()
    -        if stderr:
    -            gs.fatal(
    -                _(
    -                    "Failed to get branch from the Git repository <{repo_path}>.\n"
    -                    "{error}"
    -                ).format(
    -                    repo_path=GIT_URL,
    -                    error=gs.decode(stderr),
    -                )
    +    branch = gs.Popen(
    +        ["git", "ls-remote", "--heads", GIT_URL, f"refs/heads/{version_branch}"],
    +        stdout=PIPE,
    +        stderr=PIPE,
    +    )
    +    branch, stderr = branch.communicate()
    +    if stderr:
    +        gs.fatal(
    +            _(
    +                "Failed to get branch from the Git repository <{repo_path}>.\n"
    +                "{error}"
    +            ).format(
    +                repo_path=GIT_URL,
    +                error=gs.decode(stderr),
                 )
    -        branch = gs.decode(branch)
    +        )
    +    branch = gs.decode(branch)
         if version_branch not in branch:
             version_branch = "grass{}".format(int(major_version) - 1)
         return version_branch
    @@ -541,10 +541,8 @@ def get_default_branch(full_url):
             organization, repository = url_parts.path.split("/")[1:3]
         except URLError:
             gs.fatal(
    -            _(
    -                "Cannot retrieve organization and repository from URL: <{}>.".format(
    -                    full_url
    -                )
    +            _("Cannot retrieve organization and repository from URL: <{}>.").format(
    +                full_url
                 )
             )
         # Construct API call and retrieve default branch
    @@ -583,10 +581,8 @@ def etree_fromurl(url):
                 _(
                     "Download file from <{url}>,"
                     " failed. File is not on the server or"
    -                " check your internet connection.".format(
    -                    url=url,
    -                ),
    -            ),
    +                " check your internet connection."
    +            ).format(url=url),
             )
         return ET.fromstring(file_.read())
     
    @@ -1612,10 +1608,7 @@ def install_extension_win(name):
         source, url = resolve_source_code(url="{0}/{1}.zip".format(base_url, name))
     
         # to hide non-error messages from subprocesses
    -    if gs.verbosity() <= 2:
    -        outdev = open(os.devnull, "w")
    -    else:
    -        outdev = sys.stdout
    +    outdev = open(os.devnull, "w") if gs.verbosity() <= 2 else sys.stdout
     
         # download Addons ZIP file
         os.chdir(TMPDIR)  # this is just to not leave something behind
    @@ -1965,10 +1958,7 @@ def install_extension_std_platforms(name, source, url, branch):
         path_to_src_code_message = _("Path to the source code:")
     
         # to hide non-error messages from subprocesses
    -    if gs.verbosity() <= 2:
    -        outdev = open(os.devnull, "w")
    -    else:
    -        outdev = sys.stdout
    +    outdev = open(os.devnull, "w") if gs.verbosity() <= 2 else sys.stdout
     
         os.chdir(TMPDIR)  # this is just to not leave something behind
         srcdir = os.path.join(TMPDIR, name)
    @@ -2582,10 +2572,7 @@ def resolve_known_host_service(url, name, branch):
                             )
                             return None, None
         if match:
    -        if not actual_start:
    -            actual_start = match["url_start"]
    -        else:
    -            actual_start = ""
    +        actual_start = match["url_start"] if not actual_start else ""
             if "branch" in match["url_end"]:
                 suffix = match["url_end"].format(
                     name=name,
    @@ -2598,8 +2585,7 @@ def resolve_known_host_service(url, name, branch):
             )
             gs.verbose(_("Will use the following URL for download: {0}").format(url))
             return "remote_zip", url
    -    else:
    -        return None, None
    +    return None, None
     
     
     def validate_url(url):
    @@ -2723,7 +2709,7 @@ def resolve_source_code(url=None, name=None, branch=None, fork=False):
         # Handle local URLs
         if os.path.isdir(url):
             return "dir", os.path.abspath(url)
    -    elif os.path.exists(url):
    +    if os.path.exists(url):
             if url.endswith(".zip"):
                 return "zip", os.path.abspath(url)
             for suffix in extract_tar.supported_formats:
    @@ -2826,7 +2812,7 @@ def main():
             xmlurl = resolve_xmlurl_prefix(original_url, source=source)
             list_available_extensions(xmlurl)
             return 0
    -    elif flags["a"]:
    +    if flags["a"]:
             list_installed_extensions(toolboxes=flags["t"])
             return 0
     
    diff --git a/scripts/g.extension/testsuite/test_addons_modules.py b/scripts/g.extension/testsuite/test_addons_modules.py
    index c1cab5c954a..9b99e7ac2ae 100644
    --- a/scripts/g.extension/testsuite/test_addons_modules.py
    +++ b/scripts/g.extension/testsuite/test_addons_modules.py
    @@ -15,7 +15,7 @@
     from grass.gunittest.case import TestCase
     from grass.gunittest.main import test
     from grass.gunittest.gmodules import SimpleModule
    -from grass.gunittest.utils import silent_rmtree
    +from grass.gunittest.utils import silent_rmtree, xfail_windows
     from grass.script.utils import decode
     
     import os
    @@ -52,6 +52,7 @@
     class TestModulesMetadata(TestCase):
         url = "file://" + os.path.abspath("data")
     
    +    @xfail_windows
         def test_listing(self):
             """List individual extensions/modules/addons"""
             module = SimpleModule("g.extension", flags="l", url=self.url)
    @@ -90,6 +91,7 @@ def tearDown(self):
             """Remove created files"""
             silent_rmtree(self.install_prefix)
     
    +    @xfail_windows
         def test_directory_install(self):
             """Test installing extension from directory"""
             self.assertModule(
    @@ -102,6 +104,7 @@ def test_directory_install(self):
             for file in self.files:
                 self.assertFileExists(file)
     
    +    @xfail_windows
         def test_targz_install(self):
             """Test installing extension from local .tar.gz"""
             self.assertModule(
    @@ -113,6 +116,7 @@ def test_targz_install(self):
             for file in self.files:
                 self.assertFileExists(file)
     
    +    @xfail_windows
         def test_remote_targz_without_dir_install(self):
             """Test installing extension from (remote) .tar.gz without main dir"""
             self.assertModule(
    @@ -125,6 +129,7 @@ def test_remote_targz_without_dir_install(self):
             for file in self.files:
                 self.assertFileExists(file)
     
    +    @xfail_windows
         def test_remote_zip_install(self):
             """Test installing extension from .zip specified by URL (local)"""
             self.assertModule(
    diff --git a/scripts/g.extension/testsuite/test_addons_toolboxes.py b/scripts/g.extension/testsuite/test_addons_toolboxes.py
    index 5cbc0454a41..17d7e4b5b74 100644
    --- a/scripts/g.extension/testsuite/test_addons_toolboxes.py
    +++ b/scripts/g.extension/testsuite/test_addons_toolboxes.py
    @@ -15,9 +15,11 @@
     from grass.gunittest.case import TestCase
     from grass.gunittest.main import test
     from grass.gunittest.gmodules import SimpleModule
    +from grass.gunittest.utils import xfail_windows
     
     import os
     
    +
     FULL_TOOLBOXES_OUTPUT = """\
     Hydrology (HY)
     * r.stream.basins
    @@ -39,6 +41,7 @@
     class TestToolboxesMetadata(TestCase):
         url = "file://" + os.path.abspath("data")
     
    +    @xfail_windows
         def test_listing(self):
             """List toolboxes and their content"""
             module = SimpleModule("g.extension", flags="lt", url=self.url)
    diff --git a/scripts/g.manual/g.manual.py b/scripts/g.manual/g.manual.py
    index f4ecf961076..345a6d1714a 100755
    --- a/scripts/g.manual/g.manual.py
    +++ b/scripts/g.manual/g.manual.py
    @@ -132,10 +132,7 @@ def main():
         elif flags["t"]:
             special = "topics"
     
    -    if flags["m"]:
    -        start = start_man
    -    else:
    -        start = start_browser
    +    start = start_man if flags["m"] else start_browser
     
         entry = options["entry"]
         gisbase = os.environ["GISBASE"]
    diff --git a/scripts/g.search.modules/g.search.modules.py b/scripts/g.search.modules/g.search.modules.py
    index 85247517898..5777b4bd033 100755
    --- a/scripts/g.search.modules/g.search.modules.py
    +++ b/scripts/g.search.modules/g.search.modules.py
    @@ -66,6 +66,8 @@
     import os
     import sys
     
    +from operator import itemgetter
    +
     from grass.script import core as grass
     from grass.exceptions import CalledModuleError
     
    @@ -182,8 +184,7 @@ def colored(pattern, attrs):
     
         if pattern:
             return text.replace(pattern, colored(pattern, attrs=attrs))
    -    else:
    -        return colored(text, attrs=attrs)
    +    return colored(text, attrs=attrs)
     
     
     def _search_module(
    @@ -199,7 +200,7 @@ def _search_module(
     
         WXGUIDIR = os.path.join(os.getenv("GISBASE"), "gui", "wxpython")
         filename = os.path.join(WXGUIDIR, "xml", "module_items.xml")
    -    menudata_file = open(filename, "r")
    +    menudata_file = open(filename)
     
         menudata = ET.parse(menudata_file)
         menudata_file.close()
    @@ -210,7 +211,7 @@ def _search_module(
         if os.getenv("GRASS_ADDON_BASE"):
             filename_addons = os.path.join(os.getenv("GRASS_ADDON_BASE"), "modules.xml")
             if os.path.isfile(filename_addons):
    -            addon_menudata_file = open(filename_addons, "r")
    +            addon_menudata_file = open(filename_addons)
                 addon_menudata = ET.parse(addon_menudata_file)
                 addon_menudata_file.close()
                 addon_items = addon_menudata.findall("task")
    @@ -219,7 +220,7 @@ def _search_module(
         # add system-wide installed addons to modules list
         filename_addons_s = os.path.join(os.getenv("GISBASE"), "modules.xml")
         if os.path.isfile(filename_addons_s):
    -        addon_menudata_file_s = open(filename_addons_s, "r")
    +        addon_menudata_file_s = open(filename_addons_s)
             addon_menudata_s = ET.parse(addon_menudata_file_s)
             addon_menudata_file_s.close()
             addon_items_s = addon_menudata_s.findall("task")
    @@ -283,7 +284,7 @@ def _search_module(
                     }
                 )
     
    -    return sorted(found_modules, key=lambda k: k["name"])
    +    return sorted(found_modules, key=itemgetter("name"))
     
     
     def _basic_search(pattern, name, description, module_keywords) -> bool:
    @@ -311,10 +312,7 @@ def _exact_search(keyword, module_keywords):
         :param module_keywords: comma separated list of keywords
         """
         module_keywords = module_keywords.split(",")
    -    for current in module_keywords:
    -        if keyword == current:
    -            return True
    -    return False
    +    return keyword in module_keywords
     
     
     def _manpage_search(pattern, name):
    diff --git a/scripts/g.search.modules/testsuite/test_g_search_modules.py b/scripts/g.search.modules/testsuite/test_g_search_modules.py
    index d280ffc1441..75537eb8d78 100644
    --- a/scripts/g.search.modules/testsuite/test_g_search_modules.py
    +++ b/scripts/g.search.modules/testsuite/test_g_search_modules.py
    @@ -15,6 +15,7 @@
     from grass.gunittest.case import TestCase
     from grass.gunittest.main import test
     from grass.gunittest.gmodules import SimpleModule
    +from grass.gunittest.utils import xfail_windows
     from grass.script.utils import decode
     
     import unittest
    @@ -65,6 +66,7 @@ def test_colored_terminal(self):
             stdout = decode(module.outputs.stdout).split()
             self.assertEqual(stdout[0], termcolor.colored("r.basins.fill", attrs=["bold"]))
     
    +    @xfail_windows
         def test_manual_pages(self):
             module = SimpleModule("g.search.modules", keyword="kapri", flags="gm")
             self.assertModule(module)
    diff --git a/scripts/i.band.library/i.band.library.html b/scripts/i.band.library/i.band.library.html
    index b5d98d2607b..196f1319e3a 100644
    --- a/scripts/i.band.library/i.band.library.html
    +++ b/scripts/i.band.library/i.band.library.html
    @@ -95,11 +95,11 @@ 

    Band reference and semantic label relation

    NOTES

    -Semantic label concept is supported by temporal GRASS modules, -see t.register, -t.rast.list, -t.info -and t.rast.mapcalc +Semantic label concept is supported by temporal GRASS modules, see +t.register, +t.rast.list, +t.info +and t.rast.mapcalc modules for examples.

    Image collections

    diff --git a/scripts/i.image.mosaic/i.image.mosaic.py b/scripts/i.image.mosaic/i.image.mosaic.py index df194c49c8f..fc342a3ed96 100755 --- a/scripts/i.image.mosaic/i.image.mosaic.py +++ b/scripts/i.image.mosaic/i.image.mosaic.py @@ -56,9 +56,8 @@ def get_limit(map): def make_expression(i, count): if i > count: return "null()" - else: - e = make_expression(i + 1, count) - return "if(isnull($image%d),%s,$image%d+$offset%d)" % (i, e, i, i) + e = make_expression(i + 1, count) + return "if(isnull($image%d),%s,$image%d+$offset%d)" % (i, e, i, i) def main(): diff --git a/scripts/i.in.spotvgt/i.in.spotvgt.py b/scripts/i.in.spotvgt/i.in.spotvgt.py index cd744d4c252..9885caea5ec 100755 --- a/scripts/i.in.spotvgt/i.in.spotvgt.py +++ b/scripts/i.in.spotvgt/i.in.spotvgt.py @@ -20,7 +20,7 @@ ############################################################################# # # REQUIREMENTS: -# - gdal: http://www.gdal.org +# - gdal: https://gdal.org # # Notes: # * According to the faq (http://www.vgt.vito.be/faq/faq.html), SPOT vegetation @@ -125,9 +125,7 @@ def main(): # check for gdalinfo (just to check if installation is complete) if not gs.find_program("gdalinfo", "--help"): - gs.fatal( - _("'gdalinfo' not found, install GDAL tools first (http://www.gdal.org)") - ) + gs.fatal(_("'gdalinfo' not found, install GDAL tools first (https://gdal.org)")) pid = str(os.getpid()) tmpfile = gs.tempfile() @@ -136,11 +134,7 @@ def main(): spotdir = os.path.dirname(infile) spotname = gs.basename(infile, "hdf") - - if rast: - name = rast - else: - name = spotname + name = rast or spotname if not gs.overwrite() and gs.find_file(name)["file"]: gs.fatal(_("<%s> already exists. Aborting.") % name) diff --git a/scripts/i.oif/i.oif.py b/scripts/i.oif/i.oif.py index cfee7890120..cb156675927 100755 --- a/scripts/i.oif/i.oif.py +++ b/scripts/i.oif/i.oif.py @@ -47,7 +47,7 @@ def oifcalc(sdev, corr, k1, k2, k3): - grass.debug(_("Calculating OIF for combination: %s, %s, %s" % (k1, k2, k3)), 1) + grass.debug(_("Calculating OIF for combination: %s, %s, %s") % (k1, k2, k3), 1) # calculate SUM of Stddeviations: ssdev = [sdev[k1], sdev[k2], sdev[k3]] numer = sum(ssdev) @@ -63,7 +63,7 @@ def oifcalc(sdev, corr, k1, k2, k3): def perms(bands): n = len(bands) - for i in range(0, n - 2): + for i in range(n - 2): for j in range(i + 1, n - 1): for k in range(j + 1, n): yield (bands[i], bands[j], bands[k]) @@ -90,10 +90,7 @@ def main(): stddev[band] = float(kv["stddev"]) else: # run all bands in parallel - if "WORKERS" in os.environ: - workers = int(os.environ["WORKERS"]) - else: - workers = len(bands) + workers = int(os.environ["WORKERS"]) if "WORKERS" in os.environ else len(bands) proc = {} pout = {} @@ -122,9 +119,7 @@ def main(): grass.message(_("Calculating Correlation Matrix...")) correlation = {} - s = grass.read_command( - "r.covar", flags="r", map=[band for band in bands], quiet=True - ) + s = grass.read_command("r.covar", flags="r", map=list(bands), quiet=True) # We need to skip the first line, since r.covar prints the number of values lines = s.splitlines() @@ -144,10 +139,7 @@ def main(): _("The Optimum Index Factor analysis result (best combination shown first):") ) - if shell: - fmt = "%s,%s,%s:%.4f\n" - else: - fmt = "%s, %s, %s: %.4f\n" + fmt = "%s,%s,%s:%.4f\n" if shell else "%s, %s, %s: %.4f\n" if not output or output == "-": for v, p in oif: diff --git a/scripts/i.pansharpen/i.pansharpen.html b/scripts/i.pansharpen/i.pansharpen.html index 9a50b84bc4e..0db14283be9 100644 --- a/scripts/i.pansharpen/i.pansharpen.html +++ b/scripts/i.pansharpen/i.pansharpen.html @@ -235,7 +235,7 @@

    REFERENCES

  • Neteler, M, D. Grasso, I. Michelazzi, L. Miori, S. Merler, and C. Furlanello (2005). An integrated toolbox for image registration, fusion and classification. International Journal of Geoinformatics, 1(1):51-61 - (PDF) + (PDF)
  • Pohl, C, and J.L van Genderen (1998). Multisensor image fusion in remote sensing: concepts, methods and application. Int. J. of Rem. Sens., 19, 823-854. diff --git a/scripts/i.pansharpen/i.pansharpen.py b/scripts/i.pansharpen/i.pansharpen.py index f344c5ac7fd..730701bfb91 100755 --- a/scripts/i.pansharpen/i.pansharpen.py +++ b/scripts/i.pansharpen/i.pansharpen.py @@ -93,6 +93,7 @@ # %end import os +from grass.exceptions import CalledModuleError try: import numpy as np @@ -402,7 +403,7 @@ def main(): gs.run_command("g.region", res=panres, align=pan) # Select sharpening method - gs.message(_("Performing pan sharpening with hi res pan image: %f" % panres)) + gs.message(_("Performing pan sharpening with hi res pan image: %f") % panres) if sharpen == "brovey": brovey(pan, ms1, ms2, ms3, out, pid, sproc) elif sharpen == "ihs": @@ -437,8 +438,8 @@ def main(): for ch in ["red", "green", "blue"]: gs.verbose(_("%s_%s") % (out, ch)) - gs.verbose(_("To visualize output, run: g.region -p raster=%s_red" % out)) - gs.verbose(_("d.rgb r=%s_red g=%s_green b=%s_blue" % (out, out, out))) + gs.verbose(_("To visualize output, run: g.region -p raster=%s_red") % out) + gs.verbose(_("d.rgb r=%s_red g=%s_green b=%s_blue") % (out, out, out)) gs.verbose( _("If desired, combine channels into a single RGB map with 'r.composite'.") ) @@ -458,7 +459,7 @@ def main(): gs.run_command( "g.remove", flags="f", type="raster", pattern="tmp%s*" % pid, quiet=True ) - except: + except CalledModuleError: pass @@ -523,7 +524,7 @@ def brovey(pan, ms1, ms2, ms3, out, pid, sproc): pb.wait(), pg.wait(), pr.wait() try: pb.terminate(), pg.terminate(), pr.terminate() - except: + except OSError: pass # Cleanup @@ -535,7 +536,7 @@ def brovey(pan, ms1, ms2, ms3, out, pid, sproc): type="raster", name="%s,%s,%s" % (panmatch1, panmatch2, panmatch3), ) - except: + except CalledModuleError: pass @@ -575,7 +576,7 @@ def ihs(pan, ms1, ms2, ms3, out, pid, sproc): # Cleanup try: gs.run_command("g.remove", flags="f", quiet=True, type="raster", name=panmatch) - except: + except CalledModuleError: pass @@ -701,7 +702,7 @@ def pca(pan, ms1, ms2, ms3, out, pid, sproc): pb.wait(), pg.wait(), pr.wait() try: pb.terminate(), pg.terminate(), pr.terminate() - except: + except OSError: pass # Cleanup @@ -749,11 +750,8 @@ def matchhist(original, target, matched): 0 # cumulative total of cells for sum of current and all lower grey values ) - for n in range(0, 256): - if str(n) in stats_dict: - num_cells = stats_dict[str(n)] - else: - num_cells = 0 + for n in range(256): + num_cells = stats_dict.get(str(n), 0) cum_cells += num_cells diff --git a/scripts/i.spectral/i.spectral.py b/scripts/i.spectral/i.spectral.py index d40c1076169..07efd8af31f 100755 --- a/scripts/i.spectral/i.spectral.py +++ b/scripts/i.spectral/i.spectral.py @@ -136,10 +136,7 @@ def draw_gnuplot(what, xlabels, output, img_format, coord_legend): cmd = [] for i, row in enumerate(what): - if not coord_legend: - title = "Pick " + str(i + 1) - else: - title = str(tuple(row[0:2])) + title = "Pick " + str(i + 1) if not coord_legend else str(tuple(row[0:2])) x_datafile = os.path.join(tmp_dir, "data_%d" % i) cmd.append(" '%s' title '%s'" % (x_datafile, title)) @@ -197,8 +194,8 @@ def draw_linegraph(what): gcore.fatal( _( "Supported monitor isn't running. Please launch one of the" - " monitors {}.".format(", ".join(supported_monitors)) - ) + " monitors {}." + ).format(", ".join(supported_monitors)) ) selected_monitor = gcore.read_command("d.mon", flags="p", quiet=True).replace( "\n", "" @@ -207,17 +204,15 @@ def draw_linegraph(what): gcore.fatal( _( "Supported monitor isn't selected. Please select one of the" - " monitors {}.".format(", ".join(supported_monitors)) - ) + " monitors {}." + ).format(", ".join(supported_monitors)) ) with open(gcore.parse_command("d.mon", flags="g", quiet=True)["env"]) as f: for line in f: if "GRASS_RENDER_FILE=" in line: gcore.info( - _( - "{} monitor is used, output file {}".format( - selected_monitor.capitalize(), line.split("=")[-1] - ) + _("{} monitor is used, output file {}").format( + selected_monitor.capitalize(), line.split("=")[-1] ) ) break diff --git a/scripts/i.tasscap/i.tasscap.py b/scripts/i.tasscap/i.tasscap.py index 4c68c234c73..dc767fd3f19 100755 --- a/scripts/i.tasscap/i.tasscap.py +++ b/scripts/i.tasscap/i.tasscap.py @@ -352,7 +352,7 @@ def main(): # assign "Data Description" field in all four component maps num_comp = len(parms[satellites.index(satellite)]) - for i in range(0, num_comp): + for i in range(num_comp): comp = names[i] gs.run_command( "r.support", diff --git a/scripts/m.proj/m.proj.py b/scripts/m.proj/m.proj.py index 4540b3dcd0a..a018606fff9 100755 --- a/scripts/m.proj/m.proj.py +++ b/scripts/m.proj/m.proj.py @@ -236,14 +236,8 @@ def main(): gcore.debug("output file=[%s]" % outfile) # set up output style - if not decimal: - outfmt = ["-w5"] - else: - outfmt = ["-f", "%.8f"] - if not copy_input: - copyinp = [] - else: - copyinp = ["-E"] + outfmt = ["-w5"] if not decimal else ["-f", "%.8f"] + copyinp = [] if not copy_input else ["-E"] # do the conversion # Convert cs2cs DMS format to GRASS DMS format: diff --git a/scripts/r.buffer.lowmem/r.buffer.lowmem.py b/scripts/r.buffer.lowmem/r.buffer.lowmem.py index 2916ad95e7d..8866c21faeb 100755 --- a/scripts/r.buffer.lowmem/r.buffer.lowmem.py +++ b/scripts/r.buffer.lowmem/r.buffer.lowmem.py @@ -92,10 +92,7 @@ def main(): s = gs.read_command("g.proj", flags="j") kv = gs.parse_key_val(s) - if kv["+proj"] == "longlat": - metric = "geodesic" - else: - metric = "squared" + metric = "geodesic" if kv["+proj"] == "longlat" else "squared" gs.run_command( "r.grow.distance", input=input, metric=metric, distance=temp_dist, flags="m" diff --git a/scripts/r.fillnulls/r.fillnulls.py b/scripts/r.fillnulls/r.fillnulls.py index a53d19a8a72..b22550db497 100755 --- a/scripts/r.fillnulls/r.fillnulls.py +++ b/scripts/r.fillnulls/r.fillnulls.py @@ -273,7 +273,7 @@ def main(): type="area", quiet=quiet, ) - except: + except CalledModuleError: gs.fatal( _( "abandoned. Removing temporary maps, restoring " @@ -481,7 +481,7 @@ def main(): tmp_rmaps.remove(holename + "_edges") tmp_rmaps.remove(holename + "_dem") tmp_vmaps.remove(holename) - except: + except ValueError: pass gs.warning( _( @@ -545,7 +545,7 @@ def main(): tmp_rmaps.remove(holename + "_grown") tmp_rmaps.remove(holename + "_edges") tmp_rmaps.remove(holename + "_dem") - except: + except ValueError: pass try: gs.run_command( @@ -569,7 +569,7 @@ def main(): ) try: tmp_vmaps.remove(holename) - except: + except ValueError: pass try: gs.run_command( diff --git a/scripts/r.fillnulls/testsuite/test_r_fillnulls.py b/scripts/r.fillnulls/testsuite/test_r_fillnulls.py index 975fd5330f2..dda6d99ed95 100644 --- a/scripts/r.fillnulls/testsuite/test_r_fillnulls.py +++ b/scripts/r.fillnulls/testsuite/test_r_fillnulls.py @@ -4,8 +4,6 @@ @author: Sanjeet Bhatti """ -import os - from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.gmodules import SimpleModule diff --git a/scripts/r.grow/r.grow.html b/scripts/r.grow/r.grow.html index cbf0088ca3c..b1b037fe5bd 100644 --- a/scripts/r.grow/r.grow.html +++ b/scripts/r.grow/r.grow.html @@ -80,8 +80,8 @@

    SEE ALSO

    r.patch
    -

    Wikipedia Entry: Euclidean Metric
    -Wikipedia Entry: Manhattan Metric +

    Wikipedia Entry: Euclidean Metric
    +Wikipedia Entry: Manhattan Metric

    AUTHORS

    diff --git a/scripts/r.grow/testsuite/test_r_grow.py b/scripts/r.grow/testsuite/test_r_grow.py index 3d54b9ab993..1c9488b4180 100644 --- a/scripts/r.grow/testsuite/test_r_grow.py +++ b/scripts/r.grow/testsuite/test_r_grow.py @@ -7,7 +7,6 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.gmodules import SimpleModule -from grass.script.core import run_command class TestRGrow(TestCase): diff --git a/scripts/r.import/testsuite/test_r_import.py b/scripts/r.import/testsuite/test_r_import.py index 0e4ec3839e5..075b3a363cf 100755 --- a/scripts/r.import/testsuite/test_r_import.py +++ b/scripts/r.import/testsuite/test_r_import.py @@ -13,9 +13,9 @@ class TestRImportRegion(TestCase): def setUpClass(cls): cls.runModule("g.region", raster="elevation") - def tearDown(cls): + def tearDown(self): """Remove imported map after each test method""" - cls.runModule("g.remove", flags="f", type="raster", name=cls.imported) + self.runModule("g.remove", flags="f", type="raster", name=self.imported) def test_import_estimate(self): """Test e flag""" diff --git a/scripts/r.in.aster/r.in.aster.py b/scripts/r.in.aster/r.in.aster.py index 24722293dde..626d27e7976 100755 --- a/scripts/r.in.aster/r.in.aster.py +++ b/scripts/r.in.aster/r.in.aster.py @@ -152,10 +152,7 @@ def main(): # Band 3b is not included ASTER L1T if proctype == "L1T": allbands.remove("3b") - if band == "all": - bandlist = allbands - else: - bandlist = band.split(",") + bandlist = allbands if band == "all" else band.split(",") # initialize datasets for L1A, L1B, L1T if proctype in {"L1A", "L1B", "L1T"}: diff --git a/scripts/r.in.srtm/r.in.srtm.py b/scripts/r.in.srtm/r.in.srtm.py index 1e4c585ac02..49c7cef9758 100755 --- a/scripts/r.in.srtm/r.in.srtm.py +++ b/scripts/r.in.srtm/r.in.srtm.py @@ -76,6 +76,7 @@ import atexit import grass.script as gs import zipfile as zfile +from grass.exceptions import CalledModuleError tmpl1sec = """BYTEORDER M @@ -177,10 +178,7 @@ def main(): infile = infile[:-4] (fdir, tile) = os.path.split(infile) - if not output: - tileout = tile - else: - tileout = output + tileout = output or tile if ".hgt" in input: suff = ".hgt" @@ -230,7 +228,7 @@ def main(): try: zf = zfile.ZipFile(zipfile) zf.extractall() - except: + except (zfile.BadZipfile, zfile.LargeZipFile, PermissionError): gs.fatal(_("Unable to unzip file.")) gs.message(_("Converting input file to BIL...")) @@ -277,7 +275,7 @@ def main(): try: gs.run_command("r.in.gdal", input=bilfile, out=tileout) - except: + except CalledModuleError: gs.fatal(_("Unable to import data")) # nice color table diff --git a/scripts/r.in.wms/r.in.wms.html b/scripts/r.in.wms/r.in.wms.html index ff95f3851ea..0031627991c 100644 --- a/scripts/r.in.wms/r.in.wms.html +++ b/scripts/r.in.wms/r.in.wms.html @@ -22,7 +22,7 @@

    NOTES

    When using GDAL WMS driver (driver=WMS_GDAL), the GDAL library needs to be built with WMS support, -see GDAL WMS manual page +see GDAL WMS manual page for details.

    Tiled WMS

    diff --git a/scripts/r.in.wms/wms_base.py b/scripts/r.in.wms/wms_base.py index a14e15dc786..2d959289b23 100644 --- a/scripts/r.in.wms/wms_base.py +++ b/scripts/r.in.wms/wms_base.py @@ -78,10 +78,8 @@ def _initializeParameters(self, options, flags): self.params["password"] == "" and self.params["username"] ): gs.fatal( - _( - "Please insert both %s and %s parameters or none of them." - % ("password", "username") - ) + _("Please insert both %s and %s parameters or none of them.") + % ("password", "username") ) self.params["bgcolor"] = options["bgcolor"].strip() @@ -202,8 +200,8 @@ def _checkIgnoeredParams(self, options, flags, driver_props): _( "These parameter are ignored: %s\n\ %s driver does not support the parameters." - % (",".join(not_relevant_params), options["driver"]) ) + % (",".join(not_relevant_params), options["driver"]) ) not_relevant_flags = [] @@ -216,8 +214,8 @@ def _checkIgnoeredParams(self, options, flags, driver_props): _( "These flags are ignored: %s\n\ %s driver does not support the flags." - % (",".join(not_relevant_flags), options["driver"]) ) + % (",".join(not_relevant_flags), options["driver"]) ) def GetMap(self, options, flags): @@ -308,7 +306,7 @@ def GetCapabilities(self, options): Path(capfile_output).write_text(cap) return except OSError as error: - gs.fatal(_("Unable to open file '%s'.\n%s\n" % (capfile_output, error))) + gs.fatal(_("Unable to open file '%s'.\n%s\n") % (capfile_output, error)) # print to output print(cap) @@ -784,8 +782,7 @@ def GetSRSParamVal(srs): if srs in {84, 83, 27}: return "OGC:CRS{}".format(srs) - else: - return "EPSG:{}".format(srs) + return "EPSG:{}".format(srs) def GetEpsg(srs): diff --git a/scripts/r.in.wms/wms_cap_parsers.py b/scripts/r.in.wms/wms_cap_parsers.py index 5483be0979f..e9704651c7b 100644 --- a/scripts/r.in.wms/wms_cap_parsers.py +++ b/scripts/r.in.wms/wms_cap_parsers.py @@ -45,7 +45,7 @@ def __init__(self, cap_file): raise ParseError(_("Unable to parse XML file")) except OSError as error: raise ParseError( - _("Unable to open XML file '%s'.\n%s\n" % (cap_file, error)) + _("Unable to open XML file '%s'.\n%s\n") % (cap_file, error) ) else: try: @@ -105,8 +105,7 @@ def __init__(self, cap_file, force_version=None): raise ParseError( _("Missing version attribute root node in Capabilities XML file") ) - else: - wms_version = self.getroot().attrib["version"] + wms_version = self.getroot().attrib["version"] if wms_version == "1.3.0": self.proj_tag = "CRS" @@ -501,10 +500,7 @@ def _find(self, etreeElement, tag, ns=None): """!Find child element. If the element is not found it raises xml.etree.ElementTree.ParseError. """ - if not ns: - res = etreeElement.find(tag) - else: - res = etreeElement.find(ns(tag)) + res = etreeElement.find(tag) if not ns else etreeElement.find(ns(tag)) if res is None: raise ParseError( @@ -521,10 +517,7 @@ def _findall(self, etreeElement, tag, ns=None): """!Find all children element. If no element is found it raises xml.etree.ElementTree.ParseError. """ - if not ns: - res = etreeElement.findall(tag) - else: - res = etreeElement.findall(ns(tag)) + res = etreeElement.findall(tag) if not ns else etreeElement.findall(ns(tag)) if not res: raise ParseError( diff --git a/scripts/r.in.wms/wms_drv.py b/scripts/r.in.wms/wms_drv.py index 1e7a90e9938..e825aabe438 100644 --- a/scripts/r.in.wms/wms_drv.py +++ b/scripts/r.in.wms/wms_drv.py @@ -155,8 +155,7 @@ def _download(self): sleep(sleep_time) continue - else: - gs.fatal(_("Unable to write data into tempfile.\n%s") % str(e)) + gs.fatal(_("Unable to write data into tempfile.\n%s") % str(e)) finally: temp_tile_opened.close() @@ -286,7 +285,7 @@ def _pct2rgb(self, src_filename, dst_filename): # open source file src_ds = gdal.Open(src_filename) if src_ds is None: - gs.fatal(_("Unable to open %s " % src_filename)) + gs.fatal(_("Unable to open %s ") % src_filename) src_band = src_ds.GetRasterBand(band_number) @@ -587,7 +586,7 @@ def _getQueryBbox(self, bbox, proj, srs_param, version): # CRS:84 and CRS:83 are exception (CRS:83 and CRS:27 need to be tested) if srs_param in {84, 83} or version != "1.3.0": return bbox - elif Srs(GetSRSParamVal(srs_param)).axisorder == "yx": + if Srs(GetSRSParamVal(srs_param)).axisorder == "yx": return self._flipBbox(bbox) return bbox @@ -736,9 +735,7 @@ def _findTileMats(self, tile_mats, region, bbox): best_diff = best_scale_den - scale_den mat_diff = mat_scale_den - scale_den - if (best_diff < mat_diff and mat_diff < 0) or ( - best_diff > mat_diff and best_diff > 0 - ): + if (best_diff < mat_diff < 0) or (best_diff > mat_diff and best_diff > 0): best_t_mat = t_mat best_scale_den = mat_scale_den @@ -997,10 +994,7 @@ def _parseTilePattern(self, group_t_patts, bbox, region): res["y"] = (bbox["maxy"] - bbox["miny"]) / region["rows"] res["x"] = (bbox["maxx"] - bbox["minx"]) / region["cols"] - if res["x"] < res["y"]: - comp_res = "x" - else: - comp_res = "y" + comp_res = "x" if res["x"] < res["y"] else "y" t_res = {} best_patt = None @@ -1020,9 +1014,7 @@ def _parseTilePattern(self, group_t_patts, bbox, region): best_diff = best_res - res[comp_res] tile_diff = t_res[comp_res] - res[comp_res] - if (best_diff < tile_diff and tile_diff < 0) or ( - best_diff > tile_diff and best_diff > 0 - ): + if (best_diff < tile_diff < 0) or (best_diff > tile_diff and best_diff > 0): best_res = t_res[comp_res] best_patt = pattern diff --git a/scripts/r.in.wms/wms_gdal_drv.py b/scripts/r.in.wms/wms_gdal_drv.py index d17bac11eee..830be2b593e 100644 --- a/scripts/r.in.wms/wms_gdal_drv.py +++ b/scripts/r.in.wms/wms_gdal_drv.py @@ -155,7 +155,7 @@ def _download(self): xml_file = self._createXML() # print xml file content for debug level 1 - file = open(xml_file, "r") + file = open(xml_file) gs.debug("WMS request XML:\n%s" % file.read(), 1) file.close() @@ -172,7 +172,7 @@ def _download(self): driver = gdal.GetDriverByName(self.gdal_drv_format) if driver is None: - gs.fatal(_("Unable to find %s driver" % format)) + gs.fatal(_("Unable to find %s driver") % self.gdal_drv_format) metadata = driver.GetMetadata() if ( diff --git a/scripts/r.mapcalc.simple/testsuite/test_rmapcalcsimple.py b/scripts/r.mapcalc.simple/testsuite/test_rmapcalcsimple.py index d400ccc7980..f133da22f7d 100644 --- a/scripts/r.mapcalc.simple/testsuite/test_rmapcalcsimple.py +++ b/scripts/r.mapcalc.simple/testsuite/test_rmapcalcsimple.py @@ -24,8 +24,9 @@ def setUpClass(cls): def tearDownClass(cls): map_output1 = "test1" map_output2 = "test2" - cls.runModule("g.remove", flags="f", type="raster", name=map_output1) - cls.runModule("g.remove", flags="f", type="raster", name=map_output2) + cls.runModule( + "g.remove", flags="f", type="raster", name=(map_output1, map_output2) + ) cls.del_temp_region() def test_rmapcalcsimple(self): diff --git a/scripts/r.out.xyz/r.out.xyz.html b/scripts/r.out.xyz/r.out.xyz.html index c9b2b6510be..e603c592e32 100644 --- a/scripts/r.out.xyz/r.out.xyz.html +++ b/scripts/r.out.xyz/r.out.xyz.html @@ -6,7 +6,7 @@

    DESCRIPTION

    NOTES

    This module will by default not export x,y coordinates for raster cells -containing a NULL value. This includes cells masked by a raster MASK. +containing a NULL value. This includes cells masked by a raster mask. Using the flag -i also these raster cells will be included in the exported data.

    diff --git a/scripts/r.out.xyz/r.out.xyz.py b/scripts/r.out.xyz/r.out.xyz.py index ae8e04de4d6..6df97f3c202 100755 --- a/scripts/r.out.xyz/r.out.xyz.py +++ b/scripts/r.out.xyz/r.out.xyz.py @@ -48,10 +48,7 @@ def main(): output = options["output"] donodata = flags["i"] - if donodata: - statsflags = "1g" - else: - statsflags = "1gn" + statsflags = "1g" if donodata else "1gn" parameters = { "flags": statsflags, "input": options["input"], diff --git a/scripts/r.pack/r.pack.py b/scripts/r.pack/r.pack.py index cd7d6c39282..5029f93c6d2 100644 --- a/scripts/r.pack/r.pack.py +++ b/scripts/r.pack/r.pack.py @@ -37,6 +37,8 @@ import atexit import tarfile +from pathlib import Path + from grass.script.utils import try_rmdir, try_remove from grass.script import core as grass @@ -80,7 +82,7 @@ def main(): grass.message(_("Packing <%s> to <%s>...") % (gfile["fullname"], outfile)) basedir = os.path.sep.join(os.path.normpath(gfile["file"]).split(os.path.sep)[:-2]) - olddir = os.getcwd() + olddir = Path.cwd() # copy elements info = grass.parse_command("r.info", flags="e", map=infile) @@ -93,7 +95,7 @@ def main(): if map_file["file"]: vrt = os.path.join(map_file["file"], "vrt") if os.path.exists(vrt): - with open(vrt, "r") as f: + with open(vrt) as f: for r in f: map, mapset = r.split("@") map_basedir = os.path.sep.join( @@ -180,7 +182,7 @@ def main(): os.chdir(olddir) - grass.verbose(_("Raster map saved to '%s'" % outfile)) + grass.verbose(_("Raster map saved to '%s'") % outfile) if __name__ == "__main__": diff --git a/scripts/r.reclass.area/r.reclass.area.py b/scripts/r.reclass.area/r.reclass.area.py index 5d6fc1292bc..01e474659bc 100755 --- a/scripts/r.reclass.area/r.reclass.area.py +++ b/scripts/r.reclass.area/r.reclass.area.py @@ -152,10 +152,7 @@ def reclass(inf, outf, lim, clump, diag, les): if len(f) < 5: continue hectares = float(f[4]) * 0.0001 - if lesser: - test = hectares <= limit - else: - test = hectares >= limit + test = hectares <= limit if lesser else hectares >= limit if test: rules += "%s = %s %s\n" % (f[0], f[2], f[3]) if rules: diff --git a/scripts/r.reclass.area/testsuite/test_r_reclass_area.py b/scripts/r.reclass.area/testsuite/test_r_reclass_area.py index c8009ce5a1d..96c922bda05 100644 --- a/scripts/r.reclass.area/testsuite/test_r_reclass_area.py +++ b/scripts/r.reclass.area/testsuite/test_r_reclass_area.py @@ -26,8 +26,12 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): cls.del_temp_region() - cls.runModule("g.remove", type="raster", flags="f", name=cls.output + "Greater") - cls.runModule("g.remove", type="raster", flags="f", name=cls.output + "Lesser") + cls.runModule( + "g.remove", + type="raster", + flags="f", + name=(cls.output + "Greater", cls.output + "Lesser"), + ) def test_reclassaeaGreater(self): """Testing r.reclass.area with greater""" diff --git a/scripts/r.reclass.area/testsuite/testrra.py b/scripts/r.reclass.area/testsuite/testrra.py index e6e2300875b..5e11bf6aecc 100644 --- a/scripts/r.reclass.area/testsuite/testrra.py +++ b/scripts/r.reclass.area/testsuite/testrra.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2018 Copyright: (C) 2018 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase @@ -26,8 +26,8 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - def tearDown(cls): - cls.runModule("g.remove", type="raster", flags="f", name=cls.output) + def tearDown(self): + self.runModule("g.remove", type="raster", flags="f", name=self.output) def test_flag_c(self): """Testing flag c""" diff --git a/scripts/r.semantic.label/r.semantic.label.html b/scripts/r.semantic.label/r.semantic.label.html index 9ebcfce10a6..45ac7b9373e 100644 --- a/scripts/r.semantic.label/r.semantic.label.html +++ b/scripts/r.semantic.label/r.semantic.label.html @@ -25,10 +25,10 @@

    NOTES

    Semantic labels are supported by temporal GRASS modules. Name of STRDS can be extended by band identifier in order to filter the result by a semantic label. See -t.register, -t.rast.list, -t.info -and t.rast.mapcalc +t.register, +t.rast.list, +t.info +and t.rast.mapcalc modules for examples.

    EXAMPLES

    diff --git a/scripts/r.semantic.label/testsuite/test_r_semantic_label.py b/scripts/r.semantic.label/testsuite/test_r_semantic_label.py index b7456e22633..990954dbb5f 100644 --- a/scripts/r.semantic.label/testsuite/test_r_semantic_label.py +++ b/scripts/r.semantic.label/testsuite/test_r_semantic_label.py @@ -27,7 +27,7 @@ def read_semantic_label(self): return rast.info.semantic_label def test_semantic_label_assign_not_current_mapset(self): - if not self.mapset == "PERMANENT": + if self.mapset != "PERMANENT": self.mapset.name = "PERMANENT" a_map = self.mapset.glist(type="raster")[0] module = SimpleModule( diff --git a/scripts/r.tileset/r.tileset.py b/scripts/r.tileset/r.tileset.py index f5e7ab17b13..c3fba2c173e 100644 --- a/scripts/r.tileset/r.tileset.py +++ b/scripts/r.tileset/r.tileset.py @@ -246,16 +246,16 @@ def main(): _( "It is not possible to set 'maxcols=%s' and " "'overlap=%s'. Please set maxcols>overlap" - % (options["maxcols"], options["overlap"]) ) + % (options["maxcols"], options["overlap"]) ) elif max_rows == 0: gcore.fatal( _( "It is not possible to set 'maxrows=%s' and " "'overlap=%s'. Please set maxrows>overlap" - % (options["maxrows"], options["overlap"]) ) + % (options["maxrows"], options["overlap"]) ) # destination projection if not options["destproj"]: @@ -397,7 +397,7 @@ def main(): if errors_dest > 0: gcore.warning( - _("During computation %i tiles could not be created" % errors_dest) + _("During computation %i tiles could not be created") % errors_dest ) while xi < ximax: diff --git a/scripts/r.tileset/testsuite/test_r_tileset.py b/scripts/r.tileset/testsuite/test_r_tileset.py index 7f1c62ed1f5..cba9908d900 100644 --- a/scripts/r.tileset/testsuite/test_r_tileset.py +++ b/scripts/r.tileset/testsuite/test_r_tileset.py @@ -7,6 +7,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows from grass.script.utils import decode @@ -36,6 +37,7 @@ def tearDownClass(cls): """!Remove the temporary region""" cls.del_temp_region() + @xfail_windows def test_tiling(self): """Produce tiling test""" module = SimpleModule( diff --git a/scripts/r.unpack/r.unpack.py b/scripts/r.unpack/r.unpack.py index 053ac96988b..dd595b4722b 100644 --- a/scripts/r.unpack/r.unpack.py +++ b/scripts/r.unpack/r.unpack.py @@ -63,7 +63,7 @@ def main(): grass.debug("tmp_dir = {tmpdir}".format(tmpdir=tmp_dir)) if not os.path.exists(infile): - grass.fatal(_("File {name} not found.".format(name=infile))) + grass.fatal(_("File {name} not found.").format(name=infile)) gisenv = grass.gisenv() mset_dir = os.path.join( @@ -87,26 +87,21 @@ def main(): f = tar.extractfile("{}/{}".format(data_names[0], fname)) sys.stdout.write(f.read().decode()) except KeyError: - grass.fatal(_("Pack file unreadable: file '{}' missing".format(fname))) + grass.fatal(_("Pack file unreadable: file '{}' missing").format(fname)) tar.close() return 0 - if options["output"]: - map_name = options["output"] - else: - map_name = data_names[0].split("@")[0] + map_name = options["output"] or data_names[0].split("@")[0] gfile = grass.find_file(name=map_name, element="cell", mapset=".") if gfile["file"]: if os.environ.get("GRASS_OVERWRITE", "0") != "1": - grass.fatal(_("Raster map <{name}> already exists".format(name=map_name))) + grass.fatal(_("Raster map <{name}> already exists").format(name=map_name)) else: grass.warning( - _( - "Raster map <{name}> already exists and will be overwritten".format( - name=map_name - ) + _("Raster map <{name}> already exists and will be overwritten").format( + name=map_name ) ) @@ -132,9 +127,10 @@ def main(): grass.fatal( _( "This GRASS GIS pack file contains vector data. Use " - "v.unpack to unpack <{name}>".format(name=map_name) - ) + "v.unpack to unpack <{name}>" + ).format(name=map_name) ) + else: grass.fatal(_("Pack file unreadable")) @@ -246,7 +242,7 @@ def main(): files = "\n".join(maps) Path(vrt_file).write_text(files) - grass.message(_("Raster map <{name}> unpacked".format(name=map_name))) + grass.message(_("Raster map <{name}> unpacked").format(name=map_name)) if __name__ == "__main__": diff --git a/scripts/r3.in.xyz/r3.in.xyz.py b/scripts/r3.in.xyz/r3.in.xyz.py index b17d59506b7..5b2c8be4a65 100755 --- a/scripts/r3.in.xyz/r3.in.xyz.py +++ b/scripts/r3.in.xyz/r3.in.xyz.py @@ -226,10 +226,7 @@ def main(): addl_opts["flags"] = "i" if scan_only or shell_style: - if shell_style: - doShell = "g" - else: - doShell = "" + doShell = "g" if shell_style else "" grass.run_command( "r.in.xyz", flags="s" + doShell, @@ -243,10 +240,7 @@ def main(): ) sys.exit() - if dtype == "float": - data_type = "FCELL" - else: - data_type = "DCELL" + data_type = "FCELL" if dtype == "float" else "DCELL" region = grass.region(region3d=True) diff --git a/scripts/v.build.all/v.build.all.py b/scripts/v.build.all/v.build.all.py index 69b0837209f..8691ecddc32 100755 --- a/scripts/v.build.all/v.build.all.py +++ b/scripts/v.build.all/v.build.all.py @@ -31,10 +31,7 @@ def main(): vectors = grass.list_grouped("vect")[mapset] num_vectors = len(vectors) - if grass.verbosity() < 2: - quiet = True - else: - quiet = False + quiet = grass.verbosity() < 2 i = 1 for vect in vectors: diff --git a/scripts/v.centroids/testsuite/test_v_centroids.py b/scripts/v.centroids/testsuite/test_v_centroids.py index 4b0654748a5..a7f56464ef6 100644 --- a/scripts/v.centroids/testsuite/test_v_centroids.py +++ b/scripts/v.centroids/testsuite/test_v_centroids.py @@ -12,37 +12,47 @@ class TestVCentroids(TestCase): """Test v.centroids script""" - mapName = "busroute11" - outRouteMap = "busroute11_boundary" - fromType = "line" - toType = "boundary" - outAreaMap = "busroute11_area" + region_line = "region_line" + region_boundary = "region_boundary" + region_area = "region_area" + output = "output" @classmethod def setUpClass(cls): """Create an area from a closed line""" + cls.runModule("v.in.region", output=cls.region_line, type="line") + cls.runModule("v.in.region", output=cls.region_area, type="area") cls.runModule( "v.type", - input=cls.mapName, - output=cls.outRouteMap, - from_type=cls.fromType, - to_type=cls.toType, + input=cls.region_line, + output=cls.region_boundary, + from_type="line", + to_type="boundary", ) @classmethod def tearDownClass(cls): """Remove the generated maps""" cls.runModule( - "g.remove", flags="f", type="vector", name=(cls.outRouteMap, cls.outAreaMap) + "g.remove", + flags="f", + type="vector", + name=(cls.region_line, cls.region_area, cls.region_boundary), ) + def tearDown(self): + """Remove the generated maps""" + self.runModule("g.remove", flags="f", type="vector", name=self.output) + def test_area(self): """Adds missing centroids to closed boundaries test""" module = SimpleModule( - "v.centroids", input=self.outRouteMap, output=self.outAreaMap + "v.centroids", input=self.region_boundary, output=self.output ) self.assertModule(module) - self.assertVectorExists(self.outAreaMap) + self.assertVectorInfoEqualsVectorInfo( + self.output, self.region_area, precision=1e-6 + ) if __name__ == "__main__": diff --git a/scripts/v.centroids/v.centroids.html b/scripts/v.centroids/v.centroids.html index 2bebed24e97..b814b702bab 100644 --- a/scripts/v.centroids/v.centroids.html +++ b/scripts/v.centroids/v.centroids.html @@ -1,11 +1,13 @@

    DESCRIPTION

    -GRASS defines vector areas as composite entities consisting of a set of +In GRASS GIS, a centroid is a point within a closed ring of boundaries. +A vector area is defined as composite entity consisting of a set of closed boundaries and a centroid. The attribute information associated -with that area is linked to the centroid. The v.centroids module -adds centroids to closed boundaries in the input file and assigns a -category number to them. The starting value as well as the increment size -may be set using optional parameters. +with this area is linked to the centroid. + +The v.centroids module adds centroids to closed boundaries in +the input file and assigns a category number to them. The starting +value as well as the increment size may be set using optional parameters.

    Multiple attributes may be linked to a single vector entity through numbered fields referred to as layers. Refer to v.category for more details, as v.centroids is simply a frontend to that diff --git a/scripts/v.db.dropcolumn/v.db.dropcolumn.py b/scripts/v.db.dropcolumn/v.db.dropcolumn.py index 298a29133b3..fd34f36893f 100755 --- a/scripts/v.db.dropcolumn/v.db.dropcolumn.py +++ b/scripts/v.db.dropcolumn/v.db.dropcolumn.py @@ -86,7 +86,7 @@ def main(): if driver == "sqlite": # echo "Using special trick for SQLite" - # http://www.sqlite.org/faq.html#q11 + # https://www.sqlite.org/faq.html#q11 colnames = [] coltypes = [] for f in gs.db_describe(table, database=database, driver=driver)["cols"]: diff --git a/scripts/v.db.join/v.db.join.html b/scripts/v.db.join/v.db.join.html index e44705c55b5..436c86a7d43 100644 --- a/scripts/v.db.join/v.db.join.html +++ b/scripts/v.db.join/v.db.join.html @@ -16,8 +16,8 @@

    EXAMPLES

    Exercise to join North Carolina geological classes from a CSV table to the "geology" map of the North Carolina sample dataset (requires download -of legend CSV file nc_geology.csv -from External data for NC sample dataset): +of legend CSV file nc_geology.csv +from External data for NC sample dataset):
     # check original map attributes
    @@ -49,7 +49,7 @@ 

    EXAMPLES

    Soil map table join

    Joining the soil type explanations from table soils_legend -into the Spearfish soils map (download legend): +into the Spearfish soils map (download legend):
     g.copy vect=soils,mysoils
    diff --git a/scripts/v.db.reconnect.all/v.db.reconnect.all.py b/scripts/v.db.reconnect.all/v.db.reconnect.all.py
    index b42b8006673..7a422f47f7f 100755
    --- a/scripts/v.db.reconnect.all/v.db.reconnect.all.py
    +++ b/scripts/v.db.reconnect.all/v.db.reconnect.all.py
    @@ -19,6 +19,8 @@
     # % keyword: vector
     # % keyword: attribute table
     # % keyword: database
    +# % keyword: DBF
    +# % keyword: SQLite
     # %end
     # %flag
     # % key: c
    @@ -255,10 +257,7 @@ def main():
                     schema = ""
                     table = schema_table
     
    -            if new_schema:
    -                new_schema_table = "%s.%s" % (new_schema, table)
    -            else:
    -                new_schema_table = table
    +            new_schema_table = "%s.%s" % (new_schema, table) if new_schema else table
     
                 gs.debug(
                     "DATABASE = '%s' SCHEMA = '%s' TABLE = '%s' ->\n"
    diff --git a/scripts/v.dissolve/tests/conftest.py b/scripts/v.dissolve/tests/conftest.py
    index 9b069330488..e5e9a38818d 100644
    --- a/scripts/v.dissolve/tests/conftest.py
    +++ b/scripts/v.dissolve/tests/conftest.py
    @@ -13,10 +13,7 @@
     def updates_as_transaction(table, cat_column, column, column_quote, cats, values):
         """Create SQL statement for categories and values for a given column"""
         sql = ["BEGIN TRANSACTION"]
    -    if column_quote:
    -        quote = "'"
    -    else:
    -        quote = ""
    +    quote = "'" if column_quote else ""
         for cat, value in zip(cats, values):
             sql.append(
                 f"UPDATE {table} SET {column} = {quote}{value}{quote} "
    diff --git a/scripts/v.dissolve/tests/v_dissolve_aggregate_test.py b/scripts/v.dissolve/tests/v_dissolve_aggregate_test.py
    index 68ca178b864..90dc3de075e 100644
    --- a/scripts/v.dissolve/tests/v_dissolve_aggregate_test.py
    +++ b/scripts/v.dissolve/tests/v_dissolve_aggregate_test.py
    @@ -101,10 +101,7 @@ def test_aggregate_column_result(dataset, backend):
         for stats_column in stats_columns:
             assert stats_column in columns
             column_info = columns[stats_column]
    -        if stats_column.endswith("_n"):
    -            correct_type = "integer"
    -        else:
    -            correct_type = "double precision"
    +        correct_type = "integer" if stats_column.endswith("_n") else "double precision"
             assert (
                 columns[stats_column]["type"].lower() == correct_type
             ), f"{stats_column} has a wrong type"
    @@ -221,10 +218,7 @@ def test_sqlite_agg_accepted(dataset):
         for method, stats_column in zip(stats, expected_stats_columns):
             assert stats_column in columns
             column_info = columns[stats_column]
    -        if method == "count":
    -            correct_type = "integer"
    -        else:
    -            correct_type = "double precision"
    +        correct_type = "integer" if method == "count" else "double precision"
             assert (
                 columns[stats_column]["type"].lower() == correct_type
             ), f"{stats_column} has a wrong type"
    diff --git a/scripts/v.dissolve/tests/v_dissolve_layers_test.py b/scripts/v.dissolve/tests/v_dissolve_layers_test.py
    index 702aa8f8496..f6986d35917 100644
    --- a/scripts/v.dissolve/tests/v_dissolve_layers_test.py
    +++ b/scripts/v.dissolve/tests/v_dissolve_layers_test.py
    @@ -50,10 +50,7 @@ def test_layer_2(dataset_layer_2):
         for method, stats_column in zip(stats, expected_stats_columns):
             assert stats_column in columns
             column_info = columns[stats_column]
    -        if method == "count":
    -            correct_type = "integer"
    -        else:
    -            correct_type = "double precision"
    +        correct_type = "integer" if method == "count" else "double precision"
             assert (
                 columns[stats_column]["type"].lower() == correct_type
             ), f"{stats_column} has a wrong type"
    diff --git a/scripts/v.dissolve/v_dissolve.ipynb b/scripts/v.dissolve/v_dissolve.ipynb
    index f90907a704d..085b23828d8 100644
    --- a/scripts/v.dissolve/v_dissolve.ipynb
    +++ b/scripts/v.dissolve/v_dissolve.ipynb
    @@ -19,7 +19,6 @@
        "metadata": {},
        "outputs": [],
        "source": [
    -    "import os\n",
         "import json\n",
         "import subprocess\n",
         "import sys\n",
    diff --git a/scripts/v.import/testsuite/test_v_import.py b/scripts/v.import/testsuite/test_v_import.py
    index d8dd6b85887..90934bbb3e6 100755
    --- a/scripts/v.import/testsuite/test_v_import.py
    +++ b/scripts/v.import/testsuite/test_v_import.py
    @@ -18,9 +18,9 @@
     class TestVImport(TestCase):
         imported = "test_v_import_imported"
     
    -    def tearDown(cls):
    +    def tearDown(self):
             """Remove imported map after each test method"""
    -        cls.runModule("g.remove", flags="f", type="vector", name=cls.imported)
    +        self.runModule("g.remove", flags="f", type="vector", name=self.imported)
     
         def test_import_same_proj_gpkg(self):
             """Import GPKG in same proj, default params"""
    diff --git a/scripts/v.import/v.import.html b/scripts/v.import/v.import.html
    index a530f5f3662..281136939e2 100644
    --- a/scripts/v.import/v.import.html
    +++ b/scripts/v.import/v.import.html
    @@ -1,7 +1,7 @@
     

    DESCRIPTION

    v.import imports vector data from files and database connections -supported by the OGR library into the +supported by the OGR library into the current project (previously called location) and mapset. If the coordinate reference system (CRS) of the input does not match the CRS of the project, the input is reprojected @@ -11,13 +11,13 @@

    DESCRIPTION

    Supported Vector Formats

    v.import uses the OGR library which supports various vector data -formats including ESRI -Shapefile, Mapinfo +formats including ESRI +Shapefile, Mapinfo File, UK .NTF, SDTS, TIGER, IHO S-57 (ENC), DGN, GML, GPX, AVCBin, REC, Memory, OGDI, and PostgreSQL, depending on the local OGR installation. For details see the OGR web site. The OGR (Simple Features Library) is part of the -GDAL library, hence GDAL needs to be +GDAL library, hence GDAL needs to be installed to use v.import.

    diff --git a/scripts/v.import/v.import.py b/scripts/v.import/v.import.py index 4f579c4bf45..1e467cd190b 100755 --- a/scripts/v.import/v.import.py +++ b/scripts/v.import/v.import.py @@ -263,7 +263,7 @@ def main(): if OGRdatasource.lower().endswith("gml"): try: from osgeo import gdal - except: + except ImportError: gs.fatal( _( "Unable to load GDAL Python bindings (requires package " @@ -338,7 +338,7 @@ def main(): if OGRdatasource.lower().endswith("gml"): try: from osgeo import gdal - except: + except ImportError: gs.fatal( _( "Unable to load GDAL Python bindings (requires package " diff --git a/scripts/v.in.e00/v.in.e00.html b/scripts/v.in.e00/v.in.e00.html index ef027c192e2..931bec50cf6 100644 --- a/scripts/v.in.e00/v.in.e00.html +++ b/scripts/v.in.e00/v.in.e00.html @@ -12,7 +12,7 @@

    NOTES

    REFERENCES

    AVCE00 library (providing 'avcimport' and 'e00conv')
    -OGR vector library +OGR vector library

    SEE ALSO

    diff --git a/scripts/v.in.e00/v.in.e00.py b/scripts/v.in.e00/v.in.e00.py index 4d63636199f..4258fa3181a 100755 --- a/scripts/v.in.e00/v.in.e00.py +++ b/scripts/v.in.e00/v.in.e00.py @@ -86,10 +86,7 @@ def main(): ) merging = True - if vect: - name = vect - else: - name = e00name + name = vect or e00name # do import diff --git a/scripts/v.in.geonames/v.in.geonames.html b/scripts/v.in.geonames/v.in.geonames.html index f2657c878c3..a38aa770cc5 100644 --- a/scripts/v.in.geonames/v.in.geonames.html +++ b/scripts/v.in.geonames/v.in.geonames.html @@ -78,4 +78,4 @@

    SEE ALSO

    AUTHOR

    -Markus Neteler +Markus Neteler diff --git a/scripts/v.in.lines/v.in.lines.py b/scripts/v.in.lines/v.in.lines.py index 44112b297a3..35991988f6b 100755 --- a/scripts/v.in.lines/v.in.lines.py +++ b/scripts/v.in.lines/v.in.lines.py @@ -50,12 +50,7 @@ def main(): fs = separator(options["separator"]) threeD = flags["z"] - - if threeD: - do3D = "z" - else: - do3D = "" - + do3D = "z" if threeD else "" tmp = grass.tempfile() # set up input file diff --git a/scripts/v.in.mapgen/v.in.mapgen.py b/scripts/v.in.mapgen/v.in.mapgen.py index 404fb7ec6b2..efe7af1075d 100755 --- a/scripts/v.in.mapgen/v.in.mapgen.py +++ b/scripts/v.in.mapgen/v.in.mapgen.py @@ -73,18 +73,12 @@ def main(): if not os.path.isfile(infile): grass.fatal(_("Input file <%s> not found") % infile) - if output: - name = output - else: - name = "" + name = output or "" if threeD: matlab = True - if threeD: - do3D = "z" - else: - do3D = "" + do3D = "z" if threeD else "" tmp = grass.tempfile() diff --git a/scripts/v.pack/v.pack.py b/scripts/v.pack/v.pack.py index cd8d96b86cd..e39d52dbafe 100755 --- a/scripts/v.pack/v.pack.py +++ b/scripts/v.pack/v.pack.py @@ -38,6 +38,8 @@ import tarfile import atexit +from pathlib import Path + from grass.script.utils import try_rmdir, try_remove from grass.script import core as grass from grass.script import vector @@ -71,10 +73,7 @@ def main(): infile = infile.split("@")[0] # output name - if options["output"]: - outfile = options["output"] - else: - outfile = infile + ".pack" + outfile = options["output"] or infile + ".pack" # check if exists the output file if os.path.exists(outfile): @@ -128,7 +127,7 @@ def main(): tar.add(path, "PROJ_" + support) tar.close() - grass.message(_("Pack file <%s> created") % os.path.join(os.getcwd(), outfile)) + grass.message(_("Pack file <%s> created") % Path(outfile).resolve()) if __name__ == "__main__": diff --git a/scripts/v.rast.stats/testsuite/test_v_rast_stats.py b/scripts/v.rast.stats/testsuite/test_v_rast_stats.py index ca3111d14d8..01ae6d4a7d2 100644 --- a/scripts/v.rast.stats/testsuite/test_v_rast_stats.py +++ b/scripts/v.rast.stats/testsuite/test_v_rast_stats.py @@ -5,6 +5,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows from grass.pygrass.vector import VectorTopo from grass.pygrass.vector.geometry import Line from grass.pygrass.vector.geometry import Boundary @@ -23,11 +24,12 @@ def tearDownClass(cls): cls.del_temp_region() def tearDown(self): - self.runModule("g.remove", flags="f", type="raster", name="map_a") - self.runModule("g.remove", flags="f", type="raster", name="map_b") - self.runModule("g.remove", flags="f", type="raster", name="zone_map") - self.runModule("g.remove", flags="f", type="raster", name="row_map") - self.runModule("g.remove", flags="f", type="raster", name="test_line") + self.runModule( + "g.remove", + flags="f", + type="raster", + name="map_a,map_b,zone_map,row_map,test_line", + ) def setUp(self): """Create input data""" @@ -71,6 +73,7 @@ def setUp(self): vt.table.conn.commit() vt.close() + @xfail_windows def test_1(self): # Output of v.rast.stats univar_string = """cat|value|label|a_minimum|a_maximum|a_sum @@ -91,6 +94,7 @@ def test_1(self): self.runModule(v_db_select) self.assertLooksLike(univar_string, str(v_db_select.outputs.stdout)) + @xfail_windows def test_line_d(self): output_str = """cat|name|a_median|a_number|a_range 1|first|192|3|1 @@ -109,6 +113,7 @@ def test_line_d(self): self.runModule(v_db_select) self.assertLooksLike(output_str, str(v_db_select.outputs.stdout)) + @xfail_windows def test_line(self): output_str = """cat|name|a_median|a_number|a_range 1|first|192|5|2 @@ -128,6 +133,7 @@ def test_line(self): self.runModule(v_db_select) self.assertLooksLike(output_str, str(v_db_select.outputs.stdout)) + @xfail_windows def test_zone_all(self): # Output of v.rast.stats univar_string = """cat|value|label|a_number|a_null_cells|a_minimum|a_maximum|a_range|a_average|a_stddev|a_variance|a_coeff_var|a_sum|a_first_quartile|a_median|a_third_quartile|a_percentile_90 @@ -143,6 +149,7 @@ def test_zone_all(self): self.runModule(v_db_select) self.assertLooksLike(univar_string, str(v_db_select.outputs.stdout)) + @xfail_windows def test_small_area_with_centroid(self): # Output of v.rast.stats univar_string = """cat|name|a_number|a_null_cells|a_minimum|a_maximum|a_range|a_average|a_stddev|a_variance|a_coeff_var|a_sum|a_first_quartile|a_median|a_third_quartile|a_percentile_90 diff --git a/scripts/v.rast.stats/v.rast.stats.py b/scripts/v.rast.stats/v.rast.stats.py index 1e1451f6b84..4096aa49caf 100644 --- a/scripts/v.rast.stats/v.rast.stats.py +++ b/scripts/v.rast.stats/v.rast.stats.py @@ -116,10 +116,7 @@ def main(): # Get mapset of the vector vs = vector.split("@") - if len(vs) > 1: - vect_mapset = vs[1] - else: - vect_mapset = mapset + vect_mapset = vs[1] if len(vs) > 1 else mapset # does map exist in CURRENT mapset? if vect_mapset != mapset or not gs.find_file(vector, "vector", mapset)["file"]: @@ -143,10 +140,8 @@ def main(): gs.fatal( _( "Number of raster maps ({0}) different from \ - number of column prefixes ({1})".format( - len(rasters), len(colprefixes) - ) - ) + number of column prefixes ({1})" + ).format(len(rasters), len(colprefixes)) ) vector = vs[0] @@ -340,10 +335,8 @@ def get_nr_of_categories( gs.warning( _( "Not all vector categories converted to raster. \ - Converted {0} of {1}.".format( - number, vect_cats_n - ) - ) + Converted {0} of {1}." + ).format(number, vect_cats_n) ) return number @@ -377,10 +370,7 @@ def set_up_columns(vector, layer, percentile, colprefix, basecols, dbfdriver, c) perc = b if perc: # namespace is limited in DBF but the % value is important - if dbfdriver: - perccol = "per" + percentile - else: - perccol = "percentile_" + percentile + perccol = "per" + percentile if dbfdriver else "percentile_" + percentile percindex = basecols.index(perc) basecols[percindex] = perccol @@ -428,10 +418,7 @@ def set_up_columns(vector, layer, percentile, colprefix, basecols, dbfdriver, c) + _("Use -c flag to update values in this column.") ) else: - if i == "n": - coltype = "INTEGER" - else: - coltype = "DOUBLE PRECISION" + coltype = "INTEGER" if i == "n" else "DOUBLE PRECISION" addcols.append(currcolumn + " " + coltype) if addcols: diff --git a/scripts/v.report/v.report.py b/scripts/v.report/v.report.py index 18752a697cb..80e9e8a1189 100755 --- a/scripts/v.report/v.report.py +++ b/scripts/v.report/v.report.py @@ -55,6 +55,8 @@ import sys import os +from operator import itemgetter + import grass.script as gs from grass.script.utils import separator, decode @@ -89,10 +91,7 @@ def main(): isConnection = False colnames = ["cat"] - if option == "coor": - extracolnames = ["x", "y", "z"] - else: - extracolnames = [option] + extracolnames = ["x", "y", "z"] if option == "coor" else [option] if units == "percent": unitsp = "meters" @@ -114,7 +113,7 @@ def main(): cols = decode(line).rstrip("\r\n").split("|") if catcol == -1: ncols = len(cols) - for i in range(0, ncols): + for i in range(ncols): if cols[i] == f["key"]: catcol = i break @@ -134,7 +133,7 @@ def main(): if p.returncode != 0: sys.exit(1) - records1.sort(key=lambda r: r[catcol]) + records1.sort(key=itemgetter(catcol)) if len(records1) == 0: try: @@ -225,7 +224,7 @@ def main(): # calculate percentages records4 = [float(r[-1]) * 100 / total for r in records3] - if type(records1[0]) == int: + if isinstance(records1[0], int): records3 = [[r1] + [r4] for r1, r4 in zip(records1, records4)] else: records3 = [r1 + [r4] for r1, r4 in zip(records1, records4)] diff --git a/scripts/v.to.lines/v.to.lines.py b/scripts/v.to.lines/v.to.lines.py index bfcb2e45bc2..0630ad86401 100644 --- a/scripts/v.to.lines/v.to.lines.py +++ b/scripts/v.to.lines/v.to.lines.py @@ -189,7 +189,7 @@ def main(): gs.fatal(_("Error removing table from layer 1")) # TODO: when this except is happaning, it seems that never, so it seems wrong except Exception: - gs.warning(_("No table for layer %d" % 1)) + gs.warning(_("No table for layer %d") % 1) try: gs.run_command( "v.category", diff --git a/scripts/v.unpack/v.unpack.py b/scripts/v.unpack/v.unpack.py index 0507e9eb400..7baa1042ccd 100644 --- a/scripts/v.unpack/v.unpack.py +++ b/scripts/v.unpack/v.unpack.py @@ -77,7 +77,7 @@ def main(): tar = tarfile.TarFile.open(name=input_base, mode="r") try: data_name = tar.getnames()[0] - except: + except IndexError: grass.fatal(_("Pack file unreadable")) if flags["p"]: @@ -87,16 +87,13 @@ def main(): f = tar.extractfile(fname) sys.stdout.write(f.read().decode()) except KeyError: - grass.fatal(_("Pack file unreadable: file '{}' missing".format(fname))) + grass.fatal(_("Pack file unreadable: file '{}' missing").format(fname)) tar.close() return 0 # set the output name - if options["output"]: - map_name = options["output"] - else: - map_name = data_name + map_name = options["output"] or data_name # grass env gisenv = grass.gisenv() @@ -139,8 +136,9 @@ def main(): grass.fatal( _( "This GRASS GIS pack file contains raster data. Use " - "r.unpack to unpack <%s>" % map_name + "r.unpack to unpack <%s>" ) + % map_name ) else: grass.fatal(_("Pack file unreadable")) @@ -217,7 +215,7 @@ def main(): todb = dbconn["database"] # return the list of old connection for extract layer number and key - dbln = open(os.path.join(new_dir, "dbln"), "r") + dbln = open(os.path.join(new_dir, "dbln")) dbnlist = dbln.readlines() dbln.close() # check if dbf or sqlite directory exists @@ -232,19 +230,13 @@ def main(): # for each old connection for t in dbnlist: # it split the line of each connection, to found layer number and key - if len(t.split("|")) != 1: - values = t.split("|") - else: - values = t.split(" ") + values = t.split("|") if len(t.split("|")) != 1 else t.split(" ") from_table = values[1] layer = values[0].split("/")[0] # we need to take care about the table name in case of several layer if options["output"]: - if len(dbnlist) > 1: - to_table = "%s_%s" % (map_name, layer) - else: - to_table = map_name + to_table = "%s_%s" % (map_name, layer) if len(dbnlist) > 1 else map_name else: to_table = from_table diff --git a/scripts/v.what.strds/v.what.strds.py b/scripts/v.what.strds/v.what.strds.py index 2bd6cd72131..2c819fd0e44 100644 --- a/scripts/v.what.strds/v.what.strds.py +++ b/scripts/v.what.strds/v.what.strds.py @@ -169,13 +169,13 @@ def main(): "datasets must be equal\n<%(a)s> of type " "%(type_a)s do not match <%(b)s> of type " "%(type_b)s" - % { - "a": first_strds.get_id(), - "type_a": first_strds.get_temporal_type(), - "b": dataset.get_id(), - "type_b": dataset.get_temporal_type(), - } ) + % { + "a": first_strds.get_id(), + "type_a": first_strds.get_temporal_type(), + "b": dataset.get_id(), + "type_b": dataset.get_temporal_type(), + } ) mapmatrizes = tgis.sample_stds_by_stds_topology( @@ -202,8 +202,7 @@ def main(): if name is None: isvalid = False break - else: - mapname_list.append(name) + mapname_list.append(name) if isvalid: entry = mapmatrizes[0][i] @@ -225,9 +224,9 @@ def main(): pymap = Vector(output) try: pymap.open("r") - except: + except Exception: dbif.close() - gs.fatal(_("Unable to create vector map <%s>" % output)) + gs.fatal(_("Unable to create vector map <%s>") % output) if len(pymap.dblinks) == 0: try: @@ -235,7 +234,7 @@ def main(): gs.run_command("v.db.addtable", map=output) except CalledModuleError: dbif.close() - gs.fatal(_("Unable to add table <%s> to vector map <%s>" % output)) + gs.fatal(_("Unable to add table <%s> to vector map <%s>") % output) if pymap.is_open(): pymap.close() diff --git a/scripts/v.what.vect/testsuite/test_v_what_vect.py b/scripts/v.what.vect/testsuite/test_v_what_vect.py index 09ade33668f..2385a71c400 100644 --- a/scripts/v.what.vect/testsuite/test_v_what_vect.py +++ b/scripts/v.what.vect/testsuite/test_v_what_vect.py @@ -9,7 +9,6 @@ from grass.gunittest.gmodules import SimpleModule from grass.script.core import run_command -from grass.script.utils import decode class TestVWhatVect(TestCase): @@ -29,20 +28,20 @@ def tearDownClass(cls): def test_what_vect(self): """Uploads vector values""" - run_command("v.db.addcolumn", map=self.mapName, columns="urb_name varchar(25)") + run_command("v.db.addcolumn", map=self.mapName, columns="geology_cat integer") module = SimpleModule( "v.what.vect", map=self.mapName, - query_map="urbanarea", - column="urb_name", - query_column="NAME", + query_map="geology", + column="geology_cat", + query_column="cat", ) self.assertModule(module) - - m = SimpleModule("v.db.select", map=self.mapName) - self.assertModule(m) - self.assertRegex(decode(m.outputs.stdout), "urb_name") + minmax = "min=11\nmax=1810" + self.assertVectorFitsUnivar( + map=self.mapName, column="geology_cat", reference=minmax + ) if __name__ == "__main__": diff --git a/temporal/t.info/t.info.py b/temporal/t.info/t.info.py index 2f0b0d528ec..c04fe0c0a5f 100755 --- a/temporal/t.info/t.info.py +++ b/temporal/t.info/t.info.py @@ -91,7 +91,7 @@ def main(): " +----------------------------------------------------------------------------+" # noqa: E501 ) return - elif system and not history: + if system and not history: print("dbmi_python_interface='" + str(dbif.get_dbmi().__name__) + "'") print("dbmi_string='" + str(tgis.get_tgis_database_string()) + "'") print("sql_template_path='" + str(tgis.get_sql_template_path()) + "'") @@ -103,11 +103,7 @@ def main(): if not system and not name: gs.fatal(_("Please specify %s=") % ("name")) - if name.find("@") >= 0: - id_ = name - else: - id_ = name + "@" + gs.gisenv()["MAPSET"] - + id_ = name if name.find("@") >= 0 else name + "@" + gs.gisenv()["MAPSET"] dataset = tgis.dataset_factory(type_, id_) if not dataset.is_in_db(dbif): diff --git a/temporal/t.list/t.list.py b/temporal/t.list/t.list.py index 52285d04b83..c41bcae4e22 100755 --- a/temporal/t.list/t.list.py +++ b/temporal/t.list/t.list.py @@ -123,10 +123,7 @@ def main(): outfile = open(outpath, "w") for ttype in temporal_type.split(","): - if ttype == "absolute": - time = "absolute time" - else: - time = "relative time" + time = "absolute time" if ttype == "absolute" else "relative time" stds_list = tgis.get_dataset_list(type, ttype, columns, where, order, dbif=dbif) diff --git a/temporal/t.rast.accdetect/t.rast.accdetect.py b/temporal/t.rast.accdetect/t.rast.accdetect.py index 887616f7a1c..17433e06f3f 100644 --- a/temporal/t.rast.accdetect/t.rast.accdetect.py +++ b/temporal/t.rast.accdetect/t.rast.accdetect.py @@ -173,11 +173,7 @@ def main(): mapset = tgis.get_current_mapset() - if input.find("@") >= 0: - id = input - else: - id = input + "@" + mapset - + id = input if input.find("@") >= 0 else input + "@" + mapset input_strds = tgis.SpaceTimeRasterDataset(id) if not input_strds.is_in_db(): @@ -261,10 +257,7 @@ def main(): # The minimum threshold space time raster dataset minimum_strds = None if minimum: - if minimum.find("@") >= 0: - minimum_id = minimum - else: - minimum_id = minimum + "@" + mapset + minimum_id = minimum if minimum.find("@") >= 0 else minimum + "@" + mapset minimum_strds = tgis.SpaceTimeRasterDataset(minimum_id) if not minimum_strds.is_in_db(): @@ -282,10 +275,7 @@ def main(): # The maximum threshold space time raster dataset maximum_strds = None if maximum: - if maximum.find("@") >= 0: - maximum_id = maximum - else: - maximum_id = maximum + "@" + mapset + maximum_id = maximum if maximum.find("@") >= 0 else maximum + "@" + mapset maximum_strds = tgis.SpaceTimeRasterDataset(maximum_id) if not maximum_strds.is_in_db(): @@ -304,16 +294,10 @@ def main(): if input_strds.is_time_absolute(): start = tgis.string_to_datetime(start) - if stop: - stop = tgis.string_to_datetime(stop) - else: - stop = input_strds_end + stop = tgis.string_to_datetime(stop) if stop else input_strds_end else: start = int(start) - if stop: - stop = int(stop) - else: - stop = input_strds_end + stop = int(stop) if stop else input_strds_end if input_strds.is_time_absolute(): end = tgis.increment_datetime_by_string(start, cycle) @@ -341,7 +325,7 @@ def main(): if len(input_maps) == 0: continue - gs.message(_("Processing cycle %s - %s" % (str(start), str(end)))) + gs.message(_("Processing cycle %s - %s") % (str(start), str(end))) count = compute_occurrence( occurrence_maps, @@ -365,10 +349,7 @@ def main(): if indicator: num_maps = len(input_maps) for i in range(num_maps): - if reverse: - map = input_maps[num_maps - i - 1] - else: - map = input_maps[i] + map = input_maps[num_maps - i - 1] if reverse else input_maps[i] if ( input_strds.get_temporal_type() == "absolute" @@ -637,19 +618,13 @@ def compute_occurrence( # Aggregate num_maps = len(input_maps) for i in range(num_maps): - if reverse: - map = input_maps[num_maps - i - 1] - else: - map = input_maps[i] + map = input_maps[num_maps - i - 1] if reverse else input_maps[i] # Compute the days since start input_start, input_end = map.get_temporal_extent_as_tuple() td = input_start - start - if map.is_time_absolute(): - days = tgis.time_delta_to_relative_time(td) - else: - days = td + days = tgis.time_delta_to_relative_time(td) if map.is_time_absolute() else td if input_strds.get_temporal_type() == "absolute" and tsuffix == "gran": suffix = tgis.create_suffix_from_datetime( diff --git a/temporal/t.rast.accdetect/testsuite/test_simple.py b/temporal/t.rast.accdetect/testsuite/test_simple.py index 522c13f93e4..d67537487d5 100644 --- a/temporal/t.rast.accdetect/testsuite/test_simple.py +++ b/temporal/t.rast.accdetect/testsuite/test_simple.py @@ -62,8 +62,7 @@ def tearDownClass(cls): def tearDown(self): """Remove generated data""" - self.runModule("t.remove", flags="df", type="strds", inputs="B") - self.runModule("t.remove", flags="df", type="strds", inputs="C") + self.runModule("t.remove", flags="df", type="strds", inputs="B,C") def test_simple(self): self.assertModule( diff --git a/temporal/t.rast.accumulate/t.rast.accumulate.py b/temporal/t.rast.accumulate/t.rast.accumulate.py index 94344f2d9cc..d254d21c110 100644 --- a/temporal/t.rast.accumulate/t.rast.accumulate.py +++ b/temporal/t.rast.accumulate/t.rast.accumulate.py @@ -192,11 +192,7 @@ def main(): mapset = tgis.get_current_mapset() - if input.find("@") >= 0: - id = input - else: - id = input + "@" + mapset - + id = input if input.find("@") >= 0 else input + "@" + mapset input_strds = tgis.SpaceTimeRasterDataset(id) if not input_strds.is_in_db(): @@ -205,10 +201,7 @@ def main(): input_strds.select(dbif) - if output.find("@") >= 0: - out_id = output - else: - out_id = output + "@" + mapset + out_id = output if output.find("@") >= 0 else output + "@" + mapset # The output space time raster dataset output_strds = tgis.SpaceTimeRasterDataset(out_id) @@ -244,11 +237,7 @@ def main(): # The lower threshold space time raster dataset if lower: - - if lower.find("@") >= 0: - lower_id = lower - else: - lower_id = lower + "@" + mapset + lower_id = lower if lower.find("@") >= 0 else lower + "@" + mapset lower_strds = tgis.SpaceTimeRasterDataset(lower_id) if not lower_strds.is_in_db(): @@ -271,11 +260,7 @@ def main(): _("The upper option works only in conjunction with the lower option") ) - if upper.find("@") >= 0: - upper_id = upper - else: - upper_id = upper + "@" + mapset - + upper_id = upper if upper.find("@") >= 0 else upper + "@" + mapset upper_strds = tgis.SpaceTimeRasterDataset(upper_id) if not upper_strds.is_in_db(): dbif.close() @@ -293,17 +278,11 @@ def main(): if input_strds.is_time_absolute(): start = tgis.string_to_datetime(start) - if stop: - stop = tgis.string_to_datetime(stop) - else: - stop = input_strds_end + stop = tgis.string_to_datetime(stop) if stop else input_strds_end start = tgis.adjust_datetime_to_granularity(start, granularity) else: start = int(start) - if stop: - stop = int(stop) - else: - stop = input_strds_end + stop = int(stop) if stop else input_strds_end if input_strds.is_time_absolute(): end = tgis.increment_datetime_by_string(start, cycle) @@ -323,7 +302,7 @@ def main(): where = "start_time >= '%s' AND start_time < '%s'" % (str(start), str(end)) input_maps = input_strds.get_registered_maps_as_objects(where=where, dbif=dbif) - gs.message(_("Processing cycle %s - %s" % (str(start), str(end)))) + gs.message(_("Processing cycle %s - %s") % (str(start), str(end))) if len(input_maps) == 0: continue @@ -371,10 +350,7 @@ def main(): num_maps = len(gran_list) for i in range(num_maps): - if reverse: - map = gran_list[num_maps - i - 1] - else: - map = gran_list[i] + map = gran_list[num_maps - i - 1] if reverse else gran_list[i] # Select input maps based on temporal topology relations input_maps = [] if map.get_equal(): diff --git a/temporal/t.rast.accumulate/testsuite/test_accumulation.py b/temporal/t.rast.accumulate/testsuite/test_accumulation.py index f5bf6dcf5d7..6c277c320cf 100644 --- a/temporal/t.rast.accumulate/testsuite/test_accumulation.py +++ b/temporal/t.rast.accumulate/testsuite/test_accumulation.py @@ -12,7 +12,6 @@ import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestAccumulate(TestCase): @@ -95,9 +94,7 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): """Remove the temporary region""" - cls.runModule("t.remove", flags="df", type="strds", inputs="A") - cls.runModule("t.remove", flags="df", type="strds", inputs="Lower") - cls.runModule("t.remove", flags="df", type="strds", inputs="Upper") + cls.runModule("t.remove", flags="df", type="strds", inputs="A,Lower,Upper") cls.del_temp_region() def tearDown(self): diff --git a/temporal/t.rast.aggregate/t.rast.aggregate.py b/temporal/t.rast.aggregate/t.rast.aggregate.py index 609d6d19d38..0675407794a 100755 --- a/temporal/t.rast.aggregate/t.rast.aggregate.py +++ b/temporal/t.rast.aggregate/t.rast.aggregate.py @@ -218,10 +218,7 @@ def main(): dbif, gs.overwrite(), ) - if register_null: - register_null = False - else: - register_null = True + register_null = not register_null tgis.register_map_object_list( "rast", diff --git a/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute.py b/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute.py index 924e3950ca8..e7702ba23b5 100644 --- a/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute.py +++ b/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute.py @@ -10,7 +10,6 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py b/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py index 2b56dd30615..5ad25e2e32c 100644 --- a/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py +++ b/temporal/t.rast.aggregate/testsuite/test_aggregation_absolute_parallel.py @@ -11,7 +11,6 @@ import os from datetime import datetime -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py b/temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py index 244b0d519d5..dc1da4c1cc3 100644 --- a/temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py +++ b/temporal/t.rast.aggregate/testsuite/test_aggregation_relative.py @@ -10,7 +10,6 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.algebra/t.rast.algebra.html b/temporal/t.rast.algebra/t.rast.algebra.html index 126ed5df9c2..b7fda851224 100644 --- a/temporal/t.rast.algebra/t.rast.algebra.html +++ b/temporal/t.rast.algebra/t.rast.algebra.html @@ -608,10 +608,10 @@

    REFERENCES

    Related publications:
    • Gebbert, S., Pebesma, E. 2014. TGRASS: A temporal GIS for field based environmental modeling. - Environmental Modelling & Software 53, 1-12 (DOI) + Environmental Modelling & Software 53, 1-12 (DOI) - preprint PDF
    • Gebbert, S., Pebesma, E. 2017. The GRASS GIS temporal framework. International Journal of - Geographical Information Science 31, 1273-1292 (DOI)
    • + Geographical Information Science 31, 1273-1292 (DOI)
    • Gebbert, S., Leppelt, T., Pebesma, E., 2019. A topology based spatio-temporal map algebra for big data analysis. Data 4, 86. (DOI)
    diff --git a/temporal/t.rast.algebra/testsuite/test_raster_algebra_operators.py b/temporal/t.rast.algebra/testsuite/test_raster_algebra_operators.py index cf3d12a1aae..f07fabc9106 100644 --- a/temporal/t.rast.algebra/testsuite/test_raster_algebra_operators.py +++ b/temporal/t.rast.algebra/testsuite/test_raster_algebra_operators.py @@ -12,7 +12,6 @@ import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule from grass.gunittest.main import test diff --git a/temporal/t.rast.export/t.rast.export.py b/temporal/t.rast.export/t.rast.export.py index 675040bf5aa..fdf19541ee4 100755 --- a/temporal/t.rast.export/t.rast.export.py +++ b/temporal/t.rast.export/t.rast.export.py @@ -127,10 +127,10 @@ def main(): } if not directory or not os.path.exists(directory): - gs.fatal(_("Directory {} not found".format(directory))) + gs.fatal(_("Directory {} not found").format(directory)) if not os.access(directory, os.W_OK): - gs.fatal(_("Directory {} is not writable".format(directory))) + gs.fatal(_("Directory {} is not writable").format(directory)) if _type and _format in {"pack", "AAIGrid"}: gs.warning( diff --git a/temporal/t.rast.extract/testsuite/test_t_rast_extract.py b/temporal/t.rast.extract/testsuite/test_t_rast_extract.py index ca3c1a4c1db..b9fff4753c2 100644 --- a/temporal/t.rast.extract/testsuite/test_t_rast_extract.py +++ b/temporal/t.rast.extract/testsuite/test_t_rast_extract.py @@ -8,9 +8,6 @@ @author Soeren Gebbert """ -import subprocess - -import grass.pygrass.modules as pymod from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.gapfill/t.rast.gapfill.py b/temporal/t.rast.gapfill/t.rast.gapfill.py index e2ffb149513..84395da6295 100755 --- a/temporal/t.rast.gapfill/t.rast.gapfill.py +++ b/temporal/t.rast.gapfill/t.rast.gapfill.py @@ -208,8 +208,9 @@ def main(): gs.fatal( _( "Map with name <%s> already exists. " - "Please use another base name." % (_id) + "Please use another base name." ) + % (_id) ) elif new_map.is_in_db(dbif): overwrite_flags[new_id] = True diff --git a/temporal/t.rast.gapfill/testsuite/test_gapfill.py b/temporal/t.rast.gapfill/testsuite/test_gapfill.py index 63cd2b83c26..bfc8f48f581 100644 --- a/temporal/t.rast.gapfill/testsuite/test_gapfill.py +++ b/temporal/t.rast.gapfill/testsuite/test_gapfill.py @@ -8,10 +8,9 @@ @author Soeren Gebbert """ -import subprocess - from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows class TestRasterToVector(TestCase): @@ -75,6 +74,7 @@ def tearDown(self): """Remove generated data""" self.runModule("t.remove", flags="df", type="strds", inputs="A") + @xfail_windows def test_simple_2procs(self): self.assertModule( "t.rast.gapfill", @@ -125,6 +125,7 @@ def test_simple_2procs(self): self.assertModule(rast_list) self.assertLooksLike(text, rast_list.outputs.stdout) + @xfail_windows def test_simple_where(self): self.assertModule( "t.rast.gapfill", @@ -173,6 +174,7 @@ def test_simple_where(self): self.assertModule(rast_list) self.assertLooksLike(text, rast_list.outputs.stdout) + @xfail_windows def test_simple_where_2(self): self.assertModule( "t.rast.gapfill", @@ -216,6 +218,7 @@ def test_simple_where_2(self): self.assertModule(rast_list) self.assertLooksLike(text, rast_list.outputs.stdout) + @xfail_windows def test_simple_empty(self): self.assertModule( "t.rast.gapfill", @@ -302,6 +305,7 @@ def test_simple_gran(self): self.assertModule(rast_list) self.assertLooksLike(text, rast_list.outputs.stdout) + @xfail_windows def test_simple_gran(self): self.assertModule( "t.rast.gapfill", diff --git a/temporal/t.rast.list/t.rast.list.py b/temporal/t.rast.list/t.rast.list.py index 651bc69b956..0209d0aeee6 100755 --- a/temporal/t.rast.list/t.rast.list.py +++ b/temporal/t.rast.list/t.rast.list.py @@ -108,7 +108,13 @@ def message_option_value_excludes_option_value( return _( "Combining {option_name}={option_value} and " "{excluded_option_name}={excluded_option_value} is not allowed. {reason}" - ).format(**locals()) + ).format( + option_name=option_name, + option_value=option_value, + excluded_option_name=excluded_option_name, + excluded_option_value=excluded_option_value, + reason=reason, + ) def message_option_value_excludes_option( @@ -117,13 +123,23 @@ def message_option_value_excludes_option( return _( "The option {excluded_option_name} is not allowed with " "{option_name}={option_value}. {reason}" - ).format(**locals()) + ).format( + excluded_option_name=excluded_option_name, + option_name=option_name, + option_value=option_value, + reason=reason, + ) def message_option_value_excludes_flag(option_name, option_value, flag_name, reason): return _( "The flag -{flag_name} is not allowed with {option_name}={option_value}." - " {reason}".format(**locals()) + " {reason}" + ).format( + flag_name=flag_name, + option_name=option_name, + option_value=option_value, + reason=reason, ) diff --git a/temporal/t.rast.list/tests/t_rast_list_test.py b/temporal/t.rast.list/tests/t_rast_list_test.py index fbc092175db..86e539467cd 100644 --- a/temporal/t.rast.list/tests/t_rast_list_test.py +++ b/temporal/t.rast.list/tests/t_rast_list_test.py @@ -83,7 +83,7 @@ def test_yaml(space_time_raster_dataset): @pytest.mark.needs_solo_run @pytest.mark.parametrize( - "separator,delimiter", [(None, ","), (",", ","), (";", ";"), ("tab", "\t")] + ("separator", "delimiter"), [(None, ","), (",", ","), (";", ";"), ("tab", "\t")] ) def test_csv(space_time_raster_dataset, separator, delimiter): """Check CSV can be parsed with different separators""" diff --git a/temporal/t.rast.neighbors/testsuite/test_neighbors.py b/temporal/t.rast.neighbors/testsuite/test_neighbors.py index 414b009fb1d..b48df4df169 100644 --- a/temporal/t.rast.neighbors/testsuite/test_neighbors.py +++ b/temporal/t.rast.neighbors/testsuite/test_neighbors.py @@ -5,6 +5,7 @@ """ import os + import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.out.vtk/t.rast.out.vtk.py b/temporal/t.rast.out.vtk/t.rast.out.vtk.py index a042168499a..876770e4c4e 100755 --- a/temporal/t.rast.out.vtk/t.rast.out.vtk.py +++ b/temporal/t.rast.out.vtk/t.rast.out.vtk.py @@ -160,7 +160,7 @@ def main(): overwrite=gs.overwrite(), ) except CalledModuleError: - gs.fatal(_("Unable to export raster map <%s>" % map_name)) + gs.fatal(_("Unable to export raster map <%s>") % map_name) count += 1 diff --git a/temporal/t.rast.series/t.rast.series.py b/temporal/t.rast.series/t.rast.series.py index 074f35a00a0..57907f463e4 100755 --- a/temporal/t.rast.series/t.rast.series.py +++ b/temporal/t.rast.series/t.rast.series.py @@ -149,8 +149,8 @@ def main(): gs.warning( _( "Processing over {} maps: activating -z flag of r.series which " - "slows down processing.".format(max_files_open) - ) + "slows down processing." + ).format(max_files_open) ) flag += "z" if nulls: diff --git a/temporal/t.rast.series/testsuite/test_series.py b/temporal/t.rast.series/testsuite/test_series.py index cfb17a338cd..97df7c048fc 100644 --- a/temporal/t.rast.series/testsuite/test_series.py +++ b/temporal/t.rast.series/testsuite/test_series.py @@ -10,10 +10,10 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows class TestSnapAbsoluteSTRDS(TestCase): @@ -60,11 +60,15 @@ def tearDownClass(cls): type="raster", maps="series_average,series_maximum,series_minimum,series_minimum_2", ) - cls.runModule("g.remove", flags="f", type="raster", name="series_average") - cls.runModule("g.remove", flags="f", type="raster", name="series_maximum") - cls.runModule("g.remove", flags="f", type="raster", name="series_minimum") - cls.runModule("g.remove", flags="f", type="raster", name="series_minimum_2") - cls.runModule("g.remove", flags="f", type="raster", name="series_quantile") + cls.runModule( + "g.remove", + flags="f", + type="raster", + name=( + "series_average,series_maximum" + + ",series_minimum,series_minimum_2,series_quantile" + ), + ) def test_time_stamp(self): self.assertModule( @@ -146,6 +150,7 @@ def test_minimum_where(self): map="series_minimum_2", refmin=300, refmax=300, msg="Minimum must be 300" ) + @xfail_windows def test_quantile(self): self.assertModule( "t.rast.series", @@ -204,10 +209,12 @@ def tearDownClass(cls): type="raster", maps="series_average,series_maximum,series_minimum,series_minimum_2", ) - cls.runModule("g.remove", flags="f", type="raster", name="series_average") - cls.runModule("g.remove", flags="f", type="raster", name="series_maximum") - cls.runModule("g.remove", flags="f", type="raster", name="series_minimum") - cls.runModule("g.remove", flags="f", type="raster", name="series_minimum_2") + cls.runModule( + "g.remove", + flags="f", + type="raster", + name="series_average,series_maximum,series_minimum,series_minimum_2", + ) def test_average(self): self.assertModule( diff --git a/temporal/t.rast.to.rast3/t.rast.to.rast3.py b/temporal/t.rast.to.rast3/t.rast.to.rast3.py index e3bdd9567ad..118e19549c6 100755 --- a/temporal/t.rast.to.rast3/t.rast.to.rast3.py +++ b/temporal/t.rast.to.rast3/t.rast.to.rast3.py @@ -162,7 +162,7 @@ def main(): overwrite=gs.overwrite(), ) except CalledModuleError: - gs.fatal(_("Unable to create 3D raster map <%s>" % output)) + gs.fatal(_("Unable to create 3D raster map <%s>") % output) gs.run_command("g.remove", flags="f", type="raster", name=null_map) @@ -183,10 +183,7 @@ def main(): gs.warning(_("%s failed to set units.") % "r3.support") # Register the space time voxel cube in the temporal GIS - if output.find("@") >= 0: - id = output - else: - id = output + "@" + mapset + id = output if output.find("@") >= 0 else output + "@" + mapset start, end = sp.get_temporal_extent_as_tuple() r3ds = tgis.Raster3DDataset(id) diff --git a/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py b/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py index 3a6eb7d45cc..28853ecbff1 100644 --- a/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py +++ b/temporal/t.rast.to.rast3/testsuite/test_strds_to_rast3.py @@ -8,11 +8,7 @@ @author Soeren Gebbert """ -import subprocess - -import grass.pygrass.modules as pymod from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSTRDSToRast3(TestCase): diff --git a/temporal/t.rast.to.vect/testsuite/test_to_vect.py b/temporal/t.rast.to.vect/testsuite/test_to_vect.py index 2217b46a909..b429d8bf0dc 100644 --- a/temporal/t.rast.to.vect/testsuite/test_to_vect.py +++ b/temporal/t.rast.to.vect/testsuite/test_to_vect.py @@ -8,8 +8,6 @@ @author Soeren Gebbert """ -import subprocess - from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast.univar/testsuite/test_t_rast_univar.py b/temporal/t.rast.univar/testsuite/test_t_rast_univar.py index cfdfa78ab27..83e5c2d6229 100644 --- a/temporal/t.rast.univar/testsuite/test_t_rast_univar.py +++ b/temporal/t.rast.univar/testsuite/test_t_rast_univar.py @@ -8,8 +8,11 @@ @author Soeren Gebbert """ +from pathlib import Path + from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows class TestRasterUnivar(TestCase): @@ -145,12 +148,12 @@ def setUpClass(cls): @classmethod def tearDownClass(cls): """Remove the temporary region""" - cls.runModule("t.remove", flags="df", type="strds", inputs="A") - cls.runModule("t.remove", flags="df", type="strds", inputs="B") + cls.runModule("t.remove", flags="df", type="strds", inputs="A,B") cls.runModule("g.remove", flags="f", type="raster", name="zones") cls.del_temp_region() + @xfail_windows def test_with_all_maps(self): t_rast_univar = SimpleModule( "t.rast.univar", @@ -176,6 +179,7 @@ def test_with_all_maps(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_with_subset_of_maps(self): t_rast_univar = SimpleModule( "t.rast.univar", @@ -200,6 +204,7 @@ def test_with_subset_of_maps(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_coarser_resolution(self): t_rast_univar = SimpleModule( "t.rast.univar", @@ -243,7 +248,7 @@ def test_subset_with_output(self): a_3@testing||2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600 a_4@testing||2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600 """ - univar_output = open("univar_output.txt", "r").read() + univar_output = Path("univar_output.txt").read_text() for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")): if ref and res: @@ -269,7 +274,7 @@ def test_subset_with_extended_statistics_and_output(self): a_3@m2||2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600|300|300|300|300|300 a_4@m2||2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600|400|400|400|400|400 """ - univar_output = open("univar_output.txt", "r").read() + univar_output = Path("univar_output.txt").read_text() for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")): if ref and res: @@ -292,7 +297,7 @@ def test_subset_with_extended_statistics_and_output(self): a_3@testing||2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|2880000|0|9600|9600 a_4@testing||2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|3840000|0|9600|9600 """ - univar_output = open("univar_output.txt", "r").read() + univar_output = Path("univar_output.txt").read_text() for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")): if ref and res: @@ -315,6 +320,7 @@ def test_error_handling_no_input(self): # No input self.assertModuleFail("t.rast.univar", output="out.txt") + @xfail_windows def test_with_zones(self): """Test use of zones""" @@ -352,6 +358,7 @@ def test_with_zones(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_with_semantic_label(self): """Test semantic labels""" t_rast_univar = SimpleModule( @@ -378,6 +385,7 @@ def test_with_semantic_label(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_with_semantic_label_parallel(self): """Test semantic labels""" t_rast_univar = SimpleModule( @@ -405,6 +413,7 @@ def test_with_semantic_label_parallel(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_with_spatial_filter_intersects(self): """Test spatial filter overlaps""" t_rast_univar = SimpleModule( @@ -433,6 +442,7 @@ def test_with_spatial_filter_intersects(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_with_spatial_filter_contains(self): """Test spatial filter contains""" t_rast_univar = SimpleModule( @@ -459,6 +469,7 @@ def test_with_spatial_filter_contains(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_with_spatial_filter_is_contained(self): """Test spatial filter is_contained""" t_rast_univar = SimpleModule( diff --git a/temporal/t.rast.what/t.rast.what.py b/temporal/t.rast.what/t.rast.what.py index 9fa4ad5d793..24190a6a716 100755 --- a/temporal/t.rast.what/t.rast.what.py +++ b/temporal/t.rast.what/t.rast.what.py @@ -98,22 +98,6 @@ # % description: Use stdin as input and ignore coordinates and point option # %end -## Temporary disabled the r.what flags due to test issues -##%flag -##% key: f -##% description: Show the category labels of the grid cell(s) -##%end - -##%flag -##% key: r -##% description: Output color values as RRR:GGG:BBB -##%end - -##%flag -##% key: i -##% description: Output integer category values, not cell values -##%end - # %flag # % key: v # % description: Show the category for vector points map @@ -387,9 +371,9 @@ def one_point_per_row_output( for count in range(len(output_files)): file_name = output_files[count] - gs.verbose(_("Transforming r.what output file %s" % (file_name))) + gs.verbose(_("Transforming r.what output file %s") % (file_name)) map_list = output_time_list[count] - in_file = open(file_name, "r") + in_file = open(file_name) for line in in_file: line = line.split(separator) if vcat: @@ -410,10 +394,7 @@ def one_point_per_row_output( for i in range(len(values)): start, end = map_list[i].get_temporal_extent_as_tuple() - if vcat: - cat_str = "{ca}{sep}".format(ca=cat, sep=separator) - else: - cat_str = "" + cat_str = "{ca}{sep}".format(ca=cat, sep=separator) if vcat else "" if site_input: coor_string = ( "%(x)10.10f%(sep)s%(y)10.10f%(sep)s%(site_name)s%(sep)s" @@ -465,9 +446,8 @@ def one_point_per_col_output( first = True for count in range(len(output_files)): file_name = output_files[count] - gs.verbose(_("Transforming r.what output file %s" % (file_name))) - map_list = output_time_list[count] - in_file = open(file_name, "r") + gs.verbose(_("Transforming r.what output file %s") % (file_name)) + in_file = open(file_name) lines = in_file.readlines() matrix = [] @@ -481,10 +461,7 @@ def one_point_per_col_output( out_str = "start%(sep)send" % ({"sep": separator}) # Define different separator for coordinates and sites - if separator == ",": - coor_sep = ";" - else: - coor_sep = "," + coor_sep = ";" if separator == "," else "," for row in matrix: if vcat: @@ -518,10 +495,7 @@ def one_point_per_col_output( first = False - if vcat: - ncol = 4 - else: - ncol = 3 + ncol = 4 if vcat else 3 for col in range(num_cols - ncol): start, end = output_time_list[count][col].get_temporal_extent_as_tuple() time_string = "%(start)s%(sep)s%(end)s" % ( @@ -564,14 +538,11 @@ def one_point_per_timerow_output( file_name = output_files[count] gs.verbose("Transforming r.what output file %s" % (file_name)) map_list = output_time_list[count] - in_file = open(file_name, "r") + in_file = open(file_name) if write_header: if first is True: - if vcat: - header = "cat{sep}".format(sep=separator) - else: - header = "" + header = "cat{sep}".format(sep=separator) if vcat else "" if site_input: header += "x%(sep)sy%(sep)ssite" % ({"sep": separator}) else: @@ -608,7 +579,7 @@ def one_point_per_timerow_output( if write_header: out_file.write(header + "\n") - gs.verbose(_("Writing the output file <%s>" % (output))) + gs.verbose(_("Writing the output file <%s>") % (output)) for row in matrix: first = True for col in row: @@ -664,15 +635,13 @@ def process_loop( output_time_list.append(map_list) gs.verbose( - _( - "Process maps %(samp_start)i to %(samp_end)i (of %(total)i)" - % ( - { - "samp_start": count - len(map_names) + 1, - "samp_end": count, - "total": len(maps), - } - ) + _("Process maps %(samp_start)i to %(samp_end)i (of %(total)i)") + % ( + { + "samp_start": count - len(map_names) + 1, + "samp_end": count, + "total": len(maps), + } ) ) mod = copy.deepcopy(r_what) diff --git a/temporal/t.rast.what/testsuite/test_what.py b/temporal/t.rast.what/testsuite/test_what.py index 96432eff4e1..18c7af63807 100644 --- a/temporal/t.rast.what/testsuite/test_what.py +++ b/temporal/t.rast.what/testsuite/test_what.py @@ -10,6 +10,7 @@ from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows class TestRasterWhat(TestCase): @@ -218,6 +219,7 @@ def test_timerow_output_coords(self): "out_timerow_coords.txt", "ca4ee0e7e4aaca170d6034e0d57d292d", text=True ) + @xfail_windows def test_row_stdout_where_parallel(self): t_rast_what = SimpleModule( "t.rast.what", @@ -245,6 +247,7 @@ def test_row_stdout_where_parallel(self): """ self.assertLooksLike(text, str(t_rast_what.outputs.stdout)) + @xfail_windows def test_row_stdout_where_parallel_cat(self): t_rast_what = SimpleModule( "t.rast.what", @@ -272,6 +275,7 @@ def test_row_stdout_where_parallel_cat(self): """ self.assertLooksLike(text, str(t_rast_what.outputs.stdout)) + @xfail_windows def test_row_stdout_where_parallel2(self): """Here without output definition, the default is used then""" @@ -385,6 +389,7 @@ def tearDownClass(cls): cls.runModule("t.remove", flags="df", type="strds", inputs="A") cls.del_temp_region() + @xfail_windows def test_null_value(self): """Test setting the null value""" diff --git a/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py b/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py index 4f0d476e0e8..3ae010e8423 100644 --- a/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py +++ b/temporal/t.rast3d.extract/testsuite/test_t_rast3d_extract.py @@ -8,9 +8,6 @@ :authors: Soeren Gebbert """ -import subprocess - -import grass.pygrass.modules as pymod from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py b/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py index d34c1f253aa..21980921168 100644 --- a/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py +++ b/temporal/t.rast3d.univar/testsuite/test_t_rast3d_univar.py @@ -8,8 +8,11 @@ @author Soeren Gebbert """ +from pathlib import Path + from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows class TestRasterUnivar(TestCase): @@ -57,6 +60,7 @@ def tearDownClass(cls): cls.runModule("g.remove", flags="f", type="raster_3d", name="zones") cls.del_temp_region() + @xfail_windows def test_with_all_maps(self): t_rast3d_univar = SimpleModule( "t.rast3d.univar", @@ -81,6 +85,7 @@ def test_with_all_maps(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_with_subset_of_maps(self): t_rast3d_univar = SimpleModule( "t.rast3d.univar", @@ -119,7 +124,7 @@ def test_subset_with_output(self): a_3@testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000 a_4@testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000 """ - univar_output = open("univar_output.txt", "r").read() + univar_output = Path("univar_output.txt").read_text() for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")): if ref and res: @@ -142,7 +147,7 @@ def test_subset_with_output_no_header(self): a_3@testing|2001-07-01 00:00:00|2001-10-01 00:00:00|300|300|300|300|0|0|0|144000000|0|480000|480000 a_4@testing|2001-10-01 00:00:00|2002-01-01 00:00:00|400|400|400|400|0|0|0|192000000|0|480000|480000 """ - univar_output = open("univar_output.txt", "r").read() + univar_output = Path("univar_output.txt").read_text() for ref, res in zip(univar_text.split("\n"), univar_output.split("\n")): if ref and res: @@ -165,6 +170,7 @@ def test_error_handling_no_input(self): # No input self.assertModuleFail("t.rast3d.univar", output="out.txt") + @xfail_windows def test_with_zones(self): """Test use of zones""" @@ -202,6 +208,7 @@ def test_with_zones(self): res_line = res.split("|", 1)[1] self.assertLooksLike(ref_line, res_line) + @xfail_windows def test_with_zones_parallel(self): """Test use of zones""" diff --git a/temporal/t.remove/t.remove.py b/temporal/t.remove/t.remove.py index fd32f8972d5..91fa58dde7a 100755 --- a/temporal/t.remove/t.remove.py +++ b/temporal/t.remove/t.remove.py @@ -102,7 +102,7 @@ def main(): # Read the dataset list from file if file: - fd = open(file, "r") + fd = open(file) line = True while True: @@ -127,22 +127,25 @@ def main(): sp = tgis.open_old_stds(name, type, dbif) if not force: gs.message( - _("{stds}: {gid}".format(stds=sp.get_type().upper(), gid=sp.get_id())) + _("{stds}: {gid}").format(stds=sp.get_type().upper(), gid=sp.get_id()) ) if recursive or clean: if not force: if recursive: - msg = ( + msg = _( "The following maps of {stds} {gid} will be " "unregistered from temporal database:" ) elif clean: - msg = ( + msg = _( "The following maps of {stds} {gid} will be " "unregistered from temporal database and removed " "from spatial database:" ) - gs.message(_(msg.format(stds=sp.get_type(), gid=sp.get_id()))) + + if recursive or clean: + gs.message(msg.format(stds=sp.get_type(), gid=sp.get_id())) + maps = sp.get_registered_maps_as_objects(dbif=dbif) map_statement = "" count = 1 @@ -150,10 +153,10 @@ def main(): for map in maps: map.select(dbif) # We may have multiple layer for a single map, hence we need - # to avoid multiple deletation of the same map, + # to avoid multiple deletions of the same map, # but the database entries are still present and must be removed if not force: - gs.message(_("- %s" % map.get_name())) + gs.message(_("- %s") % map.get_name()) continue if clean and force: if map.get_name() not in name_list: @@ -190,8 +193,8 @@ def main(): gs.message( _( "Nothing removed. You must use the force flag (-{flag}) to actually " - "remove them.".format(flag="f") - ) + "remove them." + ).format(flag="f") ) else: # Execute the collected SQL statenents diff --git a/temporal/t.rename/t.rename.py b/temporal/t.rename/t.rename.py index a6aee79b790..a1f1a164fee 100755 --- a/temporal/t.rename/t.rename.py +++ b/temporal/t.rename/t.rename.py @@ -59,15 +59,8 @@ def main(): # Get the current mapset to create the id of the space time dataset mapset = gs.gisenv()["MAPSET"] - if input.find("@") >= 0: - old_id = input - else: - old_id = input + "@" + mapset - - if output.find("@") >= 0: - new_id = output - else: - new_id = output + "@" + mapset + old_id = input if input.find("@") >= 0 else input + "@" + mapset + new_id = output if output.find("@") >= 0 else output + "@" + mapset # Do not overwrite yourself if new_id == old_id: diff --git a/temporal/t.shift/testsuite/test_shift.py b/temporal/t.shift/testsuite/test_shift.py index ea28e165995..3d55b059b4c 100644 --- a/temporal/t.shift/testsuite/test_shift.py +++ b/temporal/t.shift/testsuite/test_shift.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestShiftAbsoluteSTRDS(TestCase): diff --git a/temporal/t.snap/testsuite/test_snap.py b/temporal/t.snap/testsuite/test_snap.py index 36a71c420bf..e46e25c454d 100644 --- a/temporal/t.snap/testsuite/test_snap.py +++ b/temporal/t.snap/testsuite/test_snap.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSnapAbsoluteSTRDS(TestCase): diff --git a/temporal/t.support/testsuite/test_support_str3ds.py b/temporal/t.support/testsuite/test_support_str3ds.py index 928826dbd72..533a9649692 100644 --- a/temporal/t.support/testsuite/test_support_str3ds.py +++ b/temporal/t.support/testsuite/test_support_str3ds.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSupportAbsoluteSTR3DS(TestCase): diff --git a/temporal/t.support/testsuite/test_support_strds.py b/temporal/t.support/testsuite/test_support_strds.py index f5e9ac3aa29..397a4a5e88d 100644 --- a/temporal/t.support/testsuite/test_support_strds.py +++ b/temporal/t.support/testsuite/test_support_strds.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSupportAbsoluteSTRDS(TestCase): diff --git a/temporal/t.support/testsuite/test_support_stvds.py b/temporal/t.support/testsuite/test_support_stvds.py index 2b6e347dead..b7ecc1aee01 100644 --- a/temporal/t.support/testsuite/test_support_stvds.py +++ b/temporal/t.support/testsuite/test_support_stvds.py @@ -10,10 +10,8 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestSupportAbsoluteSTVDS(TestCase): diff --git a/temporal/t.topology/t.topology.py b/temporal/t.topology/t.topology.py index 4356596f319..e9da9b369a7 100755 --- a/temporal/t.topology/t.topology.py +++ b/temporal/t.topology/t.topology.py @@ -74,10 +74,7 @@ def main(): spatial = None if spatio_temporal_relations: - if sp.get_type() == "strds": - spatial = "2D" - else: - spatial = "3D" + spatial = "2D" if sp.get_type() == "strds" else "3D" if temporal_relations or spatio_temporal_relations: sp.print_spatio_temporal_relationships(maps=maps, spatial=spatial) diff --git a/temporal/t.topology/test.t.topology.reltime.sh b/temporal/t.topology/test.t.topology.reltime.sh index 847289c4b2f..60e49355e9a 100755 --- a/temporal/t.topology/test.t.topology.reltime.sh +++ b/temporal/t.topology/test.t.topology.reltime.sh @@ -96,6 +96,5 @@ cat "${n5}" t.topology input=precip_rel_y t.topology -m input=precip_rel_y -t.remove type=strds input=precip_rel_d -t.remove type=strds input=precip_rel_y +t.remove type=strds input=precip_rel_d,precip_rel_y t.unregister type=raster file="${n1}" diff --git a/temporal/t.unregister/t.unregister.py b/temporal/t.unregister/t.unregister.py index e7e234320c0..cacfe579a7b 100755 --- a/temporal/t.unregister/t.unregister.py +++ b/temporal/t.unregister/t.unregister.py @@ -93,12 +93,7 @@ def main(): # Map names as comma separated string if maps is not None and maps != "": - if maps.find(",") == -1: - maplist = [ - maps, - ] - else: - maplist = maps.split(",") + maplist = [maps] if maps.find(",") == -1 else maps.split(",") # Build the maplist for count in range(len(maplist)): @@ -108,7 +103,7 @@ def main(): # Read the map list from file if file: - fd = open(file, "r") + fd = open(file) line = True while True: @@ -154,10 +149,8 @@ def main(): statement += map.delete(dbif=dbif, update=False, execute=False) else: gs.warning( - _( - "Unable to find %s map <%s> in temporal database" - % (map.get_type(), map.get_id()) - ) + _("Unable to find %s map <%s> in temporal database") + % (map.get_type(), map.get_id()) ) count += 1 @@ -170,7 +163,7 @@ def main(): # Update space time datasets if input: - gs.message(_("Unregister maps from space time dataset <%s>" % (input))) + gs.message(_("Unregister maps from space time dataset <%s>") % (input)) else: gs.message(_("Unregister maps from the temporal database")) diff --git a/temporal/t.unregister/testsuite/test_unregister.py b/temporal/t.unregister/testsuite/test_unregister.py index a32d33c1f32..b0102095e3d 100644 --- a/temporal/t.unregister/testsuite/test_unregister.py +++ b/temporal/t.unregister/testsuite/test_unregister.py @@ -10,7 +10,6 @@ import os -import grass.pygrass.modules as pymod import grass.temporal as tgis from grass.gunittest.case import TestCase from grass.gunittest.gmodules import SimpleModule diff --git a/temporal/t.vect.algebra/t.vect.algebra.py b/temporal/t.vect.algebra/t.vect.algebra.py index 5da83398404..852df8c3afe 100644 --- a/temporal/t.vect.algebra/t.vect.algebra.py +++ b/temporal/t.vect.algebra/t.vect.algebra.py @@ -64,7 +64,6 @@ def main(): expression = options["expression"] basename = options["basename"] spatial = flags["s"] - stdstype = "stvds" # Check for PLY istallation try: diff --git a/temporal/t.vect.extract/test.t.vect.extract.sh b/temporal/t.vect.extract/test.t.vect.extract.sh index b5cd6882e94..8b176dcc8ed 100755 --- a/temporal/t.vect.extract/test.t.vect.extract.sh +++ b/temporal/t.vect.extract/test.t.vect.extract.sh @@ -44,5 +44,4 @@ t.vect.list input=soil_abs3 columns=name,start_time,end_time,primitives # @postprocess t.unregister type=vector maps=soil_1,soil_2,soil_3,soil_4,soil_5,soil_6,soil_7,soil_8 t.remove type=stvds input=soil_abs1,soil_abs2,soil_abs3 -g.remove -f type=vector name=soil_1,soil_2,soil_3,soil_4,soil_5,soil_6,soil_7,soil_8 -g.remove -f type=vector name=new_vect_1,new_vect_2,new_vect_3,new_vect_4,new_vect_5,new_vect_6 +g.remove -f type=vector name=soil_1,soil_2,soil_3,soil_4,soil_5,soil_6,soil_7,soil_8,new_vect_1,new_vect_2,new_vect_3,new_vect_4,new_vect_5,new_vect_6 diff --git a/temporal/t.vect.observe.strds/t.vect.observe.strds.py b/temporal/t.vect.observe.strds/t.vect.observe.strds.py index 8b3850fb2ef..7e9ac225890 100755 --- a/temporal/t.vect.observe.strds/t.vect.observe.strds.py +++ b/temporal/t.vect.observe.strds/t.vect.observe.strds.py @@ -152,13 +152,13 @@ def main(): "Temporal type of space time raster datasets must be equal\n" "<%(a)s> of type %(type_a)s do not match <%(b)s> of type " "%(type_b)s" - % { - "a": first_strds.get_id(), - "type_a": first_strds.get_temporal_type(), - "b": dataset.get_id(), - "type_b": dataset.get_temporal_type(), - } ) + % { + "a": first_strds.get_id(), + "type_a": first_strds.get_temporal_type(), + "b": dataset.get_id(), + "type_b": dataset.get_temporal_type(), + } ) mapmatrizes = tgis.sample_stds_by_stds_topology( @@ -185,8 +185,7 @@ def main(): if name is None: isvalid = False break - else: - mapname_list.append(name) + mapname_list.append(name) if isvalid: entry = mapmatrizes[0][i] @@ -202,11 +201,8 @@ def main(): vector_db = gs.vector.vector_db(input) # We copy the vector table and create the new layers - if vector_db: - # Use the first layer to copy the categories from - layers = "1," - else: - layers = "" + # If vector_db, use the first layer to copy the categories from + layers = "1," if vector_db else "" first = True for layer in range(num_samples): layer += 1 diff --git a/temporal/t.vect.what.strds/t.vect.what.strds.py b/temporal/t.vect.what.strds/t.vect.what.strds.py index 6ea36e79579..b1f2c17a9c6 100755 --- a/temporal/t.vect.what.strds/t.vect.what.strds.py +++ b/temporal/t.vect.what.strds/t.vect.what.strds.py @@ -158,12 +158,9 @@ def main(): raster_maps = (new_map.get_id(),) for rastermap in raster_maps: - if column: - col_name = column - else: - # Create a new column with the SQL compliant - # name of the sampled raster map - col_name = rastermap.split("@")[0].replace(".", "_") + # Create a new column with the SQL compliant + # name of the sampled raster map if not column + col_name = column or rastermap.split("@")[0].replace(".", "_") coltype = "DOUBLE PRECISION" # Get raster type diff --git a/temporal/temporalintro.html b/temporal/temporalintro.html index c5eca6ead2c..2780efd8c85 100644 --- a/temporal/temporalintro.html +++ b/temporal/temporalintro.html @@ -262,11 +262,11 @@

    See also

    • Gebbert, S., Pebesma, E. 2014. TGRASS: A temporal GIS for field based environmental modeling. - Environmental Modelling & Software 53, 1-12 (DOI) + Environmental Modelling & Software 53, 1-12 (DOI) - preprint PDF
    • Gebbert, S., Pebesma, E. 2017. The GRASS GIS temporal framework. International Journal of - Geographical Information Science 31, 1273-1292 (DOI)
    • + Geographical Information Science 31, 1273-1292 (DOI)
    • Gebbert, S., Leppelt, T., Pebesma, E., 2019. A topology based spatio-temporal map algebra for big data analysis. Data 4, 86. (DOI)
    • diff --git a/testsuite/Makefile b/testsuite/Makefile deleted file mode 100644 index 7ed92b67442..00000000000 --- a/testsuite/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -MODULE_TOPDIR = .. - -SUBDIRS = \ - raster - -include $(MODULE_TOPDIR)/include/Make/Dir.make - -default: parsubdirs diff --git a/testsuite/README.md b/testsuite/README.md index 491fa4597af..36dda7d3da2 100644 --- a/testsuite/README.md +++ b/testsuite/README.md @@ -1,29 +1,39 @@ # Test suite -This directory contains scripts to check some functionality of GRASS GIS. +Tests are in directories `tests` and `testsuite` under each directory which has tests. +This directory contains additional scripts and information to test functionality +without a focus on a specific part of the code. -GRASS GIS testsuite documentation: +There are two testing mechanism in place, _pytest_ which is the modern way of testing +GRASS GIS. Tests using _pytest_ are written just as any other Python tests. -## Simple test data +In parallel, there is also custom unittest-based framework centered around +_grass.gunittest_ package. These tests run in the NC sample datasets and can be +executed using _pytest_ or directly. The unittest-based adds a number of custom +assert methods to accommodate different data and outputs typical in GRASS GIS. +_grass.gunittest_ documentation: + -Some tests may be launched in the location `../demolocation/`: +## Running tests + +Tests can be executed using _pytest_: ```bash -# create new mapset for test -grass ../demolocation/user1 -c -# run the test -make +# Setup the Python environment (if not set up already). +# Replace grass by path to the executable if not installed on path. +export PYTHONPATH=\$(grass --config python_path):\$PYTHONPATH +export LD_LIBRARY_PATH=\$(grass --config path)/lib:\$LD_LIBRARY_PATH +# Run the test. +pytest ``` -## Extended test data - -Most tests require the North Carolina Sample dataset, available from - +## Test data -## Notes +To test manually or to write tests, you may need to use the North Carolina +Sample dataset, available from +. -Since 2020: For a more advanced test suite, see - +## CI -Until 2019: For a more advanced test suite, see - +Most tests run in the CI. See the `.github` directory for details and +use it as a reference. diff --git a/testsuite/examples/test_framework_GRASS_GIS_with_NC.conf b/testsuite/examples/test_framework_GRASS_GIS_with_NC.conf deleted file mode 100644 index 6256108f6a8..00000000000 --- a/testsuite/examples/test_framework_GRASS_GIS_with_NC.conf +++ /dev/null @@ -1,29 +0,0 @@ -### CONFIGURATION -# -# name of binary: -GRASSBIN=grass -# source code directory as full path: -GRASSSRC="$(realpath ../../)" -# temporary grassdata directory -GRASSDATA="$HOME/grassdata" - -# leave 1 or more CPU free for other usage than testing -FREECPU=1 - -# Python binary to be used (python|python3) -PYTHON=python - -# here we suppose default compilation settings of GRASS GIS and no 'make install' -# may be no|yes -COMPILE="no" -# configure metascript with compiler flags: -CONFIGURE="${GRASSSRC}/conf_grass8.sh" - -# directory to store reports, e.g. in a subdirectory -REPORTS="testreports" - -# publish report on WWW Server (not needed for local tests) -# may be no|yes -PUBLISH="no" -# upload WWW dir on server for report publication (not used for local tests) -SERVERDIR="/var/www/html/grassgistestreports" diff --git a/testsuite/examples/test_framework_GRASS_GIS_with_NC.sh b/testsuite/examples/test_framework_GRASS_GIS_with_NC.sh deleted file mode 100755 index 808b4b9c716..00000000000 --- a/testsuite/examples/test_framework_GRASS_GIS_with_NC.sh +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/bash -############################################################################ -# -# MODULE: Example script to run testsuite -# AUTHOR(S): Markus Neteler, Sören Gebbert, Vaclav Petras -# PURPOSE: Test GRASS GIS using the test framework -# Documentation: -# https://trac.osgeo.org/grass/wiki/GSoC/2014/TestingFrameworkForGRASS -# https://grass.osgeo.org/grass-devel/manuals/libpython/gunittest_running_tests.html#example-bash-script-to-run-be-used-as-a-cron-job -# -# Data: -# We use the full NC dataset (nc_spm_full_v2_alpha.tar.gz) -# -# COPYRIGHT: (C) 2019-2021 by Markus Neteler, and the GRASS Development Team -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -############################################################################ - -### Fetch CONFIGURATION - -CONF="test_framework_GRASS_GIS_with_NC.conf" - -usage_msg(){ -echo "Usage: - $0 [conf_file] - -Example: - $0 ./${CONF} -" -} - -if [ ! -z "$1" ] ; then - case "$1" in - -h | --h | -help | --help) - usage_msg - exit 0 - ;; - *) - if [ -f ${1} ] ; then - CONF="$1" - else - echo "ERROR: $1 is not a file" - exit 1 - fi - ;; - esac -else - usage_msg - exit 0 -fi - -source ${CONF} - -######### nothing to change below - -set -e # fail fast - -# computer architecture: -ARCH=`${GRASSBIN} --config arch` - -# here we suppose default compilation settings of GRASS GIS and no make install -GRASSBIN="$GRASSSRC/bin.${ARCH}/${GRASSBIN}" -GRASSDIST="$GRASSSRC/dist.${ARCH}" - -# necessary hardcoded GRASS paths -GRASSDIST_PYTHON="$GRASSDIST/etc/python" -GRASS_MULTI_RUNNER="$GRASSSRC/python/grass/gunittest/multirunner.py" -GRASS_MULTI_REPORTER="$GRASSSRC/python/grass/gunittest/multireport.py" - -DATE_FLAGS="--utc +%Y-%m-%d-%H-%M" -NOW=$(date $DATE_FLAGS) - -# get number of processors of current machine -MYNPROC=`getconf _NPROCESSORS_ONLN` -# leave some free for other tasks -GCCTHREADS=`expr $MYNPROC - $FREECPU` -if [ $GCCTHREADS -lt 1 ] ; then - GCCTHREADS=1 -fi - -# contains last executed command stdout and stderr -# here were rely on reports being absolute -OUTPUT_LOGFILE="$REPORTS/output-$NOW.txt" - -# these are relative to REPORTS -CURRENT_REPORT_BASENAME="reports_for_date-" -FINAL_REPORT_DIR="summary_report" -CURRENT_REPORTS_DIR="$CURRENT_REPORT_BASENAME$NOW" -LOGFILE="$REPORTS/runs.log" - -mkdir -p $REPORTS/$CURRENT_REPORTS_DIR -mkdir -p $GRASSDATA - -# fetch sample data -SAMPLEDATA=nc_spm_full_v2alpha -(cd $GRASSDATA ; wget -c https://grass.osgeo.org/sampledata/north_carolina/$SAMPLEDATA.tar.gz ; tar xfz $SAMPLEDATA.tar.gz --strip-components 2) - -set -x - -echo "Testing of GRASS GIS started: $NOW" >> ${LOGFILE} - -if [ "$COMPILE" = "yes" ] ; then - ## compile current source code from scratch - cd $GRASSSRC - make distclean -j$GCCTHREADS - git pull - ./$CONFIGURE ... # configure meta script containing all the compiler flags - make -j$GCCTHREADS -fi - -# run tests for the current source code -cd $REPORTS/$CURRENT_REPORTS_DIR -$PYTHON $GRASS_MULTI_RUNNER \ - --grassbin $GRASSBIN \ - --grasssrc $GRASSSRC \ - --grassdata $GRASSDATA \ - --location $SAMPLEDATA --location-type nc # \ -# --location other_location --location-type other_type - -# create overall report of all so far executed tests -# the script depends on GRASS but just Python part is enough -export PYTHONPATH="$GRASSDIST_PYTHON:$PYTHONPATH" -$PYTHON $GRASS_MULTI_REPORTER --output $FINAL_REPORT_DIR \ - $CURRENT_REPORT_BASENAME*/* - -# publish on Web site -if [ "$PUBLISH" = "yes" ] ; then - ## although we cannot be sure the tests were executed was successfully - ## so publish or archive results - rsync -rtvu --delete $REPORTS/ $SERVERDIR -fi - -echo "Nightly ($NOW) GRASS GIS test finished: $(date $DATE_FLAGS)" >> ${LOGFILE} - -exit 0 diff --git a/testsuite/raster/Makefile b/testsuite/raster/Makefile deleted file mode 100644 index 21c1f8eb6c0..00000000000 --- a/testsuite/raster/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -all: - ./raster_md5test.sh - ./rmapcalc_test.sh diff --git a/testsuite/raster/README b/testsuite/raster/README deleted file mode 100644 index bc5b0940789..00000000000 --- a/testsuite/raster/README +++ /dev/null @@ -1 +0,0 @@ -Raster map tests go here diff --git a/testsuite/raster/rhemisphere.sh b/testsuite/raster/rhemisphere.sh deleted file mode 100755 index e312f7b36d1..00000000000 --- a/testsuite/raster/rhemisphere.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh - -# Markus Neteler, 2006 -# This program is free software under the GNU General Public -# License (>=v2). Read the file COPYING that comes with GRASS -# for details. -# Test cases for 2D raster data -# generate a hemisphere to test slope, aspect, curvatures - -# some definitions: -BOXLENGTH=1000 # side length of test area -RADIUS=500 # half BOXLENGTH - -############ - -if [ -z "$GISBASE" ] ; then - echo "You must be in GRASS GIS to run this program." >&2 - exit 1 -fi - -# some functions - keep order here -TMP="disk.$$" - -cleanup() -{ - echo "Removing temporary map" - g.remove --q -f type=raster name=$TMP > /dev/null -} - -######################## - -g.region n=$BOXLENGTH s=0 w=0 e=$BOXLENGTH -p res=1 - -X="(col() - $RADIUS)" -Y="($RADIUS - row())" -r="sqrt($X^2 + $Y^2)" - -#Mask out unwanted parts (check for <= ??): -r.mapcalc "$TMP = if($r<$RADIUS,$r,null())" - -ALPHA="acos ($TMP/$RADIUS)" -HEIGHT="$RADIUS * sin($ALPHA)" - - -r.mapcalc "hemisphere = $HEIGHT" -cleanup -g.message "Generated raster map " -#echo "Now generate aspect + slope on " diff --git a/testsuite/raster/raster_md5test.sh b/testsuite/raster_md5test.sh similarity index 67% rename from testsuite/raster/raster_md5test.sh rename to testsuite/raster_md5test.sh index 0bda0c3428c..b3281d4c505 100755 --- a/testsuite/raster/raster_md5test.sh +++ b/testsuite/raster_md5test.sh @@ -14,19 +14,23 @@ if [ -z "$GISBASE" ] ; then fi #### check if we have sed -if [ ! -x "`which sed`" ] ; then +if [ ! -x "$(which sed)" ] ; then echo "$PROG: sed required, please install first" 1>&2 exit 1 fi -#### check if we have md5sum -if [ ! -x "`which md5sum`" ] ; then - echo "$PROG: md5sum required, please install first" 1>&2 - exit 1 +#### check if we have md5sum or md5 +if [ -x "$(which md5sum)" ] ; then + MD5="md5sum | cut -d' ' -f1" +elif [ -x "$(which md5)" ] ; then + MD5="md5 -q" +else + echo "$PROG: md5sum or md5 required, please install first" 1>&2 + exit 1 fi #### check if we have cut -if [ ! -x "`which cut`" ] ; then +if [ ! -x "$(which cut)" ] ; then echo "$PROG: cut required, please install first" 1>&2 exit 1 fi @@ -38,47 +42,47 @@ export LC_NUMERIC=C # enforce ZLIB export GRASS_COMPRESSOR=ZLIB -eval `g.gisenv` -: ${GISBASE?} ${GISDBASE?} ${LOCATION_NAME?} ${MAPSET?} +eval "$(g.gisenv)" +: "${GISBASE?}" "${GISDBASE?}" "${LOCATION_NAME?}" "${MAPSET?}" MAPSET_PATH=$GISDBASE/$LOCATION_NAME/$MAPSET # some definitions PIXEL=3 PID=$$ -TMPNAME="`echo ${PID}_tmp_testmap | sed 's+\.+_+g'`" +TMPNAME=$(echo ${PID}_tmp_testmap | sed 's+\.+_+g') # some functions - keep order here cleanup() { echo "Removing temporary map" - g.remove -f type=raster name=$TMPNAME > /dev/null + g.remove -f type=raster name="$TMPNAME" > /dev/null } # check if a MASK is already present: -MASKTMP=mask.$TMPNAME -USERMASK=usermask_${MASKTMP} -if test -f $MAPSET_PATH/cell/MASK +MASKTMP="mask.${TMPNAME}" +USERMASK="usermask_${MASKTMP}" +if test -f "${MAPSET_PATH}/cell/MASK" then echo "A user raster mask (MASK) is present. Saving it..." - g.rename raster=MASK,$USERMASK > /dev/null + g.rename raster=MASK,"$USERMASK" > /dev/null fi finalcleanup() { echo "Restoring user region" - g.region region=$TMPNAME - g.remove -f type=region name=$TMPNAME > /dev/null + g.region region="$TMPNAME" + g.remove -f type=region name="$TMPNAME" > /dev/null #restore user mask if present: - if test -f $MAPSET_PATH/cell/$USERMASK ; then + if test -f "${MAPSET_PATH}/cell/${USERMASK}" ; then echo "Restoring user MASK" g.remove -f type=raster name=MASK > /dev/null - g.rename raster=$USERMASK,MASK > /dev/null + g.rename raster="$USERMASK",MASK > /dev/null fi } check_exit_status() { - if [ $1 -ne 0 ] ; then + if [ "$1" -ne 0 ] ; then echo "An error occurred." cleanup ; finalcleanup exit 1 @@ -106,7 +110,7 @@ check_md5sum() } echo "Saving current & setting test region." -g.region save=$TMPNAME +g.region save="$TMPNAME" check_exit_status $? g.region s=0 n=$PIXEL w=0 e=$PIXEL res=1 tbres=1 check_exit_status $? @@ -118,8 +122,8 @@ r.mapcalc "$TMPNAME = 1" check_exit_status $? echo "MD5 checksum on output of INT/CELL test." -MD5="`r.out.ascii $TMPNAME precision=15 | md5sum | cut -d' ' -f1`" -check_md5sum "549e7dabe70df893803690571d2e1503" "$MD5" +SUM=$(r.out.ascii "$TMPNAME" precision=15 | eval "$MD5") +check_md5sum "549e7dabe70df893803690571d2e1503" "$SUM" cleanup echo "INT/CELL md5sum test successful" @@ -132,8 +136,8 @@ r.mapcalc "$TMPNAME = $VALUE" check_exit_status $? echo "MD5 checksum on output of FLOAT/FCELL test." -MD5="`r.out.ascii $TMPNAME precision=15 | md5sum | cut -d' ' -f1`" -check_md5sum "379f3d880b6d509051af6b4ccf470762" "$MD5" +SUM=$(r.out.ascii "$TMPNAME" precision=15 | eval "$MD5") +check_md5sum "379f3d880b6d509051af6b4ccf470762" "$SUM" cleanup echo "FLOAT/FCELL md5sum test successful" diff --git a/testsuite/vector/v.in.gps_test.sh b/testsuite/vector/v.in.gps_test.sh deleted file mode 100755 index 62b2f5b651c..00000000000 --- a/testsuite/vector/v.in.gps_test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# v.in.garmin and v.in.gpsbabel test script -# by Hamish Bowman 18 May 2007 ; public domain -# assumes downloading from a garmin on port /dev/gps - -for PGM in garmin gpsbabel ; do - for DO_PTS in pts lines ; do - for TASK in w t r ; do - if [ $TASK = w ] && [ $DO_PTS = "lines" ] ; then - continue - fi - if [ $DO_PTS = "pts" ] ; then - PTFLAG="-p" - else - PTFLAG="" - fi - MAPNAME="test_${PGM}_${TASK}_${DO_PTS}_$$" - echo "-- Running [v.in.$PGM] for [$TASK] download as [$DO_PTS] into <$MAPNAME> --" - v.in.$PGM -$TASK $PTFLAG out="$MAPNAME" - if [ $? -ne 0 ] ; then - exit 1 - fi - awk 'BEGIN {printf("\n\n\n\n")}' - done - done -done diff --git a/utils/coverage_mapper.py b/utils/coverage_mapper.py index 9a2f1389781..88fa30f9b54 100644 --- a/utils/coverage_mapper.py +++ b/utils/coverage_mapper.py @@ -22,12 +22,14 @@ def map_scripts_paths(old_path): if INITIAL_GISBASE is None or INITIAL_PWD is None: return old_path p = Path(old_path) + extension = ".py" + p_name = p.stem if p.suffix == extension else p.name temporal_base = Path(INITIAL_GISBASE) / "scripts" / "t.*" base = Path(INITIAL_GISBASE) / "scripts" / "*" if p.match(str(temporal_base)): - return str(Path(INITIAL_PWD) / "temporal" / (p.name) / (p.name)) + ".py" + return str(Path(INITIAL_PWD) / "temporal" / (p_name) / (p_name)) + extension if p.match(str(base)): - return str(Path(INITIAL_PWD) / "scripts" / (p.name) / (p.name)) + ".py" + return str(Path(INITIAL_PWD) / "scripts" / (p_name) / (p_name)) + extension return old_path diff --git a/utils/g.html2man/g.html2man.py b/utils/g.html2man/g.html2man.py index 498ce34dfe1..58ffb2f7bca 100755 --- a/utils/g.html2man/g.html2man.py +++ b/utils/g.html2man/g.html2man.py @@ -17,12 +17,10 @@ def fix(content): tag, attrs, body = content if tag == "div" and ("class", "toc") in attrs: return None - else: - return (tag, attrs, fix(body)) - elif isinstance(content, list): + return (tag, attrs, fix(body)) + if isinstance(content, list): return [fixed for item in content for fixed in [fix(item)] if fixed is not None] - else: - return content + return content def main(): diff --git a/utils/g.html2man/ggroff.py b/utils/g.html2man/ggroff.py index 49c16f19f44..a0458dd0334 100644 --- a/utils/g.html2man/ggroff.py +++ b/utils/g.html2man/ggroff.py @@ -119,10 +119,7 @@ def fmt(self, format, content, var=None): self.show(pre) if sep != "": if var: - if var == "index": - val = self.get("index") + [0] - else: - val = True + val = self.get("index") + [0] if var == "index" else True self.pp_with(content, var, val) else: self.pp(content) @@ -253,8 +250,7 @@ def pp_text(self, content): for line in lines: self.pp_text(line) return - else: - content = lines[0] + content = lines[0] if self.at_bol and not self.get("preformat"): content = self.strip_re.sub("", content) self.pp_string(content) diff --git a/utils/g.html2man/ghtml.py b/utils/g.html2man/ghtml.py index eabb494198d..4b30950ff0e 100644 --- a/utils/g.html2man/ghtml.py +++ b/utils/g.html2man/ghtml.py @@ -95,7 +95,7 @@ def setify(d): - return dict([(key, frozenset(val)) for key, val in d.items()]) + return {key: frozenset(val) for key, val in d.items()} def omit(allowed, tags): @@ -225,8 +225,7 @@ def __init__(self, entities=None): def top(self): if self.tag_stack == []: return None - else: - return self.tag_stack[-1][0] + return self.tag_stack[-1][0] def pop(self): self.excluded = self.excluded_stack.pop() diff --git a/utils/g.html2man/rest.py b/utils/g.html2man/rest.py index 2df87db8e27..c320f18e397 100644 --- a/utils/g.html2man/rest.py +++ b/utils/g.html2man/rest.py @@ -1,4 +1,5 @@ import sys +from operator import itemgetter def match(node, tag, attr=None, val=None): @@ -26,8 +27,7 @@ def find(node, tag, attr=None, val=None): raise ValueError("child not found") -def children(node): - return node[2] +children = itemgetter(2) def text(node): diff --git a/utils/generate_release_notes.py b/utils/generate_release_notes.py index 3cfffe77bd2..c8a22b01d86 100755 --- a/utils/generate_release_notes.py +++ b/utils/generate_release_notes.py @@ -97,9 +97,7 @@ def print_category(category, changes, file=None): # Relies on author being specified as username. if " " in author: author = author.split(" ", maxsplit=1)[0] - if author.startswith("@"): - # We expect that to be always the case, but we test anyway. - author = author[1:] + author = author.removeprefix("@") if author in known_bot_names or author.endswith("[bot]"): hidden.append(item) elif len(visible) > max_section_length: @@ -229,7 +227,7 @@ def notes_from_gh_api(start_tag, end_tag, branch, categories, exclude): raw_changes = lines[start_whats_changed + 1 : end_whats_changed] changes = [] for change in raw_changes: - if change.startswith("* ") or change.startswith("- "): + if change.startswith(("* ", "- ")): changes.append(change[2:]) else: changes.append(change) diff --git a/utils/gitlog2changelog.py b/utils/gitlog2changelog.py index 758b142196b..5ad459aa2b1 100755 --- a/utils/gitlog2changelog.py +++ b/utils/gitlog2changelog.py @@ -78,14 +78,12 @@ dateFound = True except Exception as e: print(f"Could not parse dateList = '{line}'. Error: {e!s}") - # The Fossil-IDs are ignored: - elif line.startswith(" Fossil-ID:") or line.startswith(" [[SVN:"): - continue - # The svn-id lines are ignored - elif " git-svn-id:" in line: - continue - # The sign off line is ignored too - elif "Signed-off-by" in line: + # The Fossil-IDs, svn-id, ad sign off lines are ignored: + elif ( + line.startswith((" Fossil-ID:", " [[SVN:")) + or " git-svn-id:" in line + or "Signed-off-by" in line + ): continue # Extract the actual commit message for this commit elif authorFound & dateFound & messageFound is False: diff --git a/utils/mkhtml.py b/utils/mkhtml.py index 210e83b3fd6..39a5e6e26eb 100644 --- a/utils/mkhtml.py +++ b/utils/mkhtml.py @@ -159,17 +159,16 @@ def download_git_commit(url, response_format, *args, **kwargs): """ try: response = urlopen(url, *args, **kwargs) - if not response.code == 200: + if response.code != 200: index = HTTP_STATUS_CODES.index(response.code) desc = HTTP_STATUS_CODES[index].description gs.fatal( _( - "Download commit from <{url}>, return status code " - "{code}, {desc}".format( - url=url, - code=response.code, - desc=desc, - ), + "Download commit from <{url}>, return status code {code}, {desc}" + ).format( + url=url, + code=response.code, + desc=desc, ), ) if response_format not in response.getheader("Content-Type"): @@ -177,10 +176,10 @@ def download_git_commit(url, response_format, *args, **kwargs): _( "Wrong downloaded commit file format. " "Check url <{url}>. Allowed file format is " - "{response_format}.".format( - url=url, - response_format=response_format, - ), + "{response_format}." + ).format( + url=url, + response_format=response_format, ), ) return response @@ -190,16 +189,16 @@ def download_git_commit(url, response_format, *args, **kwargs): "The download of the commit from the GitHub API " "server wasn't successful, <{}>. Commit and commit " "date will not be included in the <{}> addon html manual " - "page.".format(err.msg, pgm) - ), + "page." + ).format(err.msg, pgm), ) except URLError: gs.warning( _( "Download file from <{url}>, failed. Check internet " "connection. Commit and commit date will not be included " - "in the <{pgm}> addon manual page.".format(url=url, pgm=pgm) - ), + "in the <{pgm}> addon manual page." + ).format(url=url, pgm=pgm), ) @@ -367,7 +366,7 @@ def has_src_code_git(src_dir, is_addon): if core module or addon source code has Git """ - actual_dir = os.getcwd() + actual_dir = Path.cwd() if is_addon: os.chdir(src_dir) else: @@ -407,15 +406,14 @@ def get_last_git_commit(src_dir, addon_path, is_addon): commit=process_result.stdout.decode(), src_dir=src_dir, ) - elif gs: + if gs: # Addons installation return get_git_commit_from_rest_api_for_addon_repo( addon_path=addon_path, src_dir=src_dir, ) # During GRASS GIS compilation from source code without Git - else: - return get_git_commit_from_file(src_dir=src_dir) + return get_git_commit_from_file(src_dir=src_dir) html_page_footer_pages_path = os.getenv("HTML_PAGE_FOOTER_PAGES_PATH") or "" @@ -850,10 +848,9 @@ def to_title(name): """Convert name of command class/family to form suitable for title""" if name == "raster3d": return "3D raster" - elif name == "postscript": + if name == "postscript": return "PostScript" - else: - return name.capitalize() + return name.capitalize() index_titles = {} diff --git a/utils/mkrest.py b/utils/mkrest.py index 24481bc3374..8d156e0bcc7 100755 --- a/utils/mkrest.py +++ b/utils/mkrest.py @@ -21,10 +21,7 @@ from datetime import datetime pgm = sys.argv[1] -if len(sys.argv) > 1: - year = sys.argv[2] -else: - year = str(datetime.now().year) +year = sys.argv[2] if len(sys.argv) > 1 else str(datetime.now().year) src_file = "%s.html" % pgm tmp_file = "%s.tmp.txt" % pgm diff --git a/utils/ppmrotate.py b/utils/ppmrotate.py index ec041e0f253..cef32eba0f4 100755 --- a/utils/ppmrotate.py +++ b/utils/ppmrotate.py @@ -110,11 +110,8 @@ def convert_and_rotate(src, dst, flip=False): to_png = False if dst.lower().endswith(".png"): to_png = True - if to_png: - tmp_img = gs.tempfile() + ".ppm" - # TODO: clean up the file - else: - tmp_img = dst + # TODO: clean up the file + tmp_img = gs.tempfile() + ".ppm" if to_png else dst write_ppm(tmp_img, ppm) if to_png: ppmtopng(dst, tmp_img) diff --git a/utils/thumbnails.py b/utils/thumbnails.py index ee9bd5e17ab..181a16aa666 100755 --- a/utils/thumbnails.py +++ b/utils/thumbnails.py @@ -23,13 +23,14 @@ def cleanup(): + names = [] if tmp_grad_rel: - gs.run_command( - "g.remove", flags="f", type="raster", name=tmp_grad_rel, quiet=True - ) + names.append(tmp_grad_rel) if tmp_grad_abs: + names.append(tmp_grad_abs) + if len(names) > 0: gs.run_command( - "g.remove", flags="f", type="raster", name=tmp_grad_abs, quiet=True + "g.remove", flags="f", type="raster", name=",".join(names), quiet=True ) diff --git a/utils/update_version.py b/utils/update_version.py index c66a34a62cd..947e68a1648 100755 --- a/utils/update_version.py +++ b/utils/update_version.py @@ -226,10 +226,7 @@ def status(args): version_info = read_version_file() today = datetime.date.today().isoformat() version = construct_version(version_info) - if not version_info.micro.endswith("dev"): - tag = version - else: - tag = None + tag = version if not version_info.micro.endswith("dev") else None if args.bash: status_as_bash(version_info=version_info, today=today, version=version, tag=tag) else: diff --git a/vector/Makefile b/vector/Makefile index f195ce3aafb..7244ac59af5 100644 --- a/vector/Makefile +++ b/vector/Makefile @@ -102,7 +102,6 @@ SUBDIRS = \ v.out.ogr \ v.in.ogr \ v.external \ - v.in.dwg \ v.in.lidar \ v.external.out diff --git a/vector/v.buffer/v.buffer.html b/vector/v.buffer/v.buffer.html index 8c835331630..06b2828cdfb 100644 --- a/vector/v.buffer/v.buffer.html +++ b/vector/v.buffer/v.buffer.html @@ -154,7 +154,7 @@

      Buffer inside input areas

      REFERENCES

      SEE ALSO

      diff --git a/vector/v.build/v.build.html b/vector/v.build/v.build.html index 9f51afdb22b..c66da69110a 100644 --- a/vector/v.build/v.build.html +++ b/vector/v.build/v.build.html @@ -27,7 +27,7 @@

      NOTES

      If error vector map is specified, v.build checks:
        -
      • isolated bondaries (which are not forming any areas),
      • +
      • isolated boundaries (which are not forming any areas),
      • centroids outside of area,
      • duplicated centroids.
      @@ -38,7 +38,7 @@

      NOTES

      • lines or boundaries of zero length,
      • -
      • intersecting boundaries, ie. overlapping areas,
      • +
      • intersecting boundaries, i.e. overlapping areas,
      • areas without centroids that are not isles.
      @@ -46,7 +46,7 @@

      EXAMPLES

      Build topology

      -Note that option=build recreates also spatial and category +Note that option=build also recreates spatial and category indices, not only topology. For linked OGR layers (see v.external) also feature index is created. @@ -61,7 +61,7 @@

      Build topology

      Dump topology or indices

      Dump options print topology, spatial, category or feature index to -standard output. Such information can be printed also for vector maps +standard output. Such information can also be printed for vector maps from other mapsets. A description of the vector topology is available in the GRASS GIS 8 Programmer's Manual, section "Vector library topology management". diff --git a/vector/v.cluster/main.c b/vector/v.cluster/main.c index c3f95e78778..49c7535beca 100644 --- a/vector/v.cluster/main.c +++ b/vector/v.cluster/main.c @@ -286,7 +286,6 @@ int main(int argc, char *argv[]) mean = sum / n; sd = sqrt(sumsq / n - mean * mean); - eps = mean + 1.644854 * sd; /* 90% CI */ eps = mean + 2.575829 * sd; /* 99% CI */ if (eps > max) @@ -493,7 +492,6 @@ int main(int argc, char *argv[]) mean = sum / n; sd = sqrt(sumsq / n - mean * mean); - eps = mean + 1.644854 * sd; /* 90% CI */ eps = mean + 2.575829 * sd; /* 99% CI */ if (eps > max) diff --git a/vector/v.cluster/v.cluster.html b/vector/v.cluster/v.cluster.html index 0e92f266eb9..9447538afab 100644 --- a/vector/v.cluster/v.cluster.html +++ b/vector/v.cluster/v.cluster.html @@ -21,7 +21,7 @@

      DESCRIPTION

      separately for each observed density (distance to the farthest neighbor).

      dbscan

      -The Density-Based Spatial +The Density-Based Spatial Clustering of Applications with Noise is a commonly used clustering algorithm. A new cluster is started for a point with at least min - 1 neighbors within the maximum distance. These neighbors @@ -46,7 +46,7 @@

      density

      optics

      This method is Ordering Points to +href="https://en.wikipedia.org/wiki/OPTICS_algorithm">Ordering Points to Identify the Clustering Structure. It is controlled by the number of neighbor points (option min - 1). The core distance of a point is the distance to the farthest neighbor. The reachability of a diff --git a/vector/v.colors/read_rgb.c b/vector/v.colors/read_rgb.c index 99aa054138d..c6e762ca0af 100644 --- a/vector/v.colors/read_rgb.c +++ b/vector/v.colors/read_rgb.c @@ -64,4 +64,5 @@ void rgb2colr(struct Map_info *Map, int layer, const char *rgb_column, G_warning(_("%d invalid RGB color values skipped"), nskipped); db_close_database_shutdown_driver(driver); + Vect_destroy_field_info(fi); } diff --git a/vector/v.colors/scan_attr.c b/vector/v.colors/scan_attr.c index 18c51635f81..e805cd74a7f 100644 --- a/vector/v.colors/scan_attr.c +++ b/vector/v.colors/scan_attr.c @@ -42,6 +42,8 @@ int scan_attr(struct Map_info *Map, int layer, const char *column_name, &cvarr); if (nrec < 1) { G_important_message(_("No data selected")); + Vect_destroy_field_info(fi); + db_close_database(driver); return 0; } @@ -100,6 +102,7 @@ int scan_attr(struct Map_info *Map, int layer, const char *column_name, } db_close_database(driver); + Vect_destroy_field_info(fi); return is_fp; } diff --git a/vector/v.external.out/v.external.out.html b/vector/v.external.out/v.external.out.html index 1d82620f17c..f9c3575aa88 100644 --- a/vector/v.external.out/v.external.out.html +++ b/vector/v.external.out/v.external.out.html @@ -2,9 +2,9 @@

      DESCRIPTION

      v.external.out instructs GRASS to write vector maps in external data format (e.g. ESRI Shapefile, Mapinfo, and others) -using OGR library. PostGIS data can +using OGR library. PostGIS data can be also written by -built-in GRASS-PostGIS +built-in GRASS-PostGIS data provider.

      NOTES

      @@ -26,9 +26,9 @@

      NOTES

      by format option. See the list of valid creation options at OGR formats specification page, example -for ESRI +for ESRI Shapefile -or PostgreSQL/PostGIS +or PostgreSQL/PostGIS format (section "Layer Creation Options"). Options are comma-separated pairs (key=value), the options are case-insensitive, @@ -180,10 +180,10 @@

      Restore settings

      REFERENCES

      SEE ALSO

      diff --git a/vector/v.external/dsn.c b/vector/v.external/dsn.c index 1a0d6bc2a57..c56009a64e2 100644 --- a/vector/v.external/dsn.c +++ b/vector/v.external/dsn.c @@ -31,7 +31,7 @@ char *get_datasource_name(const char *opt_dsn, int use_ogr) /* add db.login settings (user, password, host, port) */ if (DB_OK == - db_get_login2("pg", database, &user, &passwd, &host, &port)) { + db_get_login("pg", database, &user, &passwd, &host, &port)) { if (user) { if (!G_strcasestr(opt_dsn, "user=")) { strcat(connect_str, " user="); diff --git a/vector/v.external/v.external.html b/vector/v.external/v.external.html index fb1512f8942..200d3726363 100644 --- a/vector/v.external/v.external.html +++ b/vector/v.external/v.external.html @@ -3,7 +3,7 @@

      DESCRIPTION

      v.external creates new vector map as a link to external OGR layer or PostGIS feature table. OGR (Simple Features Library) is part of the -GDAL library, so you need to install +GDAL library, so you need to install GDAL to use v.external for external OGR layers. Note that a PostGIS feature table can be linked also using built-in GRASS-PostGIS data driver (requires GRASS to be built with PostgreSQL support). @@ -140,7 +140,7 @@

      SEE ALSO

      -GDAL Library +GDAL Library
      PostGIS diff --git a/vector/v.extract/testsuite/test_v_extract.py b/vector/v.extract/testsuite/test_v_extract.py index d266e8ad649..c46505a5527 100644 --- a/vector/v.extract/testsuite/test_v_extract.py +++ b/vector/v.extract/testsuite/test_v_extract.py @@ -5,13 +5,12 @@ Author: Sunveer Singh, Google Code-in 2017 Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ import os from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule from grass.script.core import read_command TABLE_1 = """cat|MAJORRDS_|ROAD_NAME|MULTILANE|PROPYEAR|OBJECTID|SHAPE_LEN @@ -54,8 +53,8 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - def tearDown(cls): - cls.runModule("g.remove", flags="f", type="vector", name=cls.output) + def tearDown(self): + self.runModule("g.remove", flags="f", type="vector", name=self.output) def test_flagd(self): """Testing flag d""" diff --git a/vector/v.fill.holes/examples.ipynb b/vector/v.fill.holes/examples.ipynb index fcc006501e4..a6b3ea746ce 100644 --- a/vector/v.fill.holes/examples.ipynb +++ b/vector/v.fill.holes/examples.ipynb @@ -15,12 +15,10 @@ "metadata": {}, "outputs": [], "source": [ - "import os\n", "import sys\n", "\n", "from IPython.display import Image\n", "\n", - "import grass.script as gs\n", "import grass.jupyter as gj" ] }, diff --git a/vector/v.generalize/displacement.c b/vector/v.generalize/displacement.c index bc7a3f15170..a4d599080e4 100644 --- a/vector/v.generalize/displacement.c +++ b/vector/v.generalize/displacement.c @@ -310,6 +310,8 @@ int snakes_displacement(struct Map_info *In, struct Map_info *Out, matrix_free(&fy); matrix_free(&dx_old); matrix_free(&dy_old); + Vect_destroy_cats_struct(Cats); + Vect_destroy_line_struct(Points); return 0; } diff --git a/vector/v.hull/chull.c b/vector/v.hull/chull.c index 93dfd15742e..cd8dcf52153 100644 --- a/vector/v.hull/chull.c +++ b/vector/v.hull/chull.c @@ -687,6 +687,8 @@ void CleanEdges(void) e = edges; DELETE(edges, e); } + if (!edges) + return; e = edges->next; do { if (e->delete) { @@ -711,6 +713,8 @@ void CleanFaces(void) f = faces; DELETE(faces, f); } + if (!faces) + return; f = faces->next; do { if (f->visible) { @@ -746,6 +750,8 @@ void CleanVertices(void) v = vertices; DELETE(vertices, v); } + if (!vertices) + return; v = vertices->next; do { if (v->mark && !v->onhull) { diff --git a/vector/v.in.dwg/Makefile b/vector/v.in.dwg/Makefile deleted file mode 100644 index c5c30c1dde7..00000000000 --- a/vector/v.in.dwg/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -MODULE_TOPDIR = ../.. - -PGM=v.in.dwg -ADINIT = $(ETC)/adinit.dat -ADINITSRC := $(shell echo $(OPENDWGINCPATH) | cut -b3- )/adinit/adinit.dat - -DEPENDENCIES = $(VECTORDEP) $(DBMIDEP) $(GISDEP) -LIBES = $(VECTORLIB) $(DBMILIB) $(GISLIB) $(OPENDWGLIBPATH) $(OPENDWGLIB) -EXTRA_INC = $(VECT_INC) $(OPENDWGINCPATH) -EXTRA_CFLAGS = $(VECT_CFLAGS) - -include $(MODULE_TOPDIR)/include/Make/Module.make - -ifneq ($(USE_OPENDWG),) -default: check - $(MAKE) cmd $(ADINIT) -endif - -check: -ifneq ($(strip $(MINGW)),) - cat WARNING -else - cat WARNING >/dev/tty -endif - @read IN ." diff --git a/vector/v.in.dwg/entity.c b/vector/v.in.dwg/entity.c deleted file mode 100644 index c70bc308fe0..00000000000 --- a/vector/v.in.dwg/entity.c +++ /dev/null @@ -1,540 +0,0 @@ -/* ************************************************************** - * - * MODULE: v.in.dwg - * - * AUTHOR(S): Radim Blazek - * - * PURPOSE: Import of DWG/DXF files - * - * COPYRIGHT: (C) 2001 by the GRASS Development Team - * - * This program is free software under the - * GNU General Public License (>=v2). - * Read the file COPYING that comes with GRASS - * for details. - * - * In addition, as a special exception, Radim Blazek gives permission - * to link the code of this program with the OpenDWG libraries (or with - * modified versions of the OpenDWG libraries that use the same license - * as OpenDWG libraries), and distribute linked combinations including the two. - * You must obey the GNU General Public License in all respects for all - * of the code used other than. If you modify this file, you may extend - * this exception to your version of the file, but you are not obligated - * to do so. If you do not wish to do so, delete this exception statement - * from your version. - * - * **************************************************************/ - -/* Documentation: - * http://www.opendwg.org - * -> OpenDWG Toolkit Reference - * - * Unsupported entities must be added in wrentity() - * - * TODO: 3rd dimension is not functional for CIRCLE and ARC - * -> required updated of transformation in INSERT - * (how to do that??) - */ - -#define AD_PROTOTYPES -#define AD_VM_PC - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ad2.h" -#include "global.h" - -#define exampleprintf printf -#define LOCPI M_PI - -char buf[1000]; -char buf2[1000]; - -void getEntTypeName(PAD_ENT_HDR adenhd, char *name) -{ - switch (adenhd->enttype) { - case AD_ENT_LINE: - strcpy(name, "LINE"); - break; - case AD_ENT_POINT: - strcpy(name, "POINT"); - break; - case AD_ENT_CIRCLE: - strcpy(name, "CIRCLE"); - break; - case AD_ENT_SHAPE: - strcpy(name, "SHAPE"); - break; - case AD_ENT_ELLIPSE: - strcpy(name, "ELLIPSE"); - break; - case AD_ENT_SPLINE: - strcpy(name, "SPLINE"); - break; - case AD_ENT_TEXT: - strcpy(name, "TEXT"); - break; - case AD_ENT_ARC: - strcpy(name, "ARC"); - break; - case AD_ENT_TRACE: - strcpy(name, "TRACE"); - break; - case AD_ENT_SOLID: - strcpy(name, "SOLID"); - break; - case AD_ENT_BLOCK: - strcpy(name, "BLOCK"); - break; - case AD_ENT_ENDBLK: - strcpy(name, "ENDBLK"); - break; - case AD_ENT_INSERT: - strcpy(name, "INSERT"); - break; - case AD_ENT_ATTDEF: - strcpy(name, "ATTDEF"); - break; - case AD_ENT_ATTRIB: - strcpy(name, "ATTRIB"); - break; - case AD_ENT_SEQEND: - strcpy(name, "SEQEND"); - break; - case AD_ENT_POLYLINE: - strcpy(name, "POLYLINE"); - break; - case AD_ENT_VERTEX: - strcpy(name, "VERTEX"); - break; - case AD_ENT_LINE3D: - strcpy(name, "3DLINE"); - break; - case AD_ENT_FACE3D: - strcpy(name, "3DFACE"); - break; - case AD_ENT_DIMENSION: - strcpy(name, "DIMENSION"); - break; - case AD_ENT_VIEWPORT: - strcpy(name, "VIEWPORT"); - break; - case AD_ENT_SOLID3D: - strcpy(name, "SOLID3D"); - break; - case AD_ENT_RAY: - strcpy(name, "RAY"); - break; - case AD_ENT_XLINE: - strcpy(name, "XLINE"); - break; - case AD_ENT_MTEXT: - strcpy(name, "MTEXT"); - break; - case AD_ENT_LEADER: - strcpy(name, "LEADER"); - break; - case AD_ENT_TOLERANCE: - strcpy(name, "TOLERANCE"); - break; - case AD_ENT_MLINE: - strcpy(name, "MLINE"); - break; - case AD_ENT_BODY: - strcpy(name, "BODY"); - break; - case AD_ENT_REGION: - strcpy(name, "REGION"); - break; - default: - if (adenhd->enttype == adOle2frameEnttype(dwghandle)) - strcpy(name, "OLE2FRAME"); - else if (adenhd->enttype == adLwplineEnttype(dwghandle)) - strcpy(name, "LWPOLYLINE"); - else if (adenhd->enttype == adHatchEnttype(dwghandle)) - strcpy(name, "HATCH"); - else if (adenhd->enttype == adImageEnttype(dwghandle)) - strcpy(name, "IMAGE"); - else if (adenhd->enttype == adArcAlignedTextEnttype(dwghandle)) - strcpy(name, "ArcAlignedText"); - else if (adenhd->enttype == adWipeoutEnttype(dwghandle)) - strcpy(name, "Wipeout"); - else if (adenhd->enttype == adRtextEnttype(dwghandle)) - strcpy(name, "Rtext"); - else { /* regular proxy */ - - G_debug(3, "adenhd->enttype: %d", adenhd->enttype); - strcpy(name, "Proxy"); - } - break; - } -} - -int write_line(PAD_ENT_HDR adenhd, int type, int level) -{ - int i, l; - double x, y, z, r, ang; - - adSeekLayer(dwghandle, adenhd->entlayerobjhandle, Layer); - - /* Transformation, go up through all levels of transformation */ - /* not sure what is the right order of transformation */ - for (l = level; l >= 0; l--) { - for (i = 0; i < Points->n_points; i++) { - /* scale */ - x = Points->x[i] * Trans[l].xscale; - y = Points->y[i] * Trans[l].yscale; - z = Points->z[i] * Trans[l].zscale; - /* rotate */ - r = sqrt(x * x + y * y); - ang = atan2(y, x) + Trans[l].rotang; - x = r * cos(ang); - y = r * sin(ang); - /* move */ - x += Trans[l].dx; - y += Trans[l].dy; - z += Trans[l].dz; - Points->x[i] = x; - Points->y[i] = y; - Points->z[i] = z; - } - } - - Vect_reset_cats(Cats); - Vect_cat_set(Cats, 1, cat); - Vect_write_line(&Map, type, Points, Cats); - - /* Cat */ - sprintf(buf, "insert into %s values ( %d", Fi->table, cat); - db_set_string(&sql, buf); - - /* Entity name */ - getEntTypeName(adenhd, buf2); - sprintf(buf, ", '%s'", buf2); - db_append_string(&sql, buf); - - /* Color */ - sprintf(buf, ", %d", adenhd->entcolor); - db_append_string(&sql, buf); - - /* Weight */ - sprintf(buf, ", %d", adenhd->lineweight); - db_append_string(&sql, buf); - - /* Layer name */ - if (!Layer->purgedflag && Layer->name != NULL) { - db_set_string(&str, Layer->name); - db_double_quote_string(&str); - sprintf(buf, ", '%s'", db_get_string(&str)); - } - else { - sprintf(buf, ", ''"); - } - db_append_string(&sql, buf); - - /* Block name */ - if (Block != NULL) { - db_set_string(&str, Block); - db_double_quote_string(&str); - } - else { - db_set_string(&str, ""); - } - sprintf(buf, ", '%s'", db_get_string(&str)); - db_append_string(&sql, buf); - - /* Text */ - if (Txt != NULL) { - db_set_string(&str, Txt); - db_double_quote_string(&str); - } - else { - db_set_string(&str, ""); - } - sprintf(buf, ", '%s'", db_get_string(&str)); - db_append_string(&sql, buf); - - db_append_string(&sql, ")"); - G_debug(3, db_get_string(&sql)); - - if (db_execute_immediate(driver, &sql) != DB_OK) { - db_close_database(driver); - db_shutdown_driver(driver); - G_fatal_error("Cannot insert new row: %s", db_get_string(&sql)); - } - - cat++; - return 0; -} - -/* Returns 1 if element has geometry and may be written to vector */ -int is_low_level(PAD_ENT_HDR adenhd) -{ - if (adenhd->enttype == AD_ENT_BLOCK || adenhd->enttype == AD_ENT_ENDBLK || - adenhd->enttype == AD_ENT_SEQEND || adenhd->enttype == AD_ENT_INSERT) { - return 0; - } - return 1; -} - -void wrentity(PAD_ENT_HDR adenhd, PAD_ENT aden, int level, AD_VMADDR entlist, - int circle_as_point) -{ - short ret; - PAD_BLOB_CTRL bcptr; - PAD_ENT_HDR adenhd2; - PAD_ENT aden2; - OdaLong il; - double tempdouble[3], tempbulge, tempwidth[3]; - double x, y, z, ang; - PAD_BLKH adblkh; - int layer_found = 1; - - if (is_low_level(adenhd)) - n_elements++; - - /* Check layer name */ - if (layers_opt->answers) { - int i = 0; - - adSeekLayer(dwghandle, adenhd->entlayerobjhandle, Layer); - - layer_found = 0; - if (!Layer->purgedflag) { - while (layers_opt->answers[i]) { - if (strcmp(Layer->name, layers_opt->answers[i]) == 0) { - layer_found = 1; - break; - } - i++; - } - } - - if ((!invert_flag->answer && !layer_found) || - (invert_flag->answer && layer_found)) { - if (is_low_level(adenhd)) - n_skipped++; - if (adenhd->enttype != AD_ENT_INSERT && - adenhd->enttype != AD_ENT_POLYLINE) - return; - } - } - - getEntTypeName(adenhd, buf); - G_debug(1, "Entity: %s", buf); - - Txt = NULL; - adenhd2 = (PAD_ENT_HDR)G_malloc(sizeof(AD_ENT_HDR)); - aden2 = (PAD_ENT)G_malloc(sizeof(AD_ENT)); - adblkh = (PAD_BLKH)G_malloc(sizeof(AD_BLKH)); - Vect_reset_line(Points); - - /* Check space for lower level */ - if (level + 1 == atrans) { - atrans += 10; - Trans = (TRANS *)G_realloc(Trans, atrans * sizeof(TRANS)); - } - - switch (adenhd->enttype) { - case AD_ENT_LINE: - Vect_append_point(Points, aden->line.pt0[0], aden->line.pt0[1], - aden->line.pt0[2]); - Vect_append_point(Points, aden->line.pt1[0], aden->line.pt1[1], - aden->line.pt1[2]); - write_line(adenhd, GV_LINE, level); - break; - - case AD_ENT_FACE3D: - Vect_append_point(Points, aden->face3d.pt0[0], aden->face3d.pt0[1], - aden->face3d.pt0[2]); - Vect_append_point(Points, aden->face3d.pt1[0], aden->face3d.pt1[1], - aden->face3d.pt1[2]); - Vect_append_point(Points, aden->face3d.pt2[0], aden->face3d.pt2[1], - aden->face3d.pt2[2]); - Vect_append_point(Points, aden->face3d.pt3[0], aden->face3d.pt3[1], - aden->face3d.pt3[2]); - write_line(adenhd, GV_FACE, level); - break; - - case AD_ENT_SOLID: - Vect_append_point(Points, aden->solid.pt0[0], aden->solid.pt0[1], - aden->solid.pt0[2]); - Vect_append_point(Points, aden->solid.pt1[0], aden->solid.pt1[1], - aden->solid.pt1[2]); - Vect_append_point(Points, aden->solid.pt2[0], aden->solid.pt2[1], - aden->solid.pt2[2]); - Vect_append_point(Points, aden->solid.pt3[0], aden->solid.pt3[1], - aden->solid.pt3[2]); - write_line(adenhd, GV_FACE, level); - break; - - case AD_ENT_TEXT: - Txt = aden->text.textstr; - Vect_append_point(Points, aden->text.pt0[0], aden->text.pt0[1], - aden->line.pt0[2]); - write_line(adenhd, GV_POINT, level); - break; - - case AD_ENT_POINT: - Vect_append_point(Points, aden->point.pt0[0], aden->point.pt0[1], - aden->line.pt0[2]); - write_line(adenhd, GV_POINT, level); - break; - - case AD_ENT_ARC: - for (ang = aden->arc.stang; ang < aden->arc.endang; - ang += 2 * LOCPI / 360) { - x = aden->arc.pt0[0] + aden->arc.radius * cos(ang); - y = aden->arc.pt0[1] + aden->arc.radius * sin(ang); - z = aden->arc.pt0[2]; - Vect_append_point(Points, x, y, z); - } - x = aden->arc.pt0[0] + aden->arc.radius * cos(aden->arc.endang); - y = aden->arc.pt0[1] + aden->arc.radius * sin(aden->arc.endang); - z = aden->arc.pt0[2]; - Vect_append_point(Points, x, y, z); - write_line(adenhd, GV_LINE, level); - break; - - case AD_ENT_CIRCLE: - if (circle_as_point) { - Vect_append_point(Points, aden->circle.pt0[0], aden->circle.pt0[1], - aden->circle.pt0[3]); - write_line(adenhd, GV_POINT, level); - } - else { - for (ang = 0; ang < 2 * LOCPI; ang += 2 * LOCPI / 360) { - x = aden->circle.pt0[0] + aden->circle.radius * cos(ang); - y = aden->circle.pt0[1] + aden->circle.radius * sin(ang); - z = aden->circle.pt0[3]; - Vect_append_point(Points, x, y, z); - } - Vect_append_point(Points, Points->x[0], Points->y[0], Points->z[0]); - write_line(adenhd, GV_LINE, level); - } - break; - - /* BLOCK starts block of entities but makes no transformation - is it - * right ? - * -> do nothing just warn for xref */ - case AD_ENT_BLOCK: - if (aden->block.xrefpath[0]) { - G_warning("External reference for block not supported.\n xref: %s", - aden->block.xrefpath); - } - Block = G_store(aden->block.name2); - break; - - case AD_ENT_ENDBLK: /* endblk - no data */ - G_free(Block); - Block = NULL; - break; - - case AD_ENT_INSERT: /* insert */ - /* get transformation */ - /* TODO: fix rotation for CIRCLE and ARC */ - G_debug(3, " x,y,z: %f, %f, %f", aden->insert.pt0[0], - aden->insert.pt0[1], aden->insert.pt0[2]); - G_debug(3, " xscale, yscale, zscale: %f, %f, %f", aden->insert.xscale, - aden->insert.yscale, aden->insert.zscale); - G_debug(3, " rotang: %f", aden->insert.rotang); - G_debug(3, " ncols, nrows: %d, %d", aden->insert.numcols, - aden->insert.numrows); - G_debug(3, " coldist, rowdist: %f, %f", aden->insert.coldist, - aden->insert.rowdist); - - /* write block entities */ - adSeekBlockheader(dwghandle, aden->insert.blockheaderobjhandle, adblkh); - if (!adblkh->purgedflag) { - adStartEntityGet(adblkh->entitylist); - while (1) { - ret = adGetEntity(adblkh->entitylist, adenhd2, aden2); - if (adenhd2->enttype == AD_ENT_ENDBLK) - break; - if (ret) { - /* Set transformation for lower level */ - Trans[level + 1].dx = aden->insert.pt0[0]; - Trans[level + 1].dy = aden->insert.pt0[1]; - Trans[level + 1].dz = aden->insert.pt0[2]; - Trans[level + 1].xscale = aden->insert.xscale; - Trans[level + 1].yscale = aden->insert.yscale; - Trans[level + 1].zscale = aden->insert.zscale; - Trans[level + 1].rotang = aden->insert.rotang; - wrentity(adenhd2, aden2, level + 1, adblkh->entitylist, - circle_as_point); - } - } - } - break; - - case AD_ENT_SEQEND: /* seqend */ - break; - - case AD_ENT_POLYLINE: - while (1) { - ret = adGetEntity(entlist, adenhd2, aden2); - if (ret != 1) { - G_warning("Cannot get entity: %d: %s.", adError(), - adErrorStr(adError())); - break; - } - - if (adenhd2->enttype == AD_ENT_SEQEND) - break; - if (adenhd2->enttype != AD_ENT_VERTEX) { - getEntTypeName(adenhd2, buf); - G_warning("Expected VERTEX got %s in POLYLINE -> skip", buf); - } - else { - Vect_append_point(Points, aden2->vertex.pt0[0], - aden2->vertex.pt0[1], aden2->vertex.pt0[2]); - } - }; - if ((!invert_flag->answer && layer_found) || - (invert_flag->answer && !layer_found)) - write_line(adenhd, GV_LINE, level); - break; - - default: - if (adenhd->enttype == adLwplineEnttype(dwghandle)) { - G_debug(3, "Npoints: %ld\n", aden->lwpline.numpoints); - bcptr = adStartBlobRead(aden->lwpline.ldblob); - for (il = 0; il < aden->lwpline.numpoints; il++) { - adReadBlob2Double(bcptr, tempdouble); - Vect_append_point(Points, tempdouble[0], tempdouble[1], - tempdouble[2]); - tempbulge = tempwidth[0] = tempwidth[1] = tempwidth[2] = 0.0; - if (aden->lwpline.flag & AD_LWPLINE_HAS_BULGES) { - adReadBlobDouble(bcptr, &tempbulge); - } - if (aden->lwpline.flag & AD_LWPLINE_HAS_WIDTHS) { - adReadBlob2Double(bcptr, tempwidth); - } - } - G_debug(3, "flag = %d", aden->lwpline.flag); - if (aden->lwpline.flag & AD_LWPLINE_IS_CLOSED) { - G_debug(3, " -> is closed"); - Vect_append_point(Points, Points->x[0], Points->y[0], - Points->z[0]); - } - write_line(adenhd, GV_LINE, level); - adEndBlobRead(bcptr); - } - else { - getEntTypeName(adenhd, buf); - G_warning("%s entity not supported", buf); - } - break; - - } /* end of switch */ - - G_free(aden2); - G_free(adenhd2); -} diff --git a/vector/v.in.dwg/global.h b/vector/v.in.dwg/global.h deleted file mode 100644 index 39e46f17856..00000000000 --- a/vector/v.in.dwg/global.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ************************************************************** - * - * MODULE: v.in.dwg - * - * AUTHOR(S): Radim Blazek - * - * PURPOSE: Import of DWG/DXF files - * - * COPYRIGHT: (C) 2001 by the GRASS Development Team - * - * This program is free software under the - * GNU General Public License (>=v2). - * Read the file COPYING that comes with GRASS - * for details. - * - * In addition, as a special exception, Radim Blazek gives permission - * to link the code of this program with the OpenDWG libraries (or with - * modified versions of the OpenDWG libraries that use the same license - * as OpenDWG libraries), and distribute linked combinations including the two. - * You must obey the GNU General Public License in all respects for all - * of the code used other than. If you modify this file, you may extend - * this exception to your version of the file, but you are not obligated - * to do so. If you do not wish to do so, delete this exception statement - * from your version. - * - * **************************************************************/ - -/* transformation, first level is 0 ( called from main ) and transformation - * for this level is 0,0,0, 1,1,1, 0 so that no transformation is done on first - * level (not effective but better readable?) */ -typedef struct { - double dx, dy, dz; - double xscale, yscale, zscale; - double rotang; -} TRANS; - -extern int cat; -extern int - n_elements; /* number of processed elements (only low level elements) */ -extern int - n_skipped; /* number of skipped low level elements (different layer name) */ -extern struct Map_info Map; -extern dbDriver *driver; -extern dbString sql; -extern dbString str; -extern struct line_pnts *Points; -extern struct line_cats *Cats; -extern PAD_LAY Layer; -extern char *Txt; -extern char *Block; -extern struct field_info *Fi; -extern AD_DB_HANDLE dwghandle; -extern TRANS *Trans; /* transformation */ -extern int atrans; /* number of allocated levels */ -extern struct Option *layers_opt; -extern struct Flag *invert_flag; - -void wrentity(PAD_ENT_HDR adenhd, PAD_ENT aden, int level, AD_VMADDR entlist, - int circle_as_point); diff --git a/vector/v.in.dwg/main.c b/vector/v.in.dwg/main.c deleted file mode 100644 index e21602ecb90..00000000000 --- a/vector/v.in.dwg/main.c +++ /dev/null @@ -1,291 +0,0 @@ -/* ************************************************************** - * - * MODULE: v.in.dwg - * - * AUTHOR(S): Radim Blazek - * - * PURPOSE: Import of DWG/DXF files - * - * COPYRIGHT: (C) 2001-2008 by the GRASS Development Team - * - * This program is free software under the - * GNU General Public License (>=v2). - * Read the file COPYING that comes with GRASS - * for details. - * - * In addition, as a special exception, Radim Blazek gives permission - * to link the code of this program with the OpenDWG libraries (or with - * modified versions of the OpenDWG libraries that use the same license - * as OpenDWG libraries), and distribute linked combinations including the two. - * You must obey the GNU General Public License in all respects for all - * of the code used other than. If you modify this file, you may extend - * this exception to your version of the file, but you are not obligated - * to do so. If you do not wish to do so, delete this exception statement - * from your version. - * - * **************************************************************/ -#define AD_PROTOTYPES -#define AD_VM_PC -#define OD_GENERIC_READ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ad2.h" -#include "io/odio.h" -#include "global.h" - -int cat; -int n_elements; /* number of processed elements (only low level elements) */ -int n_skipped; /* number of skipped low level elements (different layer name) */ -struct Map_info Map; -dbDriver *driver; -dbString sql; -dbString str; -struct line_pnts *Points; -struct line_cats *Cats; -PAD_LAY Layer; -char *Txt; -char *Block; -struct field_info *Fi; -AD_DB_HANDLE dwghandle; -TRANS *Trans; /* transformation */ -int atrans; /* number of allocated levels */ -struct Option *layers_opt; -struct Flag *invert_flag; - -int main(int argc, char *argv[]) -{ - struct GModule *module; - struct Option *out_opt, *in_opt; - struct Flag *z_flag, *circle_flag, *l_flag, *int_flag; - char buf[2000]; - - /* DWG */ - char path[2000]; - short initerror, entset, retval; - AD_OBJHANDLE pspace, mspace; - PAD_ENT_HDR adenhd; - PAD_ENT aden; - AD_VMADDR entlist; - - G_gisinit(argv[0]); - - module = G_define_module(); - G_add_keyword(_("vector")); - G_add_keyword(_("import")); - module->description = _("Converts DWG/DXF to GRASS vector map"); - - in_opt = G_define_standard_option(G_OPT_F_INPUT); - in_opt->description = _("Name of DWG or DXF file"); - - out_opt = G_define_standard_option(G_OPT_V_OUTPUT); - out_opt->required = YES; - - layers_opt = G_define_option(); - layers_opt->key = "layers"; - layers_opt->type = TYPE_STRING; - layers_opt->required = NO; - layers_opt->multiple = YES; - layers_opt->description = _("List of layers to import"); - - invert_flag = G_define_flag(); - invert_flag->key = 'i'; - invert_flag->description = - _("Invert selection by layers (don't import layers in list)"); - - z_flag = G_define_flag(); - z_flag->key = 'z'; - z_flag->description = _("Create 3D vector map"); - - circle_flag = G_define_flag(); - circle_flag->key = 'c'; - circle_flag->description = _("Write circles as points (centre)"); - - l_flag = G_define_flag(); - l_flag->key = 'l'; - l_flag->description = _("List available layers and exit"); - - int_flag = G_define_flag(); - int_flag->key = 'n'; - int_flag->description = _("Use numeric type for attribute \"layer\""); - - if (G_parser(argc, argv)) - exit(EXIT_FAILURE); - - db_init_string(&sql); - db_init_string(&str); - adenhd = (PAD_ENT_HDR)G_malloc(sizeof(AD_ENT_HDR)); - aden = (PAD_ENT)G_malloc(sizeof(AD_ENT)); - Layer = (PAD_LAY)G_malloc(sizeof(AD_LAY)); - Points = Vect_new_line_struct(); - Cats = Vect_new_cats_struct(); - Block = NULL; - - atrans = 20; /* nested, recursive levels */ - Trans = (TRANS *)G_malloc(atrans * sizeof(TRANS)); - - /* Init OpenDWG */ - sprintf(path, "%s/etc/adinit.dat", G_gisbase()); - if (!adInitAd2(path, &initerror)) { - sprintf(buf, _("Unable to initialize OpenDWG Toolkit, error: %d: %s."), - initerror, adErrorStr(initerror)); - if (initerror == AD_UNABLE_TO_OPEN_INIT_FILE) - sprintf(buf, _("%s Cannot open %s"), buf, path); - G_fatal_error(buf); - } - adSetupDwgRead(); - adSetupDxfRead(); - - /* Open input file */ - if ((dwghandle = adLoadFile(in_opt->answer, AD_PRELOAD_ALL, 1)) == NULL) { - G_fatal_error(_("Unable to open input file <%s>. Error %d: %s"), - in_opt->answer, adError(), adErrorStr(adError())); - } - - if (l_flag->answer) { /* List layers */ - PAD_TB adtb; - AD_DWGHDR adhd; - int i; - char on, frozen, vpfrozen, locked; - - adtb = (PAD_TB)G_malloc(sizeof(AD_TB)); - - G_debug(2, "%d layers", (int)adNumLayers(dwghandle)); - adReadHeaderBlock(dwghandle, &adhd); - adStartLayerGet(dwghandle); - - fprintf(stdout, "%d layers:\n", (int)adNumLayers(dwghandle)); - for (i = 0; i < (int)adNumLayers(dwghandle); i++) { - adGetLayer(dwghandle, &(adtb->lay)); - if (!adtb->lay.purgedflag) { - fprintf(stdout, "%s COLOR %d, ", adtb->lay.name, - adtb->lay.color); - } - adGetLayerState(dwghandle, adtb->lay.objhandle, &on, &frozen, - &vpfrozen, &locked); - if (on) - fprintf(stdout, "ON, "); - else - fprintf(stdout, "OFF, "); - if (frozen) - fprintf(stdout, "FROZEN, "); - else - fprintf(stdout, "THAWED, "); - if (vpfrozen) - fprintf(stdout, "VPFROZEN, "); - else - fprintf(stdout, "VPTHAWED, "); - if (locked) - fprintf(stdout, "LOCKED\n"); - else - fprintf(stdout, "UNLOCKED\n"); - } - adCloseFile(dwghandle); - adCloseAd2(); - exit(EXIT_SUCCESS); - } - - /* open output vector */ - if (Vect_open_new(&Map, out_opt->answer, z_flag->answer) < 0) - G_fatal_error(_("Unable to create vector map <%s>"), out_opt->answer); - - Vect_hist_command(&Map); - - /* Add DB link */ - Fi = Vect_default_field_info(&Map, 1, NULL, GV_1TABLE); - Vect_map_add_dblink(&Map, 1, NULL, Fi->table, GV_KEY_COLUMN, Fi->database, - Fi->driver); - - driver = db_start_driver_open_database(Fi->driver, - Vect_subst_var(Fi->database, &Map)); - if (driver == NULL) { - G_fatal_error(_("Unable to open database <%s> by driver <%s>"), - Vect_subst_var(Fi->database, &Map), Fi->driver); - } - db_set_error_handler_driver(driver); - - db_begin_transaction(driver); - - /* Create table */ - if (int_flag->answer) { /* List layers */ - sprintf(buf, - "create table %s ( cat integer, entity_name varchar(20), color " - "int, weight int, " - "layer real, block varchar(100), txt varchar(100) )", - Fi->table); - } - else { - sprintf(buf, - "create table %s ( cat integer, entity_name varchar(20), color " - "int, weight int, " - "layer varchar(100), block varchar(100), txt varchar(100) )", - Fi->table); - } - db_set_string(&sql, buf); - G_debug(3, db_get_string(&sql)); - - if (db_execute_immediate(driver, &sql) != DB_OK) { - db_close_database(driver); - db_shutdown_driver(driver); - G_fatal_error(_("Unable to create table: '%s'"), db_get_string(&sql)); - } - - if (db_create_index2(driver, Fi->table, GV_KEY_COLUMN) != DB_OK) - G_warning(_("Unable to create index for table <%s>, key <%s>"), - Fi->table, GV_KEY_COLUMN); - - if (db_grant_on_table(driver, Fi->table, DB_PRIV_SELECT, - DB_GROUP | DB_PUBLIC) != DB_OK) - G_fatal_error(_("Unable to grant privileges on table <%s>"), Fi->table); - - cat = 1; - n_elements = n_skipped = 0; - /* Write each entity. Some entities may be composed by other entities (like - * INSERT or BLOCK) */ - /* Set transformation for first (index 0) level */ - Trans[0].dx = Trans[0].dy = Trans[0].dz = 0; - Trans[0].xscale = Trans[0].yscale = Trans[0].zscale = 1; - Trans[0].rotang = 0; - if (adGetBlockHandle(dwghandle, pspace, AD_PAPERSPACE_HANDLE)) { - entlist = adEntityList(dwghandle, pspace); - adStartEntityGet(entlist); - for (entset = 0; entset < 2; entset++) { - do { - if (!(retval = adGetEntity(entlist, adenhd, aden))) - continue; - wrentity(adenhd, aden, 0, entlist, circle_flag->answer); - } while (retval == 1); - if (entset == 0) { - if (adGetBlockHandle(dwghandle, mspace, AD_MODELSPACE_HANDLE)) { - entlist = adEntityList(dwghandle, mspace); - adStartEntityGet(entlist); - } - } - } - } - - db_commit_transaction(driver); - db_close_database_shutdown_driver(driver); - - adCloseFile(dwghandle); - adCloseAd2(); - - Vect_build(&Map, stderr); - Vect_close(&Map); - - if (n_skipped > 0) - G_message(_("%d elements skipped (layer name was not in list)"), - n_skipped); - - G_done_msg(_("%d elements processed"), n_elements); - - exit(EXIT_SUCCESS); -} diff --git a/vector/v.in.dwg/v.in.dwg.html b/vector/v.in.dwg/v.in.dwg.html deleted file mode 100644 index 60f00966f9d..00000000000 --- a/vector/v.in.dwg/v.in.dwg.html +++ /dev/null @@ -1,32 +0,0 @@ -

      DESCRIPTION

      - -v.in.dwg imports DWG/DXF file into GRASS. - -

      EXAMPLE

      - -
      -v.in.dwg input=map.dwg output=map
      -
      - -

      NOTES

      - -v.in.dwg requires OpenDWG toolkit. To get this toolkit you must become at -least "Associate Member" of OpenDWG Alliance (http://www.opendesign.com/). -

      The toolkit, for example ad27linx.tar, unpack in a directory -(e.g. /home/usr1/opendwg27) and use the related configure options -to tell GRASS about it: - -

      -   ./configure \
      -   ... \
      -   --with-opendwg \
      -   --with-opendwg-includes=/home/usr1/opendwg27 \
      -   --with-opendwg-libs=/home/usr1/opendwg27
      -
      - -Then you can compile this module. -

      Not all entity types are supported (warning printed). - -

      AUTHOR

      - -Radim Blazek, ITC-Irst, Trento, Italy diff --git a/vector/v.in.dxf/v.in.dxf.html b/vector/v.in.dxf/v.in.dxf.html index 85d05623344..a08d2fbb5ee 100644 --- a/vector/v.in.dxf/v.in.dxf.html +++ b/vector/v.in.dxf/v.in.dxf.html @@ -45,7 +45,7 @@

      DESCRIPTION

      REFERENCES

      -AutoCad DXF (from Wikipedia, the free encyclopedia)
      +AutoCad DXF (from Wikipedia, the free encyclopedia)
      DXF References (Autodesk-supplied documentation)

      SEE ALSO

      diff --git a/vector/v.in.ogr/dsn.c b/vector/v.in.ogr/dsn.c index 2fecff7e9fb..7e483e71050 100644 --- a/vector/v.in.ogr/dsn.c +++ b/vector/v.in.ogr/dsn.c @@ -38,7 +38,7 @@ char *get_datasource_name(const char *opt_dsn, int use_ogr) /* add db.login settings (user, password, host, port) */ if (DB_OK == - db_get_login2("pg", database, &user, &passwd, &host, &port)) { + db_get_login("pg", database, &user, &passwd, &host, &port)) { if (user) { if (!G_strcasestr(opt_dsn, "user=")) { strcat(connect_str, " user="); diff --git a/vector/v.in.ogr/testsuite/test_v_in_ogr.py b/vector/v.in.ogr/testsuite/test_v_in_ogr.py index 167cd8747e8..31d2ef7ef3b 100644 --- a/vector/v.in.ogr/testsuite/test_v_in_ogr.py +++ b/vector/v.in.ogr/testsuite/test_v_in_ogr.py @@ -4,7 +4,6 @@ """ from grass.gunittest.case import TestCase -from grass.gunittest.gmodules import SimpleModule class TestOgrImport(TestCase): diff --git a/vector/v.kernel/main.c b/vector/v.kernel/main.c index 96198a4d8f7..c1e7f77a36a 100644 --- a/vector/v.kernel/main.c +++ b/vector/v.kernel/main.c @@ -769,7 +769,9 @@ double compute_all_net_distances(struct Map_info *In, struct Map_info *Net, G_debug(3, " kk = %d", kk); } } - + Vect_destroy_line_struct(APoints); + Vect_destroy_line_struct(BPoints); + Vect_destroy_boxlist(List); return (kk); } diff --git a/vector/v.kernel/v.kernel.html b/vector/v.kernel/v.kernel.html index c2bd14c87b5..3a5a0162129 100644 --- a/vector/v.kernel/v.kernel.html +++ b/vector/v.kernel/v.kernel.html @@ -2,7 +2,7 @@

      DESCRIPTION

      v.kernel generates a raster density map from vector points data using a moving -kernel. Available kernel +kernel. Available kernel density functions are uniform, triangular, epanechnikov, quartic, triweight, gaussian, cosine, default is gaussian. @@ -20,7 +20,7 @@

      NOTES

      (integer). The density result stored as category may be multiplied by this number.

      For the gaussian kernel, standard deviation for the -gaussian function +gaussian function is set to 1/4 of the radius.

      With the -o flag (experimental) the command tries to calculate an @@ -54,7 +54,7 @@

      REFERENCES

      method for networks, its computational method and a GIS-based tool. International Journal of Geographical Information Science, Vol 23(1), pp. 7-32.
      -DOI: 10.1080/13658810802475491 +DOI: 10.1080/13658810802475491

    SEE ALSO

    diff --git a/vector/v.label.sa/v.label.sa.html b/vector/v.label.sa/v.label.sa.html index 65864c78a2e..2376c70771c 100644 --- a/vector/v.label.sa/v.label.sa.html +++ b/vector/v.label.sa/v.label.sa.html @@ -41,7 +41,7 @@

    SEE ALSO

    d.label
    d.labels
    ps.map -Wikipedia article on simulated annealing +Wikipedia article on simulated annealing

    AUTHOR

    diff --git a/vector/v.net.bridge/v.net.bridge.html b/vector/v.net.bridge/v.net.bridge.html index fedb0559d6c..accd2484a33 100644 --- a/vector/v.net.bridge/v.net.bridge.html +++ b/vector/v.net.bridge/v.net.bridge.html @@ -8,8 +8,8 @@

    NOTES

    the (sub-)network. A node is an articulation point if its removal would disconnect the (sub-)network. For more information and formal definitions check the wikipedia entries: -bridge -and articulation +bridge +and articulation point.

    The output of the module contains the selected diff --git a/vector/v.net.centrality/v.net.centrality.html b/vector/v.net.centrality/v.net.centrality.html index bd122149d34..28871b660e3 100644 --- a/vector/v.net.centrality/v.net.centrality.html +++ b/vector/v.net.centrality/v.net.centrality.html @@ -9,7 +9,7 @@

    NOTES

    stores them in the given columns of an attribute table, which is created and linked to the output map. For the description of these, please check the following -wikipedia article. +wikipedia article. If the column name is not given for a measure then that measure is not computed. If -a flag is set then points are added on nodes without points. Also, the points for which the output is computed diff --git a/vector/v.net.flow/v.net.flow.html b/vector/v.net.flow/v.net.flow.html index 66a617cb0e6..9a15c95301e 100644 --- a/vector/v.net.flow/v.net.flow.html +++ b/vector/v.net.flow/v.net.flow.html @@ -23,7 +23,7 @@

    NOTES

    flowing in the backward direction. Cut map contains the edges in the minimum cut.
    -A famous result +A famous result says that the total amount of water flowing is equal to the minimum cut. diff --git a/vector/v.net.timetable/main.c b/vector/v.net.timetable/main.c index 5fb382009bb..424d8a851bd 100644 --- a/vector/v.net.timetable/main.c +++ b/vector/v.net.timetable/main.c @@ -176,9 +176,7 @@ void write_subroute(struct segment *seg, struct line_pnts *line, int line_id) struct line_cats *Cats; struct ilist *list; - Points = Vect_new_line_struct(); Cats = Vect_new_cats_struct(); - list = Vect_new_list(); r = seg->route; Vect_cat_set(Cats, 2, line_id); @@ -188,6 +186,9 @@ void write_subroute(struct segment *seg, struct line_pnts *line, int line_id) return; } + Points = Vect_new_line_struct(); + list = Vect_new_list(); + for (i = 0; i < nnodes; i++) edges[i] = 0; for (i = 0; i < lines[r]->n_values; i++) diff --git a/vector/v.net/testsuite/test_v_net.py b/vector/v.net/testsuite/test_v_net.py index 469ac127f47..50bb047628f 100644 --- a/vector/v.net/testsuite/test_v_net.py +++ b/vector/v.net/testsuite/test_v_net.py @@ -6,10 +6,10 @@ class TestVNet(TestCase): network = "test_vnet" - def tearDown(cls): + def tearDown(self): """Remove viewshed map after each test method""" # TODO: eventually, removing maps should be handled through testing framework functions - cls.runModule("g.remove", flags="f", type="vector", name=cls.network) + self.runModule("g.remove", flags="f", type="vector", name=self.network) def test_nodes(self): """Test""" diff --git a/vector/v.net/v.net.html b/vector/v.net/v.net.html index ab112155589..baef25e5484 100644 --- a/vector/v.net/v.net.html +++ b/vector/v.net/v.net.html @@ -154,7 +154,7 @@

    NOTES

    EXAMPLES

    -The examples are North Carolina dataset based. +The examples are North Carolina dataset based.

    Create nodes globally for all line ends and intersections

    diff --git a/vector/v.out.ascii/v.out.ascii.html b/vector/v.out.ascii/v.out.ascii.html index 2eff87a01fa..d8b6440b1c7 100644 --- a/vector/v.out.ascii/v.out.ascii.html +++ b/vector/v.out.ascii/v.out.ascii.html @@ -109,7 +109,7 @@

    Point mode

    WKT mode

    WKT is abbreviation -for Well-known +for Well-known text.
    diff --git a/vector/v.out.dxf/v.out.dxf.html b/vector/v.out.dxf/v.out.dxf.html
    index 853e19472bd..95057f05f22 100644
    --- a/vector/v.out.dxf/v.out.dxf.html
    +++ b/vector/v.out.dxf/v.out.dxf.html
    @@ -12,7 +12,7 @@ 

    NOTES

    REFERENCES

    -AutoCad DXF (from Wikipedia, the free encyclopedia) +AutoCad DXF (from Wikipedia, the free encyclopedia)

    SEE ALSO

    diff --git a/vector/v.out.lidar/testsuite/test_v_out_lidar.py b/vector/v.out.lidar/testsuite/test_v_out_lidar.py index 9be4f57d3b6..613cb14b61a 100644 --- a/vector/v.out.lidar/testsuite/test_v_out_lidar.py +++ b/vector/v.out.lidar/testsuite/test_v_out_lidar.py @@ -12,6 +12,7 @@ import os from grass.gunittest.case import TestCase from grass.gunittest.main import test +from grass.gunittest.utils import xfail_windows class BasicTest(TestCase): @@ -60,6 +61,7 @@ def test_module_runs_output_created(self): self.assertModule("v.out.lidar", input=self.vector_points, output=self.las_file) self.assertFileExists(self.las_file) + @xfail_windows def test_output_identical(self): """Test to see if the standard outputs are created diff --git a/vector/v.out.ogr/dsn.c b/vector/v.out.ogr/dsn.c index 31d258c05c7..bd7ce101ed2 100644 --- a/vector/v.out.ogr/dsn.c +++ b/vector/v.out.ogr/dsn.c @@ -37,7 +37,7 @@ char *get_datasource_name(const char *opt_dsn, int use_ogr) /* add db.login settings (user, password, host, port) */ if (DB_OK == - db_get_login2("pg", database, &user, &passwd, &host, &port)) { + db_get_login("pg", database, &user, &passwd, &host, &port)) { if (user) { if (!G_strcasestr(opt_dsn, "user=")) { strcat(connect_str, " user="); diff --git a/vector/v.out.ogr/v.out.ogr.html b/vector/v.out.ogr/v.out.ogr.html index d9a2c84049b..664a5c35a1a 100644 --- a/vector/v.out.ogr/v.out.ogr.html +++ b/vector/v.out.ogr/v.out.ogr.html @@ -1,27 +1,27 @@

    DESCRIPTION

    v.out.ogr converts GRASS vector map layer to any of the -supported OGR vector formats +supported OGR vector formats (including OGC GeoPackage, ESRI Shapefile, SpatiaLite or GML).

    OGR (Simple Features Library) is part of the -GDAL library, so you need to +GDAL library, so you need to install this library to use v.out.ogr.

    The OGR library supports many various formats including:

    @@ -193,7 +193,7 @@

    Export to KML (Google Earth)

    REFERENCES

    diff --git a/vector/v.out.postgis/v.out.postgis.html b/vector/v.out.postgis/v.out.postgis.html index 104a9ad2dae..aa9bd459778 100644 --- a/vector/v.out.postgis/v.out.postgis.html +++ b/vector/v.out.postgis/v.out.postgis.html @@ -65,8 +65,8 @@

    NOTES

    "geom". Name of the geometry column can be changed by options=GEOMETRY_NAME=<column>. Note that for exporting vector features as simple features can be alternatively -used PostgreSQL driver -from OGR library +used PostgreSQL driver +from OGR library through v.out.ogr module.

    diff --git a/vector/v.out.svg/main.c b/vector/v.out.svg/main.c index 4c99d148d04..4d29f845b29 100644 --- a/vector/v.out.svg/main.c +++ b/vector/v.out.svg/main.c @@ -25,7 +25,7 @@ #define SVG_NS "http://www.w3.org/2000/svg" #define XLINK_NS "http://www.w3.org/1999/xlink" -#define GRASS_NS "http:/grass.itc.it/2006/gg" +#define GRASS_NS "http://grass.itc.it/2006/gg" #define RADIUS_SCALE .003 #define WIDTH_SCALE .001 #define G_Areas "G_Areas" diff --git a/vector/v.outlier/v.outlier.html b/vector/v.outlier/v.outlier.html index 3cd3ee46a5a..7e615364916 100644 --- a/vector/v.outlier/v.outlier.html +++ b/vector/v.outlier/v.outlier.html @@ -13,12 +13,12 @@

    DESCRIPTION

    (default), or only positive or only negative outliers. Filtering out only positive outliers can be useful to filter out vegetation returns (e.g. from forest canopies) from LIDAR point clouds, in order to -extract Digital Terrain Models. Filtering out only negative outliers +extract digital terrain models (DTMs). Filtering out only negative outliers can be useful to estimate vegetation height.

    -There is a flag to create a vector that can be visualizated by -qgis. That means that topology is build and the z coordinate is +There is a flag to create a vector that can be visualized in +QGIS. That means that topology is built and the z coordinate is considered as a category.

    EXAMPLES

    diff --git a/vector/v.overlay/v.overlay.html b/vector/v.overlay/v.overlay.html index 2b2a35be8c8..0077f2915f5 100644 --- a/vector/v.overlay/v.overlay.html +++ b/vector/v.overlay/v.overlay.html @@ -97,7 +97,7 @@

    AND operator

    v.overlay with AND operator
    -Figure: v.overlay with AND operator (selected polygons in grey color) +Figure: v.overlay with AND operator (selected polygons in yellow color)

    OR operator

    @@ -113,7 +113,7 @@

    OR operator

    v.overlay with OR operator
    -Figure: v.overlay with OR operator (selected polygons in grey color) +Figure: v.overlay with OR operator (selected polygons in yellow color)

    XOR operator

    @@ -129,7 +129,7 @@

    XOR operator

    v.overlay with XOR operator
    -Figure: v.overlay with XOR operator (selected polygons in grey color) +Figure: v.overlay with XOR operator (selected polygons in yellow color)

    NOT operator

    @@ -145,7 +145,7 @@

    NOT operator

    v.overlay with NOT operator
    -Figure: v.overlay with NOT operator (selected polygon in grey color) +Figure: v.overlay with NOT operator (selected polygon in yellow color)

    Overlay operations: AND, OR, NOT, XOR

    diff --git a/vector/v.overlay/v_overlay_op_and.png b/vector/v.overlay/v_overlay_op_and.png index 3d4bb3a07ff..c545f2140ad 100644 Binary files a/vector/v.overlay/v_overlay_op_and.png and b/vector/v.overlay/v_overlay_op_and.png differ diff --git a/vector/v.overlay/v_overlay_op_not.png b/vector/v.overlay/v_overlay_op_not.png index ac7eb441bbc..2c903f22d60 100644 Binary files a/vector/v.overlay/v_overlay_op_not.png and b/vector/v.overlay/v_overlay_op_not.png differ diff --git a/vector/v.overlay/v_overlay_op_or.png b/vector/v.overlay/v_overlay_op_or.png index c19bd32ce9f..bbde7b06eb1 100644 Binary files a/vector/v.overlay/v_overlay_op_or.png and b/vector/v.overlay/v_overlay_op_or.png differ diff --git a/vector/v.overlay/v_overlay_op_xor.png b/vector/v.overlay/v_overlay_op_xor.png index 446624f36ec..bf5bd5b8e45 100644 Binary files a/vector/v.overlay/v_overlay_op_xor.png and b/vector/v.overlay/v_overlay_op_xor.png differ diff --git a/vector/v.random/testsuite/test_v_random.py b/vector/v.random/testsuite/test_v_random.py index e5cc95a93db..7b68434f46b 100644 --- a/vector/v.random/testsuite/test_v_random.py +++ b/vector/v.random/testsuite/test_v_random.py @@ -30,9 +30,10 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - def tearDown(cls): - cls.runModule("g.remove", type="vector", flags="f", name=cls.output) - cls.runModule("g.remove", type="vector", flags="f", name=cls.output2) + def tearDown(self): + self.runModule( + "g.remove", type="vector", flags="f", name=(self.output, self.output2) + ) def test_num_points(self): """Checking if number of points equals 100""" diff --git a/vector/v.reclass/reclass.c b/vector/v.reclass/reclass.c index 5af40e5473e..4300f4216ff 100644 --- a/vector/v.reclass/reclass.c +++ b/vector/v.reclass/reclass.c @@ -79,6 +79,9 @@ int reclass(struct Map_info *In, struct Map_info *Out, int type, int field, G_warning("For %d elements requested negative category (ignored, no " "category in output)", negative); + Vect_destroy_cats_struct(Cats); + Vect_destroy_cats_struct(NewCats); + Vect_destroy_line_struct(Points); return (rclelem); } diff --git a/vector/v.rectify/main.c b/vector/v.rectify/main.c index b02630c88ae..86999d6286d 100644 --- a/vector/v.rectify/main.c +++ b/vector/v.rectify/main.c @@ -126,7 +126,9 @@ int main(int argc, char *argv[]) if (grp->answer) { G_strip(grp->answer); - strcpy(group, grp->answer); + if (G_strlcpy(group, grp->answer, sizeof(group)) >= sizeof(group)) { + G_fatal_error(_("Group name <%s> is too long"), grp->answer); + } } else group[0] = '\0'; diff --git a/vector/v.select/testsuite/test_v_select.py b/vector/v.select/testsuite/test_v_select.py index c74cdb53761..c72aac8c4cc 100644 --- a/vector/v.select/testsuite/test_v_select.py +++ b/vector/v.select/testsuite/test_v_select.py @@ -13,25 +13,12 @@ class TestRasterReport(TestCase): - binput = "bridges" + binput = "zipcodes" ainput = "geology" output = "testvselect" - overlap = "geonames_wake" - disjoint = "schools_wake" - equals = "streets_wake" - touches = "zipcodes_wake" - within = "geonames_wake" - @classmethod - def setUpClass(cls): - cls.use_temp_region() - - @classmethod - def tearDownClass(cls): - cls.del_temp_region() - - def tearDown(cls): - cls.runModule("g.remove", type="vector", flags="f", name=cls.output) + def tearDown(self): + self.runModule("g.remove", type="vector", flags="f", name=self.output) def test_opo(self): """Testing operator overlap""" @@ -42,8 +29,8 @@ def test_opo(self): output=self.output, operator="overlap", ) - topology = {"points": 1088, "lines": 0, "areas": 0} - self.assertVectorFitsTopoInfo(self.overlap, topology) + topology = {"areas": 97} + self.assertVectorFitsTopoInfo(self.output, topology) def test_opd(self): """Testign operator disjoint""" @@ -54,8 +41,8 @@ def test_opd(self): output=self.output, operator="disjoint", ) - topology = {"points": 167, "lines": 0, "areas": 0} - self.assertVectorFitsTopoInfo(self.disjoint, topology) + topology = {"areas": 1770} + self.assertVectorFitsTopoInfo(self.output, topology) def test_ope(self): """Testing operator equals""" @@ -66,8 +53,7 @@ def test_ope(self): output=self.output, operator="equals", ) - topology = {"points": 0, "lines": 49746, "areas": 0} - self.assertVectorFitsTopoInfo(self.equals, topology) + self.assertVectorDoesNotExist(self.output) def test_opt(self): """Testing operator touches""" @@ -78,8 +64,7 @@ def test_opt(self): output=self.output, operator="touches", ) - topology = {"points": 0, "lines": 0, "areas": 48} - self.assertVectorFitsTopoInfo(self.touches, topology) + self.assertVectorDoesNotExist(self.output) def test_opw(self): """Testing operator within""" @@ -90,8 +75,8 @@ def test_opw(self): output=self.output, operator="within", ) - topology = {"points": 1088, "lines": 0, "areas": 0} - self.assertVectorFitsTopoInfo(self.within, topology) + topology = {"areas": 17} + self.assertVectorFitsTopoInfo(self.output, topology) if __name__ == "__main__": diff --git a/vector/v.surf.rst/Makefile b/vector/v.surf.rst/Makefile index 3b5d8eca836..414ebbd85a0 100644 --- a/vector/v.surf.rst/Makefile +++ b/vector/v.surf.rst/Makefile @@ -4,9 +4,9 @@ PGM=v.surf.rst EXTRA_CLEAN_DIRS=doxygenhtml -LIBES = $(INTERPFLLIB) $(QTREELIB) $(INTERPDATALIB) $(GMATHLIB) $(VECTORLIB) $(DBMILIB) $(GISLIB) $(MATHLIB) +LIBES = $(INTERPFLLIB) $(QTREELIB) $(INTERPDATALIB) $(GMATHLIB) $(RASTERLIB) $(VECTORLIB) $(DBMILIB) $(GISLIB) $(MATHLIB) EXTRA_LIBS = $(OPENMP_LIBPATH) $(OPENMP_LIB) -DEPENDENCIES = $(INTERPFLDEP) $(QTREEDEP) $(INTERPDATADEP) $(GMATHDEP) $(VECTORDEP) $(DBMIDEP) $(GISDEP) +DEPENDENCIES = $(INTERPFLDEP) $(QTREEDEP) $(INTERPDATADEP) $(GMATHDEP) $(RASTERDEP) $(VECTORDEP) $(DBMIDEP) $(GISDEP) EXTRA_INC = $(VECT_INC) $(OPENMP_INCPATH) EXTRA_CFLAGS = $(VECT_CFLAGS) $(OPENMP_CFLAGS) diff --git a/vector/v.surf.rst/benchmark/benchmark_v_surf_rst.py b/vector/v.surf.rst/benchmark/benchmark_v_surf_rst.py index 91fd784e0b3..ac69b441010 100644 --- a/vector/v.surf.rst/benchmark/benchmark_v_surf_rst.py +++ b/vector/v.surf.rst/benchmark/benchmark_v_surf_rst.py @@ -36,8 +36,7 @@ def benchmark(size, label, results): ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=8, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=output) + Module("g.remove", quiet=True, flags="f", type="raster", name=(reference, output)) def generate_map(npoints, rows, cols, fname): diff --git a/vector/v.surf.rst/benchmark/benchmark_v_surf_rst_cv.py b/vector/v.surf.rst/benchmark/benchmark_v_surf_rst_cv.py index 21a3c7459eb..f140ee67b8a 100644 --- a/vector/v.surf.rst/benchmark/benchmark_v_surf_rst_cv.py +++ b/vector/v.surf.rst/benchmark/benchmark_v_surf_rst_cv.py @@ -37,8 +37,7 @@ def benchmark(size, label, results): ) results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=8, repeat=3)) - Module("g.remove", quiet=True, flags="f", type="raster", name=reference) - Module("g.remove", quiet=True, flags="f", type="raster", name=output) + Module("g.remove", quiet=True, flags="f", type="raster", name=(reference, output)) def generate_map(npoints, rows, cols, fname): diff --git a/vector/v.surf.rst/main.c b/vector/v.surf.rst/main.c index c4581737eed..7b42e269d0f 100644 --- a/vector/v.surf.rst/main.c +++ b/vector/v.surf.rst/main.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -419,8 +420,8 @@ int main(int argc, char *argv[]) G_warning(_("GRASS GIS is not compiled with OpenMP support, parallel " "computation is disabled.")); #endif - if (threads > 1 && G_find_raster("MASK", G_mapset()) != NULL) { - G_warning(_("Parallel processing disabled due to active MASK.")); + if (threads > 1 && Rast_mask_is_present()) { + G_warning(_("Parallel processing disabled due to active mask.")); threads = 1; } if (devi) { diff --git a/vector/v.surf.rst/v.surf.rst.html b/vector/v.surf.rst/v.surf.rst.html index 66a39ebc6f8..199ca4fc3ca 100644 --- a/vector/v.surf.rst/v.surf.rst.html +++ b/vector/v.surf.rst/v.surf.rst.html @@ -389,7 +389,7 @@

    REFERENCES

  • Mitas, L., and Mitasova H., 1988, General variational approach to the approximation problem, Computers and Mathematics with Applications, v.16, p. 983-992.
  • -
  • +
  • Neteler, M. and Mitasova, H., 2008, Open Source GIS: A GRASS GIS Approach, 3rd Edition, Springer, New York, 406 pages.
  • Talmi, A. and Gilat, G., 1977 : Method for Smooth Approximation of Data, diff --git a/vector/v.to.3d/testsuite/test_vto3d.py b/vector/v.to.3d/testsuite/test_vto3d.py index bfa982ddd87..2297ec3a174 100644 --- a/vector/v.to.3d/testsuite/test_vto3d.py +++ b/vector/v.to.3d/testsuite/test_vto3d.py @@ -15,10 +15,13 @@ def setUpClass(cls): def tearDownClass(cls): cls.del_temp_region() - def tearDown(cls): + def tearDown(self): """Remove contours map after each test method""" - cls.runModule( - "g.remove", flags="f", type="vector", name=[cls.contours2d, cls.contours3d] + self.runModule( + "g.remove", + flags="f", + type="vector", + name=[self.contours2d, self.contours3d], ) def test_contours(self): diff --git a/vector/v.to.3d/trans2.c b/vector/v.to.3d/trans2.c index 1680d950117..c4bde9b3888 100644 --- a/vector/v.to.3d/trans2.c +++ b/vector/v.to.3d/trans2.c @@ -73,6 +73,7 @@ void trans2d(struct Map_info *In, struct Map_info *Out, int type, double height, G_debug(3, "%d records selected", cvarr.n_values); db_close_database_shutdown_driver(driver); + Vect_destroy_field_info(Fi); } G_message(_("Transforming features...")); diff --git a/vector/v.to.db/areas.c b/vector/v.to.db/areas.c index 0977890276e..232cc4894d6 100644 --- a/vector/v.to.db/areas.c +++ b/vector/v.to.db/areas.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "global.h" @@ -111,5 +112,6 @@ int read_areas(struct Map_info *Map) G_percent(area_num, nareas, 2); } + Vect_destroy_cats_struct(Cats); return 0; } diff --git a/vector/v.to.db/update.c b/vector/v.to.db/update.c index dd63ef78d35..972fd6be93e 100644 --- a/vector/v.to.db/update.c +++ b/vector/v.to.db/update.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "global.h" static int srch(const void *, const void *); @@ -297,6 +298,8 @@ int update(struct Map_info *Map) db_close_database_shutdown_driver(driver); db_free_string(&stmt); + Vect_destroy_field_info(Fi); + Vect_destroy_field_info(qFi); return 0; } diff --git a/vector/v.to.db/v.to.db.html b/vector/v.to.db/v.to.db.html index 99c2d5b3dbc..f0ba460d450 100644 --- a/vector/v.to.db/v.to.db.html +++ b/vector/v.to.db/v.to.db.html @@ -25,7 +25,7 @@

    NOTES

    all features of same category taken together.

    Line azimuth is calculated as angle from the North direction to the line endnode direction at the line statnode. By default it's reported in decimal degrees (0-360, CW) but -it also may be repored in radians with unit=radians. Azimuth value +it also may be reported in radians with unit=radians. Azimuth value -1 is used to report closed line with it's startnode and endnode being in same place. Azimuth values make sense only if every vector line has only one entry in database (unique CAT value). @@ -165,4 +165,4 @@

    SEE ALSO

    AUTHORS

    Radim Blazek, ITC-irst, Trento, Italy
    -Line sinuousity implemented by Wolf Bergenheim +Line sinuosity implemented by Wolf Bergenheim diff --git a/vector/v.transform/main.c b/vector/v.transform/main.c index 400cd3ded91..06a7d105881 100644 --- a/vector/v.transform/main.c +++ b/vector/v.transform/main.c @@ -188,8 +188,17 @@ int main(int argc, char *argv[]) if (G_parser(argc, argv)) exit(EXIT_FAILURE); - strcpy(Current.name, vold->answer); - strcpy(Trans.name, vnew->answer); + if (G_strlcpy(Current.name, vold->answer, sizeof(Current.name)) >= + sizeof(Current.name)) { + G_fatal_error(_("Input vector map name <%s> is too long"), + vold->answer); + } + + if (G_strlcpy(Trans.name, vnew->answer, sizeof(Trans.name)) >= + sizeof(Trans.name)) { + G_fatal_error(_("Output vector map name <%s> is too long"), + vnew->answer); + } Vect_check_input_output_name(vold->answer, vnew->answer, G_FATAL_EXIT); diff --git a/vector/v.type/v.type.html b/vector/v.type/v.type.html index 8e6d5806db8..124f8f39fe0 100644 --- a/vector/v.type/v.type.html +++ b/vector/v.type/v.type.html @@ -2,6 +2,27 @@

    DESCRIPTION

    v.type changes the type of geometry primitives. +

    +The following vector object types are defined in GRASS GIS: + +

      +
    • point: a point;
    • +
    • line: a directed sequence of connected vertices with two endpoints called nodes;
    • +
    • boundary: the border line describing an area;
    • +
    • centroid: a point within a closed ring of boundaries;
    • +
    • area: the topological composition of a closed ring of boundaries and a centroid;
    • +
    • face: a 3D area;
    • +
    • kernel: a 3D centroid in a volume (not yet implemented);
    • +
    • volume: a 3D corpus, the topological composition of faces and kernel (not yet implemented).
    • +
    +

    +Lines and boundaries can be composed of multiple vertices. +

    +Area topology also holds information about isles. These isles are located +within that area, not touching the boundaries of the outer area. Isles +are holes inside the area, and can consist of one or more areas. They are +used internally to maintain correct topology for areas. +

    EXAMPLES

    Convert lines to area boundaries
    diff --git a/vector/v.univar/main.c b/vector/v.univar/main.c index f84bf118fab..85217498035 100644 --- a/vector/v.univar/main.c +++ b/vector/v.univar/main.c @@ -19,7 +19,7 @@ /* TODO * - add flag to weigh by line/boundary length and area size * Roger Bivand on GRASS devel ml on July 2 2004 - * http://lists.osgeo.org/pipermail/grass-dev/2004-July/014976.html + * https://lists.osgeo.org/pipermail/grass-dev/2004-July/014976.html * "[...] calculating weighted means, weighting by line length * or area surface size [does not make sense]. I think it would be * better to treat each line or area as a discrete, unweighted, unit diff --git a/vector/v.univar/testsuite/test_v_univar.py b/vector/v.univar/testsuite/test_v_univar.py index 766871d951c..e5fc2685cac 100644 --- a/vector/v.univar/testsuite/test_v_univar.py +++ b/vector/v.univar/testsuite/test_v_univar.py @@ -15,9 +15,11 @@ from grass.gunittest.case import TestCase from grass.gunittest.main import test from grass.gunittest.gmodules import SimpleModule +from grass.gunittest.utils import xfail_windows class TestProfiling(TestCase): + @xfail_windows def test_flagg(self): """Testing flag g with map lakes""" output_str = """n=15279 @@ -40,6 +42,7 @@ def test_flagg(self): v_univar.run() self.assertLooksLike(actual=v_univar.outputs.stdout, reference=output_str) + @xfail_windows def test_flage(self): """Testing flag e with map geology""" output_str = """number of features with non NULL attribute: 1832 @@ -68,6 +71,7 @@ def test_flage(self): v_univar.run() self.assertLooksLike(actual=v_univar.outputs.stdout, reference=output_str) + @xfail_windows def test_flagw(self): """Testing flag w with map lakes""" output_str = """number of features with non NULL attribute: 15279 @@ -83,6 +87,7 @@ def test_flagw(self): v_univar.run() self.assertLooksLike(actual=v_univar.outputs.stdout, reference=output_str) + @xfail_windows def test_flagd(self): """Testing flag d with map hospitals""" univar_string = """number of primitives: 160 diff --git a/vector/v.vect.stats/testsuite/test_vect_stats.py b/vector/v.vect.stats/testsuite/test_vect_stats.py index fe982ceff33..e8a1c30c966 100644 --- a/vector/v.vect.stats/testsuite/test_vect_stats.py +++ b/vector/v.vect.stats/testsuite/test_vect_stats.py @@ -5,8 +5,8 @@ Author: Sunveer Singh, Google Code-in 2017 Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team Licence: This program is free software under the GNU General Public - License (>=v2). Read the file COPYING that comes with GRASS - for details. + License (>=v2). Read the file COPYING that comes with GRASS + for details. """ from grass.gunittest.case import TestCase diff --git a/vector/v.vol.rst/user1.c b/vector/v.vol.rst/user1.c index f47324dff36..6a1c2f441e6 100644 --- a/vector/v.vol.rst/user1.c +++ b/vector/v.vol.rst/user1.c @@ -220,6 +220,7 @@ int INPUT(struct Map_info *In, char *column, char *scol, char *wheresql) if (a < 0) { G_warning(_("Can't insert %lf,%lf,%lf,%lf,%lf a=%d"), x, y, z, w, sm, a); + Vect_destroy_field_info(Fi); return -1; } @@ -322,6 +323,7 @@ int INPUT(struct Map_info *In, char *column, char *scol, char *wheresql) } else { fprintf(stderr, "ERROR: zero points in the given region!\n"); + Vect_destroy_field_info(Fi); return -1; } } @@ -332,6 +334,7 @@ int INPUT(struct Map_info *In, char *column, char *scol, char *wheresql) KMIN, KMAX); fprintf(stderr, "for smooth connection of segments, npmin > segmax " "(see manual) \n"); + Vect_destroy_field_info(Fi); return -1; } @@ -382,6 +385,7 @@ int INPUT(struct Map_info *In, char *column, char *scol, char *wheresql) } G_message(_("Bitmap mask created")); } + Vect_destroy_field_info(Fi); return 1; } diff --git a/vector/v.vol.rst/v.vol.rst.html b/vector/v.vol.rst/v.vol.rst.html index 06fc55e5118..571a162162c 100644 --- a/vector/v.vol.rst/v.vol.rst.html +++ b/vector/v.vol.rst/v.vol.rst.html @@ -85,7 +85,7 @@

    Cross validation procedure

    representing the whole dataset.

    Example - (based on Slovakia3d dataset): + (based on Slovakia3d dataset):

     v.info -c precip3d
     g.region n=5530000 s=5275000 w=4186000 e=4631000 res=500 -p
    diff --git a/vector/v.voronoi/v.voronoi.html b/vector/v.voronoi/v.voronoi.html
    index 0b2c9e4cd40..e719c2c0038 100644
    --- a/vector/v.voronoi/v.voronoi.html
    +++ b/vector/v.voronoi/v.voronoi.html
    @@ -82,7 +82,7 @@ 

    REFERENCES

    Steve J. Fortune, (1987). A Sweepline Algorithm for Voronoi Diagrams, Algorithmica 2, 153-174 - (DOI). + (DOI).

    SEE ALSO

  • FailedPercent successful