Skip to content

Commit

Permalink
Merge pull request #234 from geohardtke/upgrade_ci
Browse files Browse the repository at this point in the history
upgrade ci
  • Loading branch information
jdroenner committed Jan 19, 2022
2 parents 00adecc + 72ddba1 commit 9249bf7
Show file tree
Hide file tree
Showing 4 changed files with 249 additions and 17 deletions.
206 changes: 200 additions & 6 deletions .github/workflows/ci.yml
Expand Up @@ -2,19 +2,213 @@ name: CI

on:
push:
branches: [ master, trying, staging ]
branches: [master, trying, staging]
pull_request:
branches: [ master, trying, staging ]
branches: [master, trying, staging]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:


jobs:
gdal_34:
name: "ci gdal-34"
runs-on: ubuntu-latest
container:
image: osgeo/gdal:ubuntu-full-3.4.0

strategy:
matrix:
features: ["", "--all-features"]

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install build deps
run: |
apt-get update -y
apt-get install build-essential pkg-config libclang-dev -y
- name: Setup building
run: |
export CC="clang-9"
export CXX="clang++-9"
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Check with Rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Check with Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets ${{ matrix.features }} -- -D warnings
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }} --verbose
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.features }} --verbose

gdal_33:
name: "ci gdal-33"
runs-on: ubuntu-latest
container:
image: osgeo/gdal:ubuntu-full-3.3.0

strategy:
matrix:
features: ["", "--all-features"]

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install build deps
run: |
apt-get update -y
apt-get install build-essential pkg-config libclang-dev -y
- name: Setup building
run: |
export CC="clang-9"
export CXX="clang++-9"
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Check with Rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Check with Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets ${{ matrix.features }} -- -D warnings
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }} --verbose
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.features }} --verbose

gdal_32:
name: "ci gdal-32"
runs-on: ubuntu-latest
container:
image: osgeo/gdal:ubuntu-full-3.2.0

ubuntu_20_04:
name: "ci ubuntu-20.04"
strategy:
matrix:
features: ["", "--all-features"]

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install build deps
run: |
apt-get update -y
apt-get install build-essential pkg-config libclang-dev -y
- name: Setup building
run: |
export CC="clang-9"
export CXX="clang++-9"
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Check with Rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Check with Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets ${{ matrix.features }} -- -D warnings
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }} --verbose
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.features }} --verbose

gdal_31:
name: "ci gdal-31"
runs-on: ubuntu-latest
container:
image: osgeo/gdal:ubuntu-full-3.1.0

strategy:
matrix:
features: ["", "--all-features"]

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install build deps
run: |
apt-get update -y
apt-get install build-essential pkg-config libclang-dev -y
- name: Setup building
run: |
export CC="clang-9"
export CXX="clang++-9"
- name: Install stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy
- name: Check with Rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Check with Clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-targets ${{ matrix.features }} -- -D warnings
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }} --verbose
- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.features }} --verbose

ubuntu_lts:
name: "ci ubuntu-lts"
runs-on: "ubuntu-20.04"

strategy:
matrix:
features: ["", "--all-features"]
Expand Down
2 changes: 1 addition & 1 deletion build.rs
Expand Up @@ -29,7 +29,7 @@ fn main() {
if detected_version.major < 2 {
panic!(
"The GDAL crate requires a GDAL version >= 2.0.0. Found {}",
detected_version.to_string()
detected_version
);
}

Expand Down
35 changes: 32 additions & 3 deletions src/raster/rasterband.rs
Expand Up @@ -232,18 +232,47 @@ impl<'a> RasterBand<'a> {
e_resample_alg: Option<ResampleAlg>,
) -> Result<Buffer<T>> {
let pixels = (size.0 * size.1) as usize;

let mut data: Vec<T> = Vec::with_capacity(pixels);

// Safety: the read_into_slice line below writes
let resample_alg = e_resample_alg.unwrap_or(ResampleAlg::NearestNeighbour);

let mut options: GDALRasterIOExtraArg = RasterIOExtraArg {
e_resample_alg: resample_alg,
..Default::default()
}
.into();

let options_ptr: *mut GDALRasterIOExtraArg = &mut options;

// Safety: the GDALRasterIOEx writes
// exactly pixel elements into the slice, before we
// read from this slice. This paradigm is suggested
// in the rust std docs
// (https://doc.rust-lang.org/std/vec/struct.Vec.html#examples-18)
let rv = unsafe {
gdal_sys::GDALRasterIOEx(
self.c_rasterband,
GDALRWFlag::GF_Read,
window.0 as c_int,
window.1 as c_int,
window_size.0 as c_int,
window_size.1 as c_int,
data.as_mut_ptr() as GDALRasterBandH,
size.0 as c_int,
size.1 as c_int,
T::gdal_type(),
0,
0,
options_ptr,
)
};
if rv != CPLErr::CE_None {
return Err(_last_cpl_err(rv));
}

unsafe {
data.set_len(pixels);
};
self.read_into_slice(window, window_size, size, &mut data, e_resample_alg)?;

Ok(Buffer { size, data })
}
Expand Down
23 changes: 16 additions & 7 deletions src/spatial_ref/tests.rs
Expand Up @@ -185,21 +185,30 @@ fn failing_transformation() {

#[test]
fn auto_identify() {
// retreived from https://epsg.io/32632, but deleted the `AUTHORITY["EPSG","32632"]`
let mut spatial_ref = SpatialRef::from_wkt(
r#"
PROJCS["WGS_1984_UTM_Zone_32N",
GEOGCS["GCS_WGS_1984",
DATUM["D_WGS_1984",
SPHEROID["WGS_1984",6378137,298.257223563]],
PRIMEM["Greenwich",0],
UNIT["Degree",0.017453292519943295]],
PROJCS["WGS 84 / UTM zone 32N",
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",9],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["Meter",1]]
UNIT["metre",1,
AUTHORITY["EPSG","9001"]],
AXIS["Easting",EAST],
AXIS["Northing",NORTH]]
"#,
)
.unwrap();
Expand Down

0 comments on commit 9249bf7

Please sign in to comment.