pax_global_header 0000666 0000000 0000000 00000000064 15103317517 0014515 g ustar 00root root 0000000 0000000 52 comment=ceeefd4aa1a2dd2244d76b172114c5ddcda7fa74
gdal-grass-2.0.0/ 0000775 0000000 0000000 00000000000 15103317517 0013540 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/.clang-format 0000664 0000000 0000000 00000003770 15103317517 0016122 0 ustar 00root root 0000000 0000000 ---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [foreach, Q_FOREACH, BOOST_FOREACH]
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 1000000000
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
ReflowComments: false
SortIncludes: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
---
Language: Json
BasedOnStyle: llvm
gdal-grass-2.0.0/.git-blame-ignore-revs 0000664 0000000 0000000 00000000051 15103317517 0017634 0 ustar 00root root 0000000 0000000 8e7529a0ba0735ff6bab9e8e67439ad22238bcf3
gdal-grass-2.0.0/.github/ 0000775 0000000 0000000 00000000000 15103317517 0015100 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/.github/how_to_release.md 0000664 0000000 0000000 00000001412 15103317517 0020417 0 ustar 00root root 0000000 0000000 # How to release gdal-grass
1. Release tag must be created on CLI (letting GitHub create the tag in
connection with with GH online publish will **not** create and archive
the release files):
```bash
git switch main
git pull
git status
# Set version, do not forget!
version="x.y.z"
# Assuming 'upstream' points to the OSGeo fork
commit=$(git rev-parse HEAD)
tag_message="gdal-grass ${version}"
git tag -a -m "${tag_message}" $version $commit
git push --tags upstream
```
2. Create a new release on GH, based on the above created tag. "Publish release"
will activate the *publish.yml* workflow, which will create and add the
packages to the release.
3. Transfer the packaged files to .
gdal-grass-2.0.0/.github/workflows/ 0000775 0000000 0000000 00000000000 15103317517 0017135 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/.github/workflows/apt.txt 0000664 0000000 0000000 00000000072 15103317517 0020461 0 ustar 00root root 0000000 0000000 gdal-bin
grass
grass-dev
libgdal-dev
libpq-dev
pkg-config
gdal-grass-2.0.0/.github/workflows/publish.yml 0000664 0000000 0000000 00000006370 15103317517 0021334 0 ustar 00root root 0000000 0000000 ---
name: Create or check a release draft
on:
push:
branches:
- main
tags:
- '**'
pull_request:
branches:
- main
paths:
- .github/**
- utils/**
env:
OUT_DIR: ${{ github.workspace }}/../g_outdir
GDAL-GRASS: gdal-grass-${{ github.ref_name }}
permissions:
contents: write
jobs:
build-n-publish:
name: Package and create release draft
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with:
python-version: '3.11'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install PyYAML
- name: Create output directory
run: |
mkdir ${{ env.OUT_DIR }}
- name: Generate ChangeLog file
run: |
lasttag=""
for tag in $(git tag -n --sort=-creatordate | cut -d' ' -f 1); do
if [[ ${{ github.ref_name }} != *"rc"* && $tag != *"rc"* && \
$tag != ${{ github.ref_name }} ]]
then
lasttag="$tag"
break
elif [[ $tag != ${{ github.ref_name }} && ${{ github.ref_name }} == *"rc"* ]]
then
lasttag="$tag"
break
fi
done
echo "Creating CHANGELOG since v$lasttag"
echo "$(python ./utils/generate_release_notes.py log main \
$lasttag ${{ github.ref_name }})" >> ${{ env.OUT_DIR }}/CHANGELOG
- name: Create tarballs (for tags only)
if: startsWith(github.ref, 'refs/tags/')
run: |
cd ..
tar -cvf ${{ env.OUT_DIR }}/${{ env.GDAL-GRASS }}.tar --exclude=".g*" \
--transform s/gdal-grass/${{ env.GDAL-GRASS }}/ gdal-grass
cd ${{ env.OUT_DIR }}
gzip -9k ${{ env.GDAL-GRASS }}.tar
md5sum ${{ env.GDAL-GRASS }}.tar.gz > ${{ env.GDAL-GRASS }}.tar.gz.md5
sha256sum ${{ env.GDAL-GRASS }}.tar.gz > ${{ env.GDAL-GRASS }}.tar.gz.sha256
xz -9e ${{ env.GDAL-GRASS }}.tar
md5sum ${{ env.GDAL-GRASS }}.tar.xz > ${{ env.GDAL-GRASS }}.tar.xz.md5
sha256sum ${{ env.GDAL-GRASS }}.tar.xz > ${{ env.GDAL-GRASS }}.tar.xz.sha256
- name: Publish draft release to GitHub (for tags only)
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1
with:
name: GDAL-GRASS GIS driver ${{ github.ref_name }}
body_path: ${{ env.OUT_DIR }}/CHANGELOG
draft: true
prerelease: ${{ contains(github.ref, 'RC') }}
files: |
${{ env.OUT_DIR }}/${{ env.GDAL-GRASS }}.tar.gz
${{ env.OUT_DIR }}/${{ env.GDAL-GRASS }}.tar.gz.md5
${{ env.OUT_DIR }}/${{ env.GDAL-GRASS }}.tar.gz.sha256
${{ env.OUT_DIR }}/${{ env.GDAL-GRASS }}.tar.xz
${{ env.OUT_DIR }}/${{ env.GDAL-GRASS }}.tar.xz.md5
${{ env.OUT_DIR }}/${{ env.GDAL-GRASS }}.tar.xz.sha256
gdal-grass-2.0.0/.github/workflows/test_simple.sh 0000775 0000000 0000000 00000001070 15103317517 0022022 0 ustar 00root root 0000000 0000000 #!/usr/bin/env bash
# fail on non-zero return code from a subprocess
set -e
# print commands
set -x
if [ -z "$1" ]; then
echo "Usage: $0 GDAL_AUTOLOAD_DIR"
exit 1
fi
# non-existent variables as an errors
set -u
export GDAL_DRIVER_PATH=$1
# Using LD_LIBRARY_PATH workaround for GRASS GIS < 7.8.8
export LD_LIBRARY_PATH=$(grass --config path)/lib
# test GRASS GIS raster map
gdalinfo $HOME/grassdata/nc_spm_08_micro/PERMANENT/cellhd/elevation
# test GRASS GIS vector map
ogrinfo -so -al $HOME/grassdata/nc_spm_08_micro/PERMANENT/vector/firestations/head
gdal-grass-2.0.0/.github/workflows/ubuntu.yml 0000664 0000000 0000000 00000003643 15103317517 0021210 0 ustar 00root root 0000000 0000000 ---
name: Build on Ubuntu
on:
- push
- pull_request
env:
GDAL_AUTOLOAD_CMAKE_DIR: $HOME/gdalplugins_cmake
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v5
- name: Get dependencies
run: |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update -y
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
- name: Setup test data
run: |
mkdir -p $HOME/grassdata
cd $HOME/grassdata/
wget -c --quiet https://grass.osgeo.org/sampledata/north_carolina/nc_spm_08_micro.zip
unzip nc_spm_08_micro.zip
rm -f nc_spm_08_micro.zip
- name: Create GDAL_AUTOLOAD directory for CMake
run: |
mkdir ${{ env.GDAL_AUTOLOAD_CMAKE_DIR }}
- name: Set up Python for tests
uses: actions/setup-python@v6
with:
python-version: 3.11
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-env pytest-sugar gdal==3.6.4
- name: CMake configure
run: |
cmake -B build -DAUTOLOAD_DIR=${{ env.GDAL_AUTOLOAD_CMAKE_DIR }}
- name: CMake build
run: |
cmake --build build
- name: CTest
run: |
export GDAL_DRIVER_PATH=${GITHUB_WORKSPACE}/build
export LD_LIBRARY_PATH=$(grass --config path)/lib
cd build
ctest --output-on-failure
- name: Install with CMake
run: |
cmake --install build
- name: Test executing of GDAL with driver on GRASS maps (CMake)
run: |
.github/workflows/test_simple.sh ${{ env.GDAL_AUTOLOAD_CMAKE_DIR }}
gdal-grass-2.0.0/.gitignore 0000664 0000000 0000000 00000000174 15103317517 0015532 0 ustar 00root root 0000000 0000000 *~
*.log
*.o
*.so
*.dylib
# CMake files (CMakeSettings.json is generated by Visual Studio)
/build
CMakeSettings.json
*.pyc
gdal-grass-2.0.0/.pre-commit-config.yaml 0000664 0000000 0000000 00000001045 15103317517 0020021 0 ustar 00root root 0000000 0000000 ---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.44.0
hooks:
- id: markdownlint-fix
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v15.0.7
hooks:
- id: clang-format
types_or: [c, c++, javascript, json, objective-c]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
hooks:
- id: yamllint
gdal-grass-2.0.0/.yamllint 0000664 0000000 0000000 00000000352 15103317517 0015372 0 ustar 00root root 0000000 0000000 ---
extends: default
rules:
comments:
level: error
min-spaces-from-content: 1
document-start:
level: error
line-length:
level: error
max: 120
allow-non-breakable-inline-mappings: true
truthy: disable
gdal-grass-2.0.0/CMakeLists.txt 0000664 0000000 0000000 00000006611 15103317517 0016304 0 ustar 00root root 0000000 0000000 # SPDX-License-Identifier: MIT
# ##############################################################################
# CMake settings
cmake_minimum_required(VERSION 3.10.0)
set(CMAKE_COLOR_MAKEFILE ON)
# set path to additional CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ##############################################################################
# Project and version
set(CPACK_PACKAGE_VERSION_MAJOR "2")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(VERSION_SUFFIX "")
set(COMPLETE_VERSION
${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
)
set(RELEASE_NAME ${COMPLETE_VERSION}${VERSION_SUFFIX})
project(gdal-grass VERSION ${COMPLETE_VERSION})
message(STATUS "gdal-grass version ${RELEASE_NAME}")
include(CTest)
# ##############################################################################
# Dependencies and flags
find_package(GDAL REQUIRED)
find_package(GRASS REQUIRED)
find_package(PostgreSQL)
find_package(PROJ)
if(NOT AUTOLOAD_DIR)
execute_process(
COMMAND ${GDAL_CONFIG} --prefix
OUTPUT_VARIABLE GDALPREFIX
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(AUTOLOAD_DIR ${GDALPREFIX}/lib/gdalplugins)
if(NOT AUTOLOAD_DIR)
message(FATAL_ERROR "Could not set GDAL plugin path")
endif()
endif()
message(
STATUS "Using ${AUTOLOAD_DIR} as GDAL shared library autoload directory")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -DUSE_CPL -DGRASS_GISBASE=\\\"${GRASS_GISBASE}\\\"")
# ##############################################################################
# Build
set(GLIB_SOURCES source/grass.cpp)
set(OLIB_SOURCES source/ogrgrassdriver.cpp source/ogrgrassdatasource.cpp
source/ogrgrasslayer.cpp source/ogrgrass.h)
add_library(gdal_grass SHARED ${GLIB_SOURCES})
set_target_properties(gdal_grass PROPERTIES PREFIX "")
set_target_properties(gdal_grass PROPERTIES OUTPUT_NAME "gdal_GRASS")
set_target_properties(gdal_grass PROPERTIES INSTALL_RPATH "${GRASS_GISBASE}/lib")
target_include_directories(
gdal_grass PRIVATE ${CMAKE_SOURCE_DIR} ${GDAL_INCLUDE_DIR} ${PostgreSQL_INCLUDE_DIRS}
${GRASS_INCLUDE} ${PROJ_INCLUDE_DIRS})
target_link_libraries(gdal_grass PUBLIC ${GDAL_LIBRARY} ${G_LIBS})
install(TARGETS gdal_grass DESTINATION ${AUTOLOAD_DIR})
add_library(ogr_grass SHARED ${OLIB_SOURCES})
set_target_properties(ogr_grass PROPERTIES PREFIX "")
set_target_properties(ogr_grass PROPERTIES OUTPUT_NAME "ogr_GRASS")
set_target_properties(ogr_grass PROPERTIES INSTALL_RPATH "${GRASS_GISBASE}/lib")
target_include_directories(
ogr_grass PRIVATE ${CMAKE_SOURCE_DIR} ${GDAL_INCLUDE_DIR} ${PostgreSQL_INCLUDE_DIRS}
${GRASS_INCLUDE} ${PROJ_INCLUDE_DIRS})
target_link_libraries(ogr_grass PUBLIC ${GDAL_LIBRARY} ${G_LIBS})
install(TARGETS ogr_grass DESTINATION ${AUTOLOAD_DIR})
# ##############################################################################
# Tests
if (Python_LOOKUP_VERSION)
set(Python_FIND_STRATEGY VERSION)
find_package(Python ${Python_LOOKUP_VERSION} EXACT COMPONENTS Interpreter Development NumPy)
else ()
set(Python_FIND_STRATEGY LOCATION)
find_package(Python 3.11 COMPONENTS Interpreter Development NumPy)
endif ()
if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/autotest")
add_subdirectory(autotest)
endif ()
gdal-grass-2.0.0/LICENSE 0000664 0000000 0000000 00000002230 15103317517 0014542 0 ustar 00root root 0000000 0000000 GDAL-GRASS GIS Driver Licensing
===============================
GDAL-GRASS GIS Driver is licensed under an MIT style license with the
following terms:
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.
gdal-grass-2.0.0/README.md 0000664 0000000 0000000 00000007060 15103317517 0015022 0 ustar 00root root 0000000 0000000 # Introduction
Description: GRASS GIS extension for the GDAL library
GDAL is a translator library for raster geospatial data formats.
As a library, it presents a single abstract data model to the
calling application for all supported formats. This extension
provides access to GRASS data via GDAL.
This package contains the two standalone GDAL-GRASS GIS drivers,
the [raster driver](docs/grass_raster.md) and the [vector driver](docs/grass_vector.md)
for [GRASS GIS](http://grass.osgeo.org/) raster and vector file support
in [GDAL](https://gdal.org/).
This approach avoids circular dependencies with GRASS depending on GDAL,
but GDAL with GRASS support depending on GRASS. With this driver package
you configure and install GDAL normally, then build and install GRASS normally
and finally build and install this driver in
[GDAL's "autoload" directory](https://gdal.org/user/configoptions.html#driver-management).
## Installation
To build this driver it is necessary for it to find GDAL and GRASS
support files.
**Building with CMake:**
```bash
cd gdal-grass
mkdir build && cd build
cmake ..
cmake --build .
cmake --install .
```
CMake usually works out the location of GDAL and GRASS, but at times you
may need/wish to set some configurations manually, e.g.:
```bash
cmake .. -DAUTOLOAD_DIR=/opt/local/lib/gdalplugins \
-DGDAL_CONFIG_PREFER_PATH=/opt/local/bin \
-DGRASS_BIN_PREFER_PATH=/opt/local/bin
```
## Usage
Set the driver path (e.g. in $HOME/.bashrc):
```bash
GDAL_DRIVER_PATH="/usr/lib/gdalplugins"
```
Access GRASS GIS raster data from GDAL:
```bash
gdalinfo $HOME/grassdata/nc_spm_08_grass7/PERMANENT/cellhd/elevation
```
Access GRASS GIS vector data from GDAL-OGR:
```bash
ogrinfo -so -al $HOME/grassdata/nc_spm_08_grass7/PERMANENT/vector/zipcodes/head
```
## Where is the gdal-grass driver available?
- Linux:
- Windows:
- other operating systems: please add here
## Version number has been restarted
Note that during the transit of this driver out of core GDAL we have
decided to reset the version numbering back to 1.
So: older packages show 3.x which the new driver is 1.x (or later).
## Release management
List of [milestones](https://github.com/OSGeo/gdal-grass/milestones).
## Tracking upstream changes
The release policies of the GDAL-GRASS driver are (so far) fairly simple:
- we follow the GDAL development for their breaking changes:
- as of 2022, any GDAL 2+ and GDAL 3+ version is compliant, with GDAL 3+ recommended.
- we follow the GRASS GIS development for their breaking changes:
- as of 2022, any GRASS GIS 7+ and GRASS GIS 8+ version is compliant,
with GRASS GIS 8+ recommended.
We expect low maintenance needs for this driver.
## Using milestones
For easier planning, each issue and pull request will be assigned
to a [milestone](https://github.com/OSGeo/gdal-grass/milestones).
## QA / CI
Any pull request opened in this repository is compiled and tested with
[GitHub Actions](https://github.com/OSGeo/gdal-grass/actions) against
the GDAL version included in Ubuntu (see related
[CI workflow](https://github.com/OSGeo/gdal-grass/blob/main/.github/workflows/ubuntu.yml)).
Improvements and other workflows are welcome, ideally as
a [pull request](https://github.com/OSGeo/gdal-grass/pulls).
## Found a bug?
Please open an [issue](https://github.com/OSGeo/gdal-grass/issues) describing
the problem along with a reproducible example.
## Who is involved here?
Please see the list of [contributors](https://github.com/OSGeo/gdal-grass/graphs/contributors).
gdal-grass-2.0.0/autotest/ 0000775 0000000 0000000 00000000000 15103317517 0015410 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/autotest/CMakeLists.txt 0000664 0000000 0000000 00000007325 15103317517 0020157 0 ustar 00root root 0000000 0000000 # CMake4GDAL project is distributed under MIT license. See accompanying file LICENSE.txt.
#[[
option(AUTOTEST_DOWNLOAD_TEST_DATA "Autotest to download test data" OFF)
option(AUTOTEST_SLOW_TEST "Autotest to run slow test" OFF)
if (NOT DEFINED ENV{CTEST_PARALLEL_LEVEL})
set(PARALLEL_OPTION "-j1")
endif ()
]]
if (Python_Interpreter_FOUND)
if (WIN32)
# If running GDAL as a CustomBuild Command os MSBuild, "ERROR bla:" is considered as failing the job. This is rarely
# the intended behavior
list(APPEND PYTHON_RUN_ENV "CPL_ERROR_SEPARATOR=\\;")
endif ()
# Set TEST_ENV that goes into pytest.ini
# Set GDAL_DATA
if(WIN32)
file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/data" GDAL_DATA)
else()
set(GDAL_DATA "${PROJECT_BINARY_DIR}/data")
endif()
set(TEST_ENV_ GDAL_DATA=${GDAL_DATA})
if (GDAL_DOWNLOAD_TEST_DATA)
list(APPEND TEST_ENV_ GDAL_DOWNLOAD_TEST_DATA=YES)
else ()
list(APPEND TEST_ENV_ "#GDAL_DOWNLOAD_TEST_DATA=YES")
endif ()
if (GDAL_SLOW_TESTS)
list(APPEND TEST_ENV_ GDAL_RUN_SLOW_TESTS=YES)
else ()
list(APPEND TEST_ENV_ "#GDAL_RUN_SLOW_TESTS=YES")
endif ()
# Conda enable PROJ_NETWORK but this does interfere with some of our tests due to some unexpected grid being used
list(APPEND TEST_ENV_ PROJ_NETWORK=OFF)
list(APPEND TEST_ENV_ "GDAL_DRIVER_PATH=${PROJECT_BINARY_DIR}")
string(REPLACE ";" "\n " TEST_ENV "${TEST_ENV_}")
set(AUTOTEST_LOG_FILE "${CMAKE_CURRENT_BINARY_DIR}/autotest.log")
set(PYTEST_INI_HEADER_MESSAGE "This file was generated from ${GDAL_CMAKE_TEMPLATE_PATH}/pytest.ini.in using ${CMAKE_CURRENT_LIST_FILE}")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pytest.ini.in ${CMAKE_CURRENT_BINARY_DIR}/pytest.ini @ONLY)
unset(PYTEST_INI_HEADER_MESSAGE)
function (copy_file_or_dir source dest)
if (IS_DIRECTORY ${source})
message(STATUS "Copying contents of ${source} to ${destination}")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${source} ${destination})
else()
message(STATUS "Copying ${source} to ${destination}")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${source} ${destination})
endif()
endfunction()
function (symlink_or_copy source destination)
file(CREATE_LINK ${source} ${destination}
RESULT res
SYMBOLIC)
if (NOT res EQUAL 0)
copy_file_or_dir(${source} ${destination})
endif ()
endfunction ()
symlink_or_copy(${CMAKE_CURRENT_SOURCE_DIR}/conftest.py ${CMAKE_CURRENT_BINARY_DIR}/conftest.py)
if (NOT "${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
foreach (subdir IN ITEMS pymod) # proj_grids cpp/data)
if (SKIP_COPYING_AUTOTEST_SUBDIRS)
message(STATUS "Skipping copying ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}")
else ()
symlink_or_copy(${CMAKE_CURRENT_SOURCE_DIR}/${subdir} ${CMAKE_CURRENT_BINARY_DIR}/${subdir})
endif ()
endforeach ()
endif()
foreach (tgt IN ITEMS ogr gdrivers)
if (NOT "${CMAKE_BINARY_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
if (SKIP_COPYING_AUTOTEST_SUBDIRS)
message(STATUS "Skipping copying ${CMAKE_CURRENT_SOURCE_DIR}/${tgt}")
else ()
symlink_or_copy(${CMAKE_CURRENT_SOURCE_DIR}/${tgt} ${CMAKE_CURRENT_BINARY_DIR}/${tgt})
endif ()
endif()
add_custom_target(
autotest_${tgt}
COMMAND ${CMAKE_COMMAND} -E env ${PYTHON_RUN_ENV} ${Python_EXECUTABLE} -m pytest -c
${CMAKE_CURRENT_BINARY_DIR}/pytest.ini ${tgt}
DEPENDS ${GDAL_LIB_TARGET_NAME} gdalapps python_binding)
add_test(NAME autotest_${tgt} COMMAND ${Python_EXECUTABLE} -m pytest -c ${CMAKE_CURRENT_BINARY_DIR}/pytest.ini
${tgt})
set_property(TEST autotest_${tgt} PROPERTY ENVIRONMENT "${PYTHON_RUN_ENV}")
endforeach ()
endif ()
gdal-grass-2.0.0/autotest/README.md 0000664 0000000 0000000 00000001444 15103317517 0016672 0 ustar 00root root 0000000 0000000 # GDAL-GRASS driver test suite
## How to run tests
1. You need to install `pytest` to run the test suite. This should do it:
```bash
pip install --upgrade pip
pip install pytest pytest-env pytest-sugar gdal==$(gdal-config --version)
```
2. Configure
```bash
cd gdal-grass
cmake -B build
cd build
cmake build .
```
3. Then, run tests with:
```bash
ctest
```
or:
```bash
cd autotest # i.e gdal-grass/build/autotest
pytest
```
4. Some quick usage tips:
```bash
# get more verbose output; don't capture stdout/stdin
pytest -vvs
# run all the ogr tests
pytest ogr
# run a particular module only
pytest ogr/ogr_grass.py
# run a particular test case in a module
pytest ogr/ogr_grass.py::test_ogr_grass_point2
```
gdal-grass-2.0.0/autotest/conftest.py 0000775 0000000 0000000 00000024176 15103317517 0017624 0 ustar 00root root 0000000 0000000 # coding: utf-8
from __future__ import absolute_import, division, print_function
import os
import sys
import pytest
from osgeo import gdal, ogr, osr
# Explicitly enable exceptions since autotest/ now assumes them to be
# enabled
gdal.UseExceptions()
# Put the pymod dir on the path, so modules can `import gdaltest`
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "pymod"))
# put the autotest dir on the path too. This lets us import all test modules
sys.path.insert(1, os.path.dirname(__file__))
# These files may be non-importable, and don't contain tests anyway.
# So we skip searching them during test collection.
collect_ignore = [
"kml_generate_test_files.py",
"gdrivers/netcdf_cfchecks.py",
"gdrivers/generate_bag.py",
"gdrivers/generate_fits.py",
]
collect_ignore_glob = ["pymod/*.py"]
if "APPLY_LOCALE" in os.environ:
import locale
locale.setlocale(locale.LC_ALL, "")
def setup_proj_search_paths():
from osgeo import osr
proj_grids_path = os.path.join(os.path.dirname(__file__), "proj_grids")
assert os.path.exists(proj_grids_path)
proj_db_tmpdir = os.path.join(
os.path.dirname(__file__), "gcore", "tmp", "proj_db_tmpdir"
)
proj_db_tmpdir_filename = os.path.join(proj_db_tmpdir, "proj.db")
src_proj_db_filename = None
for path in osr.GetPROJSearchPaths():
if os.path.exists(os.path.join(path, "proj.db")):
src_proj_db_filename = os.path.join(path, "proj.db")
break
if src_proj_db_filename is None:
print("Cannot find source proj.db")
sys.exit(1)
if (
not os.path.exists(proj_db_tmpdir_filename)
or os.stat(proj_db_tmpdir_filename).st_mtime
< os.stat(src_proj_db_filename).st_mtime
or os.stat(proj_db_tmpdir_filename).st_size
!= os.stat(src_proj_db_filename).st_size
):
import shutil
from filelock import FileLock
# We need to do the copy of proj.db from its source directory to
# gcore/tmp/proj_db_tmpdir under a lock to prevent pytest invocations
# run concurrently to overwrite in parallel, leading to PROJ being
# confused by the file being overwritten after opening, whereas PROJ
# assumes it to be immutable.
lock = FileLock(proj_db_tmpdir + ".lock")
with lock:
if (
not os.path.exists(proj_db_tmpdir_filename)
or os.stat(proj_db_tmpdir_filename).st_mtime
< os.stat(src_proj_db_filename).st_mtime
or os.stat(proj_db_tmpdir_filename).st_size
!= os.stat(src_proj_db_filename).st_size
):
print("Copying %s to %s" % (src_proj_db_filename, proj_db_tmpdir))
if not os.path.exists(proj_db_tmpdir):
os.mkdir(proj_db_tmpdir, 0o755)
shutil.copy(src_proj_db_filename, proj_db_tmpdir)
assert os.path.exists(proj_db_tmpdir_filename)
osr.SetPROJSearchPaths([proj_db_tmpdir, proj_grids_path])
# setup_proj_search_paths()
@pytest.fixture(scope="module", autouse=True)
def chdir_to_test_file(request):
"""
Changes to the same directory as the test file.
Also puts that directory at the start of sys.path,
so that imports of other files in the same directory are easy.
Tests have grown to expect this.
NOTE: This happens when the test is *run*, not during collection.
So test modules must not rely on it at module level.
"""
old = os.getcwd()
new_cwd = os.path.dirname(request.module.__file__)
os.chdir(new_cwd)
sys.path.insert(0, new_cwd)
yield
if sys.path and sys.path[0] == new_cwd:
sys.path.pop(0)
os.chdir(old)
def pytest_collection_modifyitems(config, items):
# skip test with @ptest.mark.require_run_on_demand when RUN_ON_DEMAND is not set
skip_run_on_demand_not_set = pytest.mark.skip("RUN_ON_DEMAND not set")
import gdaltest
import ogrtest
drivers_checked = {}
# Note: when adding a new custom marker, document it in cmake/template/pytest.ini.in
for item in items:
for mark in item.iter_markers("require_driver"):
driver_name = mark.args[0]
if driver_name not in drivers_checked:
driver = gdal.GetDriverByName(driver_name) or ogr.GetDriverByName(
driver_name
)
drivers_checked[driver_name] = bool(driver)
if driver:
# Store the driver on gdaltest module so test functions can assume it's there.
setattr(gdaltest, "%s_drv" % driver_name.lower(), driver)
if not drivers_checked[driver_name]:
# skip tests with @pytest.mark.require_driver(name) when the driver isn't available
item.add_marker(pytest.mark.skip(f"Driver {driver_name} not present"))
if not gdal.GetConfigOption("RUN_ON_DEMAND"):
for mark in item.iter_markers("require_run_on_demand"):
item.add_marker(skip_run_on_demand_not_set)
for mark in item.iter_markers("slow"):
if not gdaltest.run_slow_tests():
item.add_marker(pytest.mark.skip("GDAL_RUN_SLOW_TESTS not set"))
for mark in item.iter_markers("require_creation_option"):
driver, option = mark.args
drv = gdal.GetDriverByName(driver)
if drv is None:
item.add_marker(
pytest.mark.skip(f"{driver} driver is not included in this build")
)
elif option not in drv.GetMetadata()["DMD_CREATIONOPTIONLIST"]:
item.add_marker(
pytest.mark.skip(
f"{driver} creation option {option} not supported in this build"
)
)
for mark in item.iter_markers("require_geos"):
if not ogrtest.have_geos():
item.add_marker(pytest.mark.skip("GEOS not available"))
required_version = (
mark.args[0] if len(mark.args) > 0 else 0,
mark.args[1] if len(mark.args) > 1 else 0,
mark.args[2] if len(mark.args) > 2 else 0,
)
actual_version = (
ogr.GetGEOSVersionMajor(),
ogr.GetGEOSVersionMinor(),
ogr.GetGEOSVersionMicro(),
)
if actual_version < required_version:
item.add_marker(
pytest.mark.skip(
f"Requires GEOS >= {'.'.join(str(x) for x in required_version)}"
)
)
for mark in item.iter_markers("require_proj"):
required_version = (
mark.args[0],
mark.args[1] if len(mark.args) > 1 else 0,
mark.args[2] if len(mark.args) > 2 else 0,
)
actual_version = (
osr.GetPROJVersionMajor(),
osr.GetPROJVersionMinor(),
osr.GetPROJVersionMicro(),
)
if actual_version < required_version:
item.add_marker(
pytest.mark.skip(
f"Requires PROJ >= {'.'.join(str(x) for x in required_version)}"
)
)
for mark in item.iter_markers("require_curl"):
if not gdaltest.built_against_curl():
item.add_marker(pytest.mark.skip("curl support not available"))
def pytest_addoption(parser):
parser.addini("gdal_version", "GDAL version for which pytest.ini was generated")
def pytest_configure(config):
test_version = config.getini("gdal_version")
lib_version = gdal.__version__
if not lib_version.startswith(test_version):
raise Exception(
f"Attempting to run tests for GDAL {test_version} but library version is "
f"{lib_version}. Do you need to run setdevenv.sh ?"
)
def list_loaded_dlls():
try:
import psutil
except ImportError:
return None
process = psutil.Process()
loaded_dlls = []
for dll in process.memory_maps():
if os.path.exists(dll.path):
loaded_dlls.append(dll.path)
loaded_dlls = sorted(loaded_dlls)
return "\n".join(loaded_dlls)
def pytest_report_header(config):
gdal_header_info = "GDAL Build Info:"
for item in gdal.VersionInfo("BUILD_INFO").strip().split("\n"):
gdal_header_info += "\n " + item.replace("=", ": ")
import gdaltest
gdal_download_test_data = gdal.GetConfigOption("GDAL_DOWNLOAD_TEST_DATA")
if gdal_download_test_data is None:
gdal_download_test_data = "undefined"
gdal_header_info += f"\nGDAL_DOWNLOAD_TEST_DATA: {gdal_download_test_data}"
if not gdaltest.download_test_data():
gdal_header_info += " (tests relying on downloaded data may be skipped)"
gdal_run_slow_tests = gdal.GetConfigOption("GDAL_RUN_SLOW_TESTS")
if gdal_run_slow_tests is None:
gdal_run_slow_tests = "undefined"
gdal_header_info += f"\nGDAL_RUN_SLOW_TESTS: {gdal_run_slow_tests}"
if not gdaltest.run_slow_tests():
gdal_header_info += ' (tests marked as "slow" will be skipped)'
if gdal.GetConfigOption("CI"):
loaded_dlls = list_loaded_dlls()
if loaded_dlls:
gdal_header_info += "\nLoaded shared objects:\n" + loaded_dlls
return gdal_header_info
@pytest.fixture()
def tmp_vsimem(request):
import pathlib
import re
# sanitize test name using same method as pytest's tmp_path
subdir = re.sub(r"[\W]", "_", request.node.name)
# return a pathlib object so that behavior matches tmp_path
# and we can easily switch between the two
path = pathlib.PurePosixPath("/vsimem") / subdir
gdal.Mkdir(str(path), 0o755)
yield path
gdal.RmdirRecursive(str(path))
# Fixture to run a test function with pytest_benchmark
@pytest.fixture(scope="function")
def decorate_with_benchmark(request, benchmark):
def run_under_benchmark(f, benchmark):
def test_with_benchmark_fixture(*args, **kwargs):
@benchmark
def do():
f(*args, **kwargs)
return test_with_benchmark_fixture
request.node.obj = run_under_benchmark(request.node.obj, benchmark)
gdal-grass-2.0.0/autotest/gdrivers/ 0000775 0000000 0000000 00000000000 15103317517 0017235 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/autotest/gdrivers/data/ 0000775 0000000 0000000 00000000000 15103317517 0020146 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/ 0000775 0000000 0000000 00000000000 15103317517 0024162 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/PERMANENT/ 0000775 0000000 0000000 00000000000 15103317517 0025513 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/PERMANENT/PROJ_INFO 0000664 0000000 0000000 00000000244 15103317517 0027023 0 ustar 00root root 0000000 0000000 name: Universe Transverse Mercator
datum: nad83
towgs84: 0.000,0.000,0.000
proj: utm
ellps: grs80
a: 6378137.0000000000
es: 0.0066943800
f: 298.2572221010
zone: 18
gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/PERMANENT/PROJ_UNITS 0000664 0000000 0000000 00000000046 15103317517 0027172 0 ustar 00root root 0000000 0000000 unit: meter
units: meters
meters: 1.0
gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/README.txt 0000664 0000000 0000000 00000000153 15103317517 0025657 0 ustar 00root root 0000000 0000000 This is a very small extract from the sample set https://grass.osgeo.org/sampledata/fire_grass6data.tar.gz
gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/demomapset/ 0000775 0000000 0000000 00000000000 15103317517 0026320 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/demomapset/WIND 0000664 0000000 0000000 00000000475 15103317517 0027012 0 ustar 00root root 0000000 0000000 proj: 1
zone: 18
north: 4391490
south: 4385100
east: 551890
west: 547000
cols: 245
rows: 320
e-w resol: 19.95918367
n-s resol: 19.96875
top: 1
bottom: 0
cols3: 245
rows3: 320
depths: 1
e-w resol3: 19.95918367
n-s resol3: 19.96875
t-b resol: 1
gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/demomapset/cell/ 0000775 0000000 0000000 00000000000 15103317517 0027237 5 ustar 00root root 0000000 0000000 gdal-grass-2.0.0/autotest/gdrivers/data/small_grass_dataset/demomapset/cell/elevation 0000664 0000000 0000000 00000031015 15103317517 0031150 0 ustar 00root root 0000000 0000000 # &