GithubHelp home page GithubHelp logo

georust / gdal Goto Github PK

View Code? Open in Web Editor NEW
327.0 20.0 89.0 2.38 MB

Rust bindings for GDAL

Home Page: https://crates.io/crates/gdal

License: MIT License

Rust 99.85% C 0.06% Shell 0.06% Python 0.03%
geospatial rust gdal hacktoberfest

gdal's Introduction

GDAL

Documentation Build Status

GDAL is a translator and processing library for various raster and vector geospatial data formats.

This crate provides safe, idiomatic Rust bindings for GDAL.

Capabilities

GDAL is an incredibly powerful library. For a general understanding of its capabilities, a good place to get started is the GDAL User-oriented documentation. These features include:

  • Opening raster and vector file formats for reading/writing
  • Translating between file formats
  • Reading and writing metadata in raster and vector datasets
  • Accessing raster bands and their metadata
  • Reading and writing geospatial coordinate system and projection values
  • Warping (resampling and re-projecting) between coordinate systems

Documentation

This crate's API documentation is hosted on docs.rs.

The Rust documentation is currently a work in progress, and may not cover requisite details on parameter semantics, value interpretation, etc. Therefore, the authoritative documentation is that of GDAL in the form of its C and C++ APIs. The former is technically what this crate calls, but the latter is usually more clear and better documented.

Usage

This crate provides high-level, idiomatic Rust bindings for GDAL. To do that, it uses gdal-sys internally, a low-level interface to the GDAL C library, which is generated using bindgen. Using the gdal-sys crate directly is normally not needed, but it can be useful in order to call APIs that have not yet been exposed in gdal.

Version support

As a general rule, only GDAL versions in Ubuntu LTS-1 (previous LTS version, that is, GDAL 3.0 in 20.04 at this moment) are supported. gdal-sys might support earlier versions using the bindgen feature flag, but gdal does not.

Building this crate assumes a compatible version of GDAL is installed with the corresponding header files and shared libraries. This repository includes pre-generated bindings for GDAL 3.0 through 3.8 (see thegdal-sys/prebuilt-bindings directory). If you're compiling against another version of GDAL, you can enable the bindgen feature flag to have the bindings generated on the fly.

Community

This crate is part of the expansive (and expanding!) georust organization. Come join our discussions on Discord!

Contributing

This crate continues to evolve, and PRs are always welcome. Make sure you are comfortable with the Code of Conduct and License before submitting a PR.

License

This library is released under the MIT license

gdal's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gdal's Issues

Fails to build on arm64 due to wrong pointer type

Not sure why, but it seems like something in gdal_sys expects a different pointer type for ESRI when compiling for arm64. This is the only error I get:

error[E0308]: mismatched types
   --> /app/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.6.0/src/spatial_ref/srs.rs:157:62
    |
157 |         let rv = unsafe { gdal_sys::OSRImportFromESRI(c_obj, ptrs.as_mut_ptr()) };
    |                                                              ^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
    |
    = note: expected raw pointer `*mut *mut u8`
               found raw pointer `*mut *mut i8`

I'm going to dig further into this.

crates publishing team

๐Ÿ‘‹ Hi @jdroenner and @frewsxcv,

Following up on georust/meta#21, I created a new org team with you two as maintainers. Could you please update the crate owners? I'm assuming it makes sense to share a single team for these two crates, but feel free to do otherwise.

Specifically:


  • @frewsxcv: update gdal crate owners on crates.io:
cd gdal

# ๐Ÿ’ฅ remove large publishing group
cargo owner --remove github:georust:core
# ๐Ÿ” add small publishing group
cargo owner --add github:georust:gdal-publishers

# ๐Ÿšจ consider adding jdroenner as a user-owner, as they have been maintaing and publishing recently
cargo owner --add jdroenner

# ๐Ÿšจ consider removing mgax as a user-owner, since they expressed no longer being actively involved in the project
cargo owner --remove mgax

# ๐Ÿšจ and from https://github.com/orgs/georust/teams/gdal-publishers

# make sure everything looks good ๐Ÿ‘€ 
cargo owner --list

  • @jdroenner: update gdal-sys crate owners on crates.io:

@jdroenner - you're the only "user owner" of that crate, so only you can edit that crate's owners:

cd gdal-sys

# ๐Ÿ’ฅ remove large publishing group
cargo owner --remove github:georust:core
# ๐Ÿ” add small publishing group
cargo owner --add github:georust:gdal-publishers

# and consider another user-owner, that way if for some reason you become inaccessible
# we have someone else who can edit the owners. See https://github.com/rust-lang/crates.io/issues/2906
cargo owner --add <username>

# make sure everything looks good ๐Ÿ‘€ 
cargo owner --list

And if there's anyone else you'd like to be able to publish the crates, feel free to add them to your publishing team, or as a user-owner. Consider that user-owners, as opposed to owners-via-team, can themselves edit the crate's owners, which could be desirable, or not, depending.

Let me know if you have any questions, or you can review georust/meta#21.

Linking error building library with examples

Hi, Ive run into an issue while using rust-gdal, in a library, that contains
examples, that should be built with cargo build --examples.

A minimal example of this can be seen with

Cargo.toml

[package]
name = "my_library"
version = "0.1.0"

[dependencies]
gdal = "0.4.0"

src/lib.rs

extern crate gdal;

use std::path::Path;
use gdal::vector::Dataset;

pub fn some_library_func(path: &Path) {
    let mut dataset = Dataset::open(path).unwrap();
    let layer = dataset.layer(0).unwrap();
    for feature in layer.features() {
        let geometry = feature.geometry();
        println!("{}", geometry.wkt().unwrap());
    }
}

examples/foo.rs

extern crate my_library;

use std::path::Path;

pub fn main() {
    my_library::some_library_func(Path::new("fixtures/roads.geojson"));
}

Exits with the following output:

$ cargo build --examples --verbose
       Fresh cc v1.0.17
       Fresh unicode-xid v0.0.4
       Fresh quote v0.3.15
       Fresh pkg-config v0.3.11
       Fresh libc v0.2.42
       Fresh cfg-if v0.1.4
       Fresh rustc-demangle v0.1.8
       Fresh synom v0.11.3
       Fresh syn v0.11.11
       Fresh num-traits v0.2.5
       Fresh backtrace-sys v0.1.23
       Fresh synstructure v0.6.1
       Fresh gdal-sys v0.2.0
       Fresh geo-types v0.1.1
       Fresh backtrace v0.3.9
       Fresh failure_derive v0.1.1
       Fresh failure v0.1.1
       Fresh gdal v0.4.0
   Compiling my_library v0.1.0 (file:///media/sf_Shared/my_library)
     Running `rustc --crate-name foo examples/foo.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=043b9f347a9b62dc -C extra-filename=-043b9f347a9b62dc --out-dir /media/sf_Shared/my_library/target/debug/examples -C incremental=/media/sf_Shared/my_library/target/debug/incremental -L dependency=/media/sf_Shared/my_library/target/debug/deps --extern gdal=/media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib --extern my_library=/media/sf_Shared/my_library/target/debug/deps/libmy_library-7ac8bbc0bc167bd9.rlib -L native=/media/sf_Shared/foodal/target/debug/build/backtrace-sys-e8ffa1bb7c17ed91/out`
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/media/sf_Shared/my_library/target/debug/examples/foo-043b9f347a9b62dc.15kq92zzbmxot4k9.rcgu.o" "/media/sf_Shared/my_library/target/debug/examples/foo-043b9f347a9b62dc.1qddbosld5q76e2k.rcgu.o" "/media/sf_Shared/my_library/target/debug/examples/foo-043b9f347a9b62dc.1y16o1qfye96o7m0.rcgu.o" "/media/sf_Shared/my_library/target/debug/examples/foo-043b9f347a9b62dc.3rngp6bm2u2q5z0y.rcgu.o" "/media/sf_Shared/my_library/target/debug/examples/foo-043b9f347a9b62dc.4oc10dk278mpk1vy.rcgu.o" "/media/sf_Shared/my_library/target/debug/examples/foo-043b9f347a9b62dc.oa3rad818d8sgn4.rcgu.o" "-o" "/media/sf_Shared/my_library/target/debug/examples/foo-043b9f347a9b62dc" "/media/sf_Shared/my_library/target/debug/examples/foo-043b9f347a9b62dc.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/media/sf_Shared/my_library/target/debug/deps" "-L" "/media/sf_Shared/foodal/target/debug/build/backtrace-sys-e8ffa1bb7c17ed91/out" "-L" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/media/sf_Shared/my_library/target/debug/deps/libmy_library-7ac8bbc0bc167bd9.rlib" "/media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib" "/media/sf_Shared/my_library/target/debug/deps/libgeo_types-60136e86db0880a9.rlib" "/media/sf_Shared/my_library/target/debug/deps/libnum_traits-3fe5540af7b259fe.rlib" "/media/sf_Shared/my_library/target/debug/deps/libgdal_sys-74099c4c48944713.rlib" "/media/sf_Shared/my_library/target/debug/deps/libfailure-f26dac43455e9e51.rlib" "/media/sf_Shared/my_library/target/debug/deps/libbacktrace-12416ba8ba1e479f.rlib" "/media/sf_Shared/my_library/target/debug/deps/libbacktrace_sys-d5861526e2603679.rlib" "/media/sf_Shared/my_library/target/debug/deps/librustc_demangle-1f0506f786720cbf.rlib" "/media/sf_Shared/my_library/target/debug/deps/libcfg_if-f8134544e6bb51a5.rlib" "/media/sf_Shared/my_library/target/debug/deps/liblibc-76755a6888618a72.rlib" "-Wl,--start-group" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-2e0e6fd5a64772ec.rlib" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-731e169e757c346a.rlib" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_jemalloc-095fc2295ae9ef1b.rlib" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-937988d834c61738.rlib" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc_system-b7ac4cdefbcbe74e.rlib" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-2acd14cf338f9037.rlib" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-abc00040df319771.rlib" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-c03be6943b237af4.rlib" "-Wl,--end-group" "/home/webadmin/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-7d0cd09e2c099c63.rlib" "-Wl,-Bdynamic" "-l" "util" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-l" "util" "-l" "util"
  = note: /media/sf_Shared/my_library/target/debug/deps/libmy_library-7ac8bbc0bc167bd9.rlib(my_library-7ac8bbc0bc167bd9.bsv4hhfe0fw3uwo.rcgu.o): In function `_$LT$gdal..vector..layer..FeatureIterator$LT$$u27$a$GT$$u20$as$u20$core..iter..iterator..Iterator$GT$::next::h73f4d65d41612cf7':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/layer.rs:134: undefined reference to `OGR_L_GetNextFeature'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal13.rcgu.o): In function `gdal::vector::layer::Layer::_with_c_layer::hb4cf7070ac35817d':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/layer.rs:42: undefined reference to `OGR_L_GetLayerDefn'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal14.rcgu.o): In function `gdal::vector::driver::_register_drivers::_$u7b$$u7b$closure$u7d$$u7d$::hd91edad7f5150321':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/driver.rs:17: undefined reference to `OGRRegisterAll'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal14.rcgu.o): In function `gdal::vector::dataset::Dataset::open::haff3629ce2a2efbe':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/dataset.rs:48: undefined reference to `OGROpen'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal14.rcgu.o): In function `gdal::vector::dataset::Dataset::layer::h9b77e803f7182c07':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/dataset.rs:68: undefined reference to `OGR_DS_GetLayer'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal14.rcgu.o): In function `_$LT$gdal..vector..dataset..Dataset$u20$as$u20$core..ops..drop..Drop$GT$::drop::h5a765ac8c64519c6':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/dataset.rs:106: undefined reference to `OGR_DS_Destroy'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal15.rcgu.o): In function `gdal::utils::_last_null_pointer_err::h5a6deb31c2739074':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/utils.rs:27: undefined reference to `CPLGetLastErrorMsg'
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/utils.rs:28: undefined reference to `CPLErrorReset'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal4.rcgu.o): In function `gdal::vector::geometry::Geometry::wkt::h85760a13445f617a':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/geometry.rs:101: undefined reference to `OGR_G_ExportToWkt'
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/geometry.rs:106: undefined reference to `OGRFree'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal4.rcgu.o): In function `_$LT$gdal..vector..geometry..Geometry$u20$as$u20$core..ops..drop..Drop$GT$::drop::hc443bf41f447c587':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/geometry.rs:254: undefined reference to `OGR_G_DestroyGeometry'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal5.rcgu.o): In function `gdal::vector::feature::Feature::_lazy_feature_geometries::h5b8df148d0a91920':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/feature.rs:40: undefined reference to `OGR_FD_GetGeomFieldCount'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal5.rcgu.o): In function `gdal::vector::feature::Feature::geometry::h92741fc478a9108e':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/feature.rs:75: undefined reference to `OGR_F_GetGeometryRef'
          /media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib(gdal-846e2f1337cd8da6.gdal5.rcgu.o): In function `_$LT$gdal..vector..feature..Feature$LT$$u27$a$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::hf5c2659b91e81689':
          /home/webadmin/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-0.4.0/src/vector/feature.rs:165: undefined reference to `OGR_F_Destroy'
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `my_library`.

Caused by:
  process didn't exit successfully: `rustc --crate-name foo examples/foo.rs --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=043b9f347a9b62dc -C extra-filename=-043b9f347a9b62dc --out-dir /media/sf_Shared/my_library/target/debug/examples -C incremental=/media/sf_Shared/my_library/target/debug/incremental -L dependency=/media/sf_Shared/my_library/target/debug/deps --extern gdal=/media/sf_Shared/my_library/target/debug/deps/libgdal-846e2f1337cd8da6.rlib --extern my_library=/media/sf_Shared/my_library/target/debug/deps/libmy_library-7ac8bbc0bc167bd9.rlib -L native=/media/sf_Shared/foodal/target/debug/build/backtrace-sys-e8ffa1bb7c17ed91/out` (exit code: 101)

Building the project with plain cargo build works as expected.

Ubuntu 16.04.4 LTS
cargo 1.27.0 (1e95190e5 2018-05-27)
rustc 1.27.0 (3eda71b00 2018-06-19)
gdal 2.1.3 (installed from the ubuntugis ppa fwiw)

`actual_block_size` not available for GDAL >= 3

At #92, there is a change to

    /// Get actual block size (at the edges) when block size
    /// does not divide band size.
    #[cfg(all(major_ge_2, minor_ge_2))]
    pub fn actual_block_size(&self, offset: (isize, isize)) -> Result<(usize, usize)> {
        let mut block_size_x = 0;
        let mut block_size_y = 0;
        โ€ฆ

This means the function is gone at GDAL 3.0 or 3.1? I guess this can be fixed easily.

Build fails on MacOS

Hey all,

I'm pretty new to Rust so please forgive me if there's something simple I'm missing.

I'm trying to run the example in the docs with a shapefile I have locally, but the build fails, suggesting that it can't find GDAL.

Here's the error:

$ cargo build
   Compiling gdal-sys v0.3.0
   Compiling thiserror-impl v1.0.22
error: failed to run custom build command for `gdal-sys v0.3.0`

Caused by:
  process didn't exit successfully: `/Users/tom/dev/rust/geocsv/target/debug/build/gdal-sys-be9ea9545f8d6e9b/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=GDAL_STATIC
cargo:rerun-if-env-changed=GDAL_DYNAMIC
cargo:rerun-if-env-changed=GDAL_INCLUDE_DIR
cargo:rerun-if-env-changed=GDAL_LIB_DIR
cargo:rerun-if-env-changed=GDAL_HOME
cargo:rerun-if-env-changed=GDAL_VERSION
cargo:rerun-if-env-changed=GDAL_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_apple_darwin
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_apple_darwin
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-apple-darwin
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_apple_darwin
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

--- stderr
thread 'main' panicked at 'No GDAL version detected', /Users/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/gdal-sys-0.3.0/build.rs:202:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

warning: build failed, waiting for other jobs to finish...
error: build failed

But I have gdal installed:

$ gdal-config --prefix
/usr/local/Cellar/gdal/3.2.0_1
$ gdal-config --version
3.2.0

After looking at the error message's environment variable suggestions, I tried setting some variables which looked promising...

$ gdal-config --cflags
-I/usr/local/Cellar/gdal/3.2.0_1/include
$ gdal-config --libs
-L/usr/local/Cellar/gdal/3.2.0_1/lib -lgdal
$ export GDAL_INCLUDE_DIR=/usr/local/Cellar/gdal/3.2.0_1/include
$ export GDAL_LIB_DIR=/usr/local/Cellar/gdal/3.2.0_1/lib
$ export GDAL_HOME=/usr/local/Cellar/gdal/3.2.0_1
$ cargo build
... error ...

But it's possible I'm setting them incorrectly.

What am I missing?

Thanks!

PostGIS write example

I was wondering if you had or knew of an example of using these binding to load vector data into a PostGIS database.

Essentially an example like https://github.com/georust/gdal/blob/master/examples/read_write_ogr.rs but instead of converting the GeoJSON to a shapefile, it gets converted to a PostGIS table.

When try this:

let mut postgis = Dataset::open(Path::new("PG: host=localhost dbname=** user=*"))?;

I get an Error browsing database for PostGIS Raster tables: error.

Running the ogr2ogr command:

ogr2ogr -f "PostgreSQL" PG:"dbname=** user=**" input.geojson

works fine so I think I have all the correct drivers installed.

Apologies if this is obvious but been trying to figure it out for a while now without success. I would be willing to submit a PR with a working example for the examples folder for others who are trying to do the same if you can help me figure this out.

Thanks!

Makes GDALAccess enum public

Should we re-export GDALAccess enum from gdal-sys that is imported in dataset.rs ? It seems useful as it is needed for the second argument to Dataset::open_ex (in order to open file in update/edit mode). Pls. let me know and I will provide a PR.

Dataset Later Iteration

There isn't an API for iterating through a Dataset's layers. This requires a foreknowledge of what layer names are in the Dataset.

please publish a new version to crates

It looks like a few documented features were added after the last release, so I can't use them.
Can you please update the cargo file?

src/main.rs:36:54: 36:69 error: no method named `get_point_vec` found for type `&gdal::vector::geometry::Geometry` in the current scope
src/main.rs:36         let points : Vec<(f64, f64, f64)> = geometry.get_point_vec();

FieldValue Types

There are some missing types in FieldValue's that one would expect to find such as:

IntegerListValue
Integer64ListValue
StringListValue
RealListValue

Replace "failure" error handling

Handling gdal crate errors in other crates requires the "failure" crate which is deprecated. We should use a crate / error strategy which does not require additional crates.

Consider using bindgen for gdal-sys

What the title says. This might make adding the missing APIs easier, but will probably require a large rework of the crate.

Do you think it might be a good idea?

I'm not necessarily volunteering to implement this ๐Ÿ˜„ .

Dataset should be Send

To the best of our understanding, GDAL supports minimal multi-threading in that it is okay for different threads to access a Dataset as long as only one thread is accessing it at any time (see GDAL Doc).

I believe we should implement Send trait on {raster,vector}::Dataset to allow it to be passed across threads if necessary. As Dataset is not Clone or Copy, there is still only one copy of the handle. Note that RasterBand and Layer should not be Send because they allow reference back to Dataset and may cause concurrent calls to the GDAL layer.

We have encountered this use-case when creating multi-threaded pipeline to work on large (> 4GB) datasets. Also happy to provide a PR.

Improve / write docs

The state of the documentation in this crate is not as it should be. This is a task is also ideal for new contributors. Most of the time the docs of the wrapped gdal-sys method will be enough to derive a methods doc.

No license

As far as I know, this project does not specify which software license it is licensed under.

Any way of selecting GDALRIOResampleAlg?

At the moment, to read a raster into a slice you are using GDALRasterIO, which doesn't provide a way to select a resampling algorithm.

If I'm not mistaken, GDALRasterIOEx has an extra option which could be used to do that.

Is there any way to pass a sampling algorithm (GDALRIOResampleAlg) to read_as or read_into_slice?

I tried to implement my own read_into_slice function but RasterBand.c_rasterband is private and I'm not sure how to proceed.

Cheers!

Missing Gdal dataset open flags

The gdal::open_ex open_flags allow only value from the GDALAccess::Type values.

This prevent using the others GDAL_OF_XXX flags combination.

They are preprocessor #define in gdal.h and thus skipped by bindgen; they are still essential to control some opening behaviors like raster/vector driver selection, or multidimensional raster or gnm drivers.

Maybe a crate like bitflags could help.

Serde deserialize support for GDAL

Hello guys,

Not sure an issue is the best way to ask this, so let me know if it should be somewhere else.

Basically for some context I've been using this library quite a bit and I do want to give something back. I've made small additions to the API but I think the most interesting part is adding some serde deserialization support.

How it works is I can have an object like this

#[derive(Deserialize, Debug)]
struct StronglyTypedObject {
    #[serde(rename="FieldNameInOGR")]
    global_id: String,
    some_count: u16,
    some_code: String,

    // This means the OGR layer has a field named Shape_Area
    #[serde(rename="Shape_Area")]
    shape_area: f32,
}

And I can deserialize like so

let mut ds = Dataset::open_from_str("/path/to/an/esri_yuck.gdb")?;
//let layer = ds.layer_by_sql("SELECT field1, field2, field4 FROM my_layer_name")?;
let layer = ds.layer_by_name("my_layer_name")?;

let gd = GdalStructDeserializerContext::new::<StronglyTypedObject>(layer.defn());
let my_obj: StronglyTypedObject = gd.to_struct(&layer.features().next().unwrap())?;

The reason for the context is that it will read the fields in the generic object and store the corresponding field indexes in order. It works similiar to bincode.

I also made a 2nd deserializer that can deserialize to Vec<String>, Vec<FieldValue>, HashMap<String, String>, and HashMap<String, FieldValue>. The maps keys are the field name, and the vector indexes are the field indexes.

FYI FieldValue is in this repo that is an enum that acts as a union to store strongly typed data.

So basically the question is -- Is there interest for a PR?

It would work like the other libraries where you can add a feature serde to the package and it will add this support.

I attached the raw code in case you would prefer looking at source. It has not been cleaned up, but should be more or less working. I'm currently working on making sure Option works as well (check Gdal for null fields) as being able to deserialize the FID. Another idea is integrating with the rust geo library https://github.com/georust/geo to be able to deserialize directly into a rust shape object.

I'm not sure I did things the best way. I hardcoded the FieldValue variant indexes for example, which isn't super clean. I'm not sure if this idea of a context was good. And how I kept state in the deserializer. Said another way, design comments welcome !

Anyway, it is still cool to get typed objects directly from Gdal.

Also I used this trick to get the field names of the struct from serde-rs/serde#1110.

gdal_serde.zip

Borrowed vs. owned geometries

The OGR C API has two ways of accessing geometries:

  • take a geometry pointer from a feature using OGR_F_GetGeometryRef, and you're not supposed to modify or deallocate it,
  • clone the above geometry, or create one from scratch e.g. using OGR_G_CreateFromWkt, and you can modify it, and you're responsible for deallocating; you can also pass ownership back to OGR by attaching it to a feature, using OGR_F_SetGeometryDirectly.

In both cases, you have a pointer to OGRGeometryH. We should support operations on both, e.g. transforming them to JSON or WKT, and it makes sense to share the implementation.

A naive approach would be to always copy geometries, and only work with owned geometries from Rust, but that seems wasteful. But I'm probably implementing this initially, to have a working API.

Another option is to create different types for owned and borrowed geometries and share the implementation by a common trait. I've experimented with this in the feature-geometry branch.

A third option is to have an owned geometry type, which wraps a borrowed geometry type, similar to String and str.

@georust/core, any input is much appreciated :)

Async functions

Hi,

Is there a plan to move functions to support async execution, or at least implement thread safe data types, while this crate is good, its really hard to implement functions that require async operations in conjunction with gdal functions.

Thanks

Allow to write ogr data

I guess it would be nice to be able to write OGR data.

(I started to work on this if it's ok for you ?)

Release 0.7

We should release a new version soon. However, there are still some things to do:

  • #110 change the crate publishing teams
  • merge #88
  • merge #109
  • #111 update changelog and readme.md to reflect recent changes

Is there something missing?

Consider making a new release

There's been a couple of changes lately: bindgen for gdal-sys, failure support and, to a lesser extent, moving to geo-types. It might be worth issuing new releases for these.

Feature::field should return Result<Option<FieldValue>>

Currently, Feature::field returns Result<FieldValue>, but fields can be null. When this is the case, the default value for the FieldValue variant is returned. This makes it difficult to distinguish e.g. a legitimate Integer 0 value from the absence of a value.

I am not very familiar with the GDAL lib, but just taking a quick one through, it looks like maybe the OGR_F_IsFieldNull function could be used to see if a field is null first, and if so, return None.

Adapt to GDAL 3

GDAL 3 introduces large changes. We should decide how to handle them in this crate.

Some (but not all) options are:

  1. The easiest way would be to drop support for GDAL < 3.0.
  2. Use modules and features as feature gate. This would result in separate modules with methods from gdal 2.4, gdal 3.0, ...

Unit tests frequently fail with a segfault

Running cargo test frequently fails with a segfault.

Running the tests using valgrind indicates a read-after-free problem in the last line of Geometry::test_spatial_reference where it calls geom.spatial_reference(). Valgrind is suggesting that some memory is being read after it has been freed after the previous line.

Commenting out the test_spatial_reference test makes all the other tests pass reliably and there are no segfaults.

Perhaps srs is being dropped on exit from set_spatial_reference because it is being moved into the function.

Full valgrind output follows:

$ valgrind target/debug/deps/gdal-70427d28ae09def0 --test-threads 1
==14812== Memcheck, a memory error detector
==14812== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==14812== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==14812== Command: target/debug/deps/gdal-70427d28ae09def0 --test-threads 1
==14812== 

running 56 tests
test raster::tests::test_create ... ok
test raster::tests::test_create_copy ... ok
test raster::tests::test_create_with_band_type ... ok
test raster::tests::test_geo_transform ... ok
test raster::tests::test_get_band_type ... ERROR 5: GDALDataset::GetRasterBand(2) - Illegal band #

ok
test raster::tests::test_get_dataset_driver ... ok
test raster::tests::test_get_description ... ok
test raster::tests::test_get_driver_by_name ... ok
test raster::tests::test_get_metadata_item ... ok
test raster::tests::test_get_no_data_value ... ok
test raster::tests::test_get_offset ... ok
test raster::tests::test_get_projection ... ok
test raster::tests::test_get_raster_count ... ok
test raster::tests::test_get_raster_size ... ok
test raster::tests::test_get_rasterband ... ok
test raster::tests::test_get_scale ... ok
test raster::tests::test_open ... ERROR 4: No such file or directory
ok
test raster::tests::test_read_full_raster_as ... ok
test raster::tests::test_read_raster ... ok
test raster::tests::test_read_raster_as ... ok
test raster::tests::test_set_metadata_item ... ok
test raster::tests::test_write_raster ... ok
test spatial_ref::tests::authority ... ok
test spatial_ref::tests::comparison ... ok
test spatial_ref::tests::from_epsg_to_wkt_proj4 ... ok
test spatial_ref::tests::from_esri_to_proj4 ... ok
test spatial_ref::tests::from_proj4_to_wkt ... ok
test spatial_ref::tests::from_wkt_to_proj4 ... ok
test spatial_ref::tests::transform_coordinates ... ok
test spatial_ref::tests::transform_ogr_geometry ... ok
test vector::geometry::tests::test_area ... Warning 1: OGR_G_Area() called against non-surface geometry type.
ok
test vector::geometry::tests::test_is_empty ... ok
test vector::geometry::tests::test_spatial_reference ... ==14812== Thread 2 vector::geometry::tests::test_spatial_reference:
==14812== Invalid read of size 8
==14812==    at 0x58A3530: OGRSpatialReference::Clone() const (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x17C67F: gdal::spatial_ref::srs::SpatialRef::from_c_obj::hfd278dfebc14debd (srs.rs:137)
==14812==    by 0x1685CA: gdal::vector::geometry::Geometry::spatial_reference::h5e750946ce85fd56 (geometry.rs:269)
==14812==    by 0x1694D4: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:344)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812==    by 0x1E5A9B: call_once<(),()> (boxed.rs:692)
==14812==    by 0x1E5A9B: start_thread (thread.rs:21)
==14812==    by 0x1E5A9B: std::sys::imp::thread::Thread::new::thread_start::hf0e7be833820328e (thread.rs:84)
==14812==    by 0x62E1183: start_thread (pthread_create.c:312)
==14812==  Address 0x152780d0 is 32 bytes inside a block of size 48 free'd
==14812==    at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14812==    by 0x17B50F: _$LT$gdal..spatial_ref..srs..SpatialRef$u20$as$u20$core..ops..drop..Drop$GT$::drop::h1719ff8fe53de0b5 (srs.rs:52)
==14812==    by 0x135454: core::ptr::drop_in_place::h479a4a3c2ae0bb10 (ptr.rs:61)
==14812==    by 0x1686DF: gdal::vector::geometry::Geometry::set_spatial_reference::h167598c79e299e3e (in /home/warwick/git/rust-gdal/target/debug/deps/gdal-70427d28ae09def0)
==14812==    by 0x1694BD: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:343)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812==    by 0x1E5A9B: call_once<(),()> (boxed.rs:692)
==14812==    by 0x1E5A9B: start_thread (thread.rs:21)
==14812==    by 0x1E5A9B: std::sys::imp::thread::Thread::new::thread_start::hf0e7be833820328e (thread.rs:84)
==14812== 
==14812== Invalid read of size 8
==14812==    at 0x58AD9D1: OGR_SRSNode::Clone() const (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x58A353D: OGRSpatialReference::Clone() const (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x17C67F: gdal::spatial_ref::srs::SpatialRef::from_c_obj::hfd278dfebc14debd (srs.rs:137)
==14812==    by 0x1685CA: gdal::vector::geometry::Geometry::spatial_reference::h5e750946ce85fd56 (geometry.rs:269)
==14812==    by 0x1694D4: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:344)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812==    by 0x1E5A9B: call_once<(),()> (boxed.rs:692)
==14812==    by 0x1E5A9B: start_thread (thread.rs:21)
==14812==    by 0x1E5A9B: std::sys::imp::thread::Thread::new::thread_start::hf0e7be833820328e (thread.rs:84)
==14812==  Address 0x15278240 is 0 bytes inside a block of size 32 free'd
==14812==    at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14812==    by 0x58A2E58: OGRSpatialReference::~OGRSpatialReference() (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x17B50F: _$LT$gdal..spatial_ref..srs..SpatialRef$u20$as$u20$core..ops..drop..Drop$GT$::drop::h1719ff8fe53de0b5 (srs.rs:52)
==14812==    by 0x135454: core::ptr::drop_in_place::h479a4a3c2ae0bb10 (ptr.rs:61)
==14812==    by 0x1686DF: gdal::vector::geometry::Geometry::set_spatial_reference::h167598c79e299e3e (in /home/warwick/git/rust-gdal/target/debug/deps/gdal-70427d28ae09def0)
==14812==    by 0x1694BD: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:343)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812== 
==14812== Invalid read of size 4
==14812==    at 0x58AD9E0: OGR_SRSNode::Clone() const (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x58A353D: OGRSpatialReference::Clone() const (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x17C67F: gdal::spatial_ref::srs::SpatialRef::from_c_obj::hfd278dfebc14debd (srs.rs:137)
==14812==    by 0x1685CA: gdal::vector::geometry::Geometry::spatial_reference::h5e750946ce85fd56 (geometry.rs:269)
==14812==    by 0x1694D4: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:344)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812==    by 0x1E5A9B: call_once<(),()> (boxed.rs:692)
==14812==    by 0x1E5A9B: start_thread (thread.rs:21)
==14812==    by 0x1E5A9B: std::sys::imp::thread::Thread::new::thread_start::hf0e7be833820328e (thread.rs:84)
==14812==  Address 0x15278258 is 24 bytes inside a block of size 32 free'd
==14812==    at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14812==    by 0x58A2E58: OGRSpatialReference::~OGRSpatialReference() (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x17B50F: _$LT$gdal..spatial_ref..srs..SpatialRef$u20$as$u20$core..ops..drop..Drop$GT$::drop::h1719ff8fe53de0b5 (srs.rs:52)
==14812==    by 0x135454: core::ptr::drop_in_place::h479a4a3c2ae0bb10 (ptr.rs:61)
==14812==    by 0x1686DF: gdal::vector::geometry::Geometry::set_spatial_reference::h167598c79e299e3e (in /home/warwick/git/rust-gdal/target/debug/deps/gdal-70427d28ae09def0)
==14812==    by 0x1694BD: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:343)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812== 
==14812== Invalid read of size 4
==14812==    at 0x58A30A1: OGRSpatialReference::Dereference() (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x58A3148: OGRSpatialReference::Release() (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x5882308: OGRPolygon::~OGRPolygon() (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x16877F: _$LT$gdal..vector..geometry..Geometry$u20$as$u20$core..ops..drop..Drop$GT$::drop::hfcb368eda58f012d (geometry.rs:285)
==14812==    by 0x136764: core::ptr::drop_in_place::hae6dc65110a508bb (ptr.rs:61)
==14812==    by 0x169547: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:345)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812==  Address 0x152780d8 is 40 bytes inside a block of size 48 free'd
==14812==    at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14812==    by 0x17B50F: _$LT$gdal..spatial_ref..srs..SpatialRef$u20$as$u20$core..ops..drop..Drop$GT$::drop::h1719ff8fe53de0b5 (srs.rs:52)
==14812==    by 0x135454: core::ptr::drop_in_place::h479a4a3c2ae0bb10 (ptr.rs:61)
==14812==    by 0x1686DF: gdal::vector::geometry::Geometry::set_spatial_reference::h167598c79e299e3e (in /home/warwick/git/rust-gdal/target/debug/deps/gdal-70427d28ae09def0)
==14812==    by 0x1694BD: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:343)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812==    by 0x1E5A9B: call_once<(),()> (boxed.rs:692)
==14812==    by 0x1E5A9B: start_thread (thread.rs:21)
==14812==    by 0x1E5A9B: std::sys::imp::thread::Thread::new::thread_start::hf0e7be833820328e (thread.rs:84)
==14812== 
==14812== Invalid read of size 4
==14812==    at 0x547D0E2: CPLAtomicAdd (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x58A3148: OGRSpatialReference::Release() (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x5882308: OGRPolygon::~OGRPolygon() (in /usr/lib/libgdal.so.20.1.0)
==14812==    by 0x16877F: _$LT$gdal..vector..geometry..Geometry$u20$as$u20$core..ops..drop..Drop$GT$::drop::hfcb368eda58f012d (geometry.rs:285)
==14812==    by 0x136764: core::ptr::drop_in_place::hae6dc65110a508bb (ptr.rs:61)
==14812==    by 0x169547: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:345)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812==  Address 0x152780d8 is 40 bytes inside a block of size 48 free'd
==14812==    at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14812==    by 0x17B50F: _$LT$gdal..spatial_ref..srs..SpatialRef$u20$as$u20$core..ops..drop..Drop$GT$::drop::h1719ff8fe53de0b5 (srs.rs:52)
==14812==    by 0x135454: core::ptr::drop_in_place::h479a4a3c2ae0bb10 (ptr.rs:61)
==14812==    by 0x1686DF: gdal::vector::geometry::Geometry::set_spatial_reference::h167598c79e299e3e (in /home/warwick/git/rust-gdal/target/debug/deps/gdal-70427d28ae09def0)
==14812==    by 0x1694BD: gdal::vector::geometry::tests::test_spatial_reference::ha3db80e6d425558d (geometry.rs:343)
==14812==    by 0x1929B1: {{closure}} (lib.rs:1480)
==14812==    by 0x1929B1: call_once<closure,(())> (function.rs:223)
==14812==    by 0x1929B1: _$LT$F$u20$as$u20$test..FnBox$LT$T$GT$$GT$::call_box::h3cf6e61f5182f464 (lib.rs:141)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x183E8A: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x183E8A: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x183E8A: {{closure}} (lib.rs:1419)
==14812==    by 0x183E8A: std::sys_common::backtrace::__rust_begin_short_backtrace::h36d0e6f1b34daaf1 (backtrace.rs:136)
==14812==    by 0x184BC2: {{closure}}<closure,()> (mod.rs:394)
==14812==    by 0x184BC2: call_once<(),closure> (panic.rs:296)
==14812==    by 0x184BC2: std::panicking::try::do_call::h0a36fa793f806dec (panicking.rs:480)
==14812==    by 0x1EDACC: __rust_maybe_catch_panic (lib.rs:99)
==14812==    by 0x18C702: try<(),std::panic::AssertUnwindSafe<closure>> (panicking.rs:459)
==14812==    by 0x18C702: catch_unwind<std::panic::AssertUnwindSafe<closure>,()> (panic.rs:361)
==14812==    by 0x18C702: {{closure}}<closure,()> (mod.rs:393)
==14812==    by 0x18C702: _$LT$F$u20$as$u20$alloc..boxed..FnBox$LT$A$GT$$GT$::call_box::hdc66c7bb936b9796 (boxed.rs:682)
==14812==    by 0x1E5A9B: call_once<(),()> (boxed.rs:692)
==14812==    by 0x1E5A9B: start_thread (thread.rs:21)
==14812==    by 0x1E5A9B: std::sys::imp::thread::Thread::new::thread_start::hf0e7be833820328e (thread.rs:84)
==14812== 
ok
test vector::tests::convert_geo::test_import_export_geometrycollection ... ok
test vector::tests::convert_geo::test_import_export_linestring ... ok
test vector::tests::convert_geo::test_import_export_multilinestring ... ok
test vector::tests::convert_geo::test_import_export_multipoint ... ok
test vector::tests::convert_geo::test_import_export_multipolygon ... ok
test vector::tests::convert_geo::test_import_export_point ... ok
test vector::tests::convert_geo::test_import_export_polygon ... ok
test vector::tests::test_convex_hull ... ok
test vector::tests::test_create_bbox ... ok
test vector::tests::test_float_field ... ok
test vector::tests::test_geom_accessors ... ok
test vector::tests::test_geom_fields ... ok
test vector::tests::test_get_layer_by_name ... ok
test vector::tests::test_iterate_features ... ok
test vector::tests::test_json ... ok
test vector::tests::test_layer_count ... ok
test vector::tests::test_missing_field ... ok
test vector::tests::test_schema ... ok
test vector::tests::test_spatial_filter ... ok
test vector::tests::test_string_field ... ok
test vector::tests::test_wkt ... ok
test vector::tests::test_write_features ... ok
test version::tests::test_version_info ... ok

test result: ok. 56 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

==14812== 
==14812== HEAP SUMMARY:
==14812==     in use at exit: 48 bytes in 2 blocks
==14812==   total heap usage: 7,693 allocs, 7,691 frees, 414,448 bytes allocated
==14812== 
==14812== LEAK SUMMARY:
==14812==    definitely lost: 0 bytes in 0 blocks
==14812==    indirectly lost: 0 bytes in 0 blocks
==14812==      possibly lost: 0 bytes in 0 blocks
==14812==    still reachable: 48 bytes in 2 blocks
==14812==         suppressed: 0 bytes in 0 blocks
==14812== Rerun with --leak-check=full to see details of leaked memory
==14812== 
==14812== For counts of detected and suppressed errors, rerun with: -v
==14812== ERROR SUMMARY: 7 errors from 5 contexts (suppressed: 0 from 0)

GdalType as Pulic

I would like to be able to write a function that loads a raster dataset into an ndarray. For instance:
fn read_as_array<T: Copy + From<GdalType>, P: AsRef<Path>>(path: P) -> Result<ndarray::Array2<T>> { ... }

This would internally coerce the GdalType values into their corresponding primitive number type. Unfortunately, GdalType is currently marked private and this is not possible. Would it be possible to mark it as pub or am I approaching this problem incorrectly?

Cannot compile GDAL in windows - dataset.rs - convert::From<[_; 0] is not implemented

The compilation is failing to with the following messages:

Compiling gdal v0.7.2
error[E0277]: the trait bound std::vec::Vec<_>: std::convert::From<[_; 0]> is not satisfied
--> C:\Users\caioh.cargo\registry\src\github.com-1ecc6299db9ec823\gdal-0.7.2\src\dataset.rs:75:21
|
75 | None => Vec::from([]),
| ^^^^^^^^^ the trait std::convert::From<[_; 0]> is not implemented for std::vec::Vec<_>
|
= help: the following implementations were found:
<std::vec::Vec as std::convert::From<&[T]>>
<std::vec::Vec as std::convert::From<&mut [T]>>
<std::vec::Vec as std::convert::From<std::borrow::Cow<'a, [T]>>>
<std::vec::Vec as std::convert::From<std::boxed::Box<[T]>>>
and 5 others
= note: required by std::convert::From::from

error[E0277]: the trait bound std::vec::Vec<_>: std::convert::From<[_; 0]> is not satisfied
--> C:\Users\caioh.cargo\registry\src\github.com-1ecc6299db9ec823\gdal-0.7.2\src\dataset.rs:96:21
|
96 | None => Vec::from([]),
| ^^^^^^^^^ the trait std::convert::From<[_; 0]> is not implemented for std::vec::Vec<_>
|
= help: the following implementations were found:
<std::vec::Vec as std::convert::From<&[T]>>
<std::vec::Vec as std::convert::From<&mut [T]>>
<std::vec::Vec as std::convert::From<std::borrow::Cow<'a, [T]>>>
<std::vec::Vec as std::convert::From<std::boxed::Box<[T]>>>
and 5 others
= note: required by std::convert::From::from

error[E0277]: the trait bound std::vec::Vec<_>: std::convert::From<[_; 0]> is not satisfied
--> C:\Users\caioh.cargo\registry\src\github.com-1ecc6299db9ec823\gdal-0.7.2\src\dataset.rs:120:21
|
120 | None => Vec::from([]),
| ^^^^^^^^^ the trait std::convert::From<[_; 0]> is not implemented for std::vec::Vec<_>
|
= help: the following implementations were found:
<std::vec::Vec as std::convert::From<&[T]>>
<std::vec::Vec as std::convert::From<&mut [T]>>
<std::vec::Vec as std::convert::From<std::borrow::Cow<'a, [T]>>>
<std::vec::Vec as std::convert::From<std::boxed::Box<[T]>>>
and 5 others
= note: required by std::convert::From::from

error: aborting due to 3 previous errors

For more information about this error, try rustc --explain E0277.
error: could not compile gdal.

Provide read_into_slice ability in RasterBand

The library currently provides a RasterBand::read_as function, that allocates a buffer on the heap. It would be very convenient, if we could re-use the same buffer, and allow functionality to read data into an already allocated slice. This would save many heap allocations if reading chunks of large rasters in a loop.

A possible implementation would the following addition to RasterBand in src/raster/rasterband.rs. It is almost verbatim, the same code as read_as, except without an extra Vec allocation.

    /// Read into a slice `[T]` from a `Dataset`. T implements `GdalType`
    /// # Arguments
    /// * band_index - the band_index
    /// * window - the window position from top left
    /// * window_size - the window size (GDAL will interpolate data if window_size != buffer_size)
    /// * size - the desired size of the `Buffer`
    /// * buffer - the slice to copy into (length is checked with `assert`)
    pub fn read_into_slice<T: Copy + GdalType>(
        &self,
        window: (isize, isize),
        window_size: (usize, usize),
        size: (usize, usize),
        buffer: &mut [T],
    ) -> Result<()>
    {
        let pixels = (size.0 * size.1) as usize;
        assert_eq!(buffer.len(), pixels);

        //let no_data:
        let rv = unsafe {
            gdal_sys::GDALRasterIO(
                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,
                buffer as *mut [T] as *mut T as GDALRasterBandH,
                size.0 as c_int,
                size.1 as c_int,
                T::gdal_type(),
                0,
                0
            )
        };
        if rv != CPLErr::CE_None {
            Err(_last_cpl_err(rv))?;
        }

        Ok(())
    }

Happy to provide a PR if it makes sense.

Accessing metadata (GDALMayorObject)

GDALMayorObject is the base class for everything in GDAL: GDALDataset, GDALRasterBandand OGRLayer. Also since GDAL 2.0 the separation between raster and vector datasets was removed. Every dataset is now a GDALDataset (OGRDataSource is deprecated).

GDALMayorObject provides methods to access metadata e.g. GetMetadataItem. Sadly there is no way to access metadata from rust-gdal.

My current idea to provide access to metadata for all GDALMayorObject based types is the following:

  • Add a (non exported) trait to access the c-pointer:
trait MajorObject {
    unsafe fn get_gdal_object_ptr(&self) -> *const c_void;
}
  • Add a trait with default implementations (using the pointer) to access the metadata:
pub trait Metadata: MajorObject {
    fn get_metadata_item(&self, key: &str, domain: &str) -> Option<String> { ... }
    ...
}
  • Implement MajorObject and Metadata for all matching types:
pub struct Dataset {
    c_dataset: *const c_void,
}

impl MajorObject for Dataset {
    unsafe fn get_gdal_object_ptr(&self) -> *const c_void {
        self.c_dataset
    }
}

impl Metadata for Dataset {}

I have a working implementation of this approach, but I would like to hear other ideas :)

test failures on macos

Hi, I'm new to this repository. ๐Ÿ‘‹

I just built from master and am seeing these test failures:

running 70 tests
test config::tests::test_set_option_with_embedded_nul ... ok
test config::tests::test_clear_option ... ok
test config::tests::test_set_get_option ... ok
test raster::tests::test_get_description ... ok
test raster::tests::test_get_driver_by_name ... ok
test raster::tests::test_create_with_band_type ... ok
test raster::tests::test_create ... ok
test raster::tests::test_get_band_type ... ok
test raster::tests::test_geo_transform ... ok
test raster::tests::test_get_metadata_item ... ok
test raster::tests::test_get_raster_block_size ... ok
test raster::tests::test_create_copy ... ok
test raster::tests::test_get_no_data_value ... ok
test raster::tests::test_get_raster_count ... ok
test raster::tests::test_get_rasterband ... ok
test raster::tests::test_get_projection ... ok
test raster::tests::test_get_offset ... FAILED
test raster::tests::test_get_dataset_driver ... ok
test raster::tests::test_get_rasterband_block_size ... ok
test raster::tests::test_get_rasterband_size ... ok
test raster::tests::test_get_raster_size ... ok
test raster::tests::test_get_scale ... FAILED
test raster::tests::test_set_no_data_value ... ok
test raster::tests::test_set_metadata_item ... ok
test raster::tests::test_write_raster ... ok
test raster::tests::test_open ... ok
test raster::tests::test_read_full_raster_as ... ok
test raster::tests::test_read_raster ... ok
test raster::tests::test_read_raster_as ... ok
test spatial_ref::tests::authority ... ok
test spatial_ref::tests::from_esri_to_proj4 ... ok
test spatial_ref::tests::from_epsg_to_wkt_proj4 ... FAILED
test spatial_ref::tests::auto_identify ... ok
test vector::geometry::tests::test_is_empty ... ok
test vector::geometry::tests::test_area ... ok
test vector::ops::geometry::intersection::tests::test_intersection_no_gdal_ptr ... ok
test spatial_ref::tests::from_wkt_to_proj4 ... ok
test vector::ops::geometry::intersection::tests::test_intersection_no_intersects ... ok
test vector::tests::convert_geo::test_import_export_geometrycollection ... ok
test spatial_ref::tests::comparison ... ok
test vector::ops::geometry::intersection::tests::test_intersection_success ... ok
test vector::tests::convert_geo::test_import_export_linestring ... ok
test vector::tests::convert_geo::test_import_export_multipoint ... ok
test vector::tests::convert_geo::test_import_export_multilinestring ... ok
test vector::tests::convert_geo::test_import_export_multipolygon ... ok
test vector::tests::convert_geo::test_import_export_polygon ... ok
test vector::tests::convert_geo::test_import_export_point ... ok
test vector::tests::test_convex_hull ... ok
test vector::tests::test_create_bbox ... ok
test spatial_ref::tests::from_proj4_to_wkt ... FAILED
test vector::geometry::tests::test_spatial_reference ... ok
test vector::tests::test_float_field ... ok
test vector::tests::test_get_layer_by_name ... ok
test vector::tests::test_json ... ok
test vector::tests::test_geom_fields ... FAILED
test vector::tests::test_geom_accessors ... ok
test vector::tests::test_iterate_features ... ok
test spatial_ref::tests::transform_ogr_geometry ... FAILED
test vector::tests::test_layer_count ... ok
test vector::tests::test_layer_spatial_reference ... ok
test vector::tests::test_layer_extent ... ok
test vector::tests::test_schema ... ok
test version::tests::test_version_info ... ok
test vector::tests::test_string_field ... ok
test vector::tests::test_missing_field ... ok
test spatial_ref::tests::transform_coordinates ... FAILED
test vector::tests::test_spatial_filter ... ok
test spatial_ref::tests::failing_transformation ... ok
test vector::tests::test_wkt ... ok
test vector::tests::test_write_features ... ok

failures:

---- raster::tests::test_get_offset stdout ----
thread 'raster::tests::test_get_offset' panicked at 'assertion failed: `(left == right)`
  left: `None`,
 right: `Some(0.0)`', src/raster/tests.rs:347:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- raster::tests::test_get_scale stdout ----
thread 'raster::tests::test_get_scale' panicked at 'assertion failed: `(left == right)`
  left: `None`,
 right: `Some(1.0)`', src/raster/tests.rs:339:5

---- spatial_ref::tests::from_epsg_to_wkt_proj4 stdout ----
thread 'spatial_ref::tests::from_epsg_to_wkt_proj4' panicked at 'assertion failed: `(left == right)`
  left: `"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\"]]"`,
 right: `"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\"]],AXIS[\"Latitude\",NORTH],AXIS[\"Longitude\",EAST],AUTHORITY[\"EPSG\",\"4326\"]]"`', src/spatial_ref/tests.rs:39:5

---- spatial_ref::tests::from_proj4_to_wkt stdout ----
thread 'spatial_ref::tests::from_proj4_to_wkt' panicked at 'assertion failed: `(left == right)`
  left: `"PROJCS[\"unknown\",GEOGCS[\"unknown\",DATUM[\"Unknown based on GRS80 ellipsoid\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]]],PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"latitude_of_center\",52],PARAMETER[\"longitude_of_center\",10],PARAMETER[\"false_easting\",4321000],PARAMETER[\"false_northing\",3210000],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH]]"`,
 right: `"PROJCS[\"unnamed\",GEOGCS[\"GRS 1980(IUGG, 1980)\",DATUM[\"unknown\",SPHEROID[\"GRS80\",6378137,298.257222101]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433]],PROJECTION[\"Lambert_Azimuthal_Equal_Area\"],PARAMETER[\"latitude_of_center\",52],PARAMETER[\"longitude_of_center\",10],PARAMETER[\"false_easting\",4321000],PARAMETER[\"false_northing\",3210000],UNIT[\"Meter\",1]]"`', src/spatial_ref/tests.rs:28:5

---- vector::tests::test_geom_fields stdout ----
thread 'vector::tests::test_geom_fields' panicked at 'assertion failed: geom_field.spatial_ref().unwrap() == spatial_ref2', src/vector/tests/mod.rs:216:5

---- spatial_ref::tests::transform_ogr_geometry stdout ----
thread 'spatial_ref::tests::transform_ogr_geometry' panicked at 'assertion failed: `(left == right)`
  left: `"POLYGON ((5509543.1508097 1716062.19161922,5467122.00033 1980151.20428024,5623571.02849272 2010213.31025368,5671834.92154436 1746968.07828026,5509543.1508097 1716062.19161922))"`,
 right: `"POLYGON ((7166004.81833779 564241.992615556,7403258.72613859 654346.74777158,7345135.05829164 847853.579444857,7112561.07890564 758804.633233282,7166004.81833779 564241.992615556))"`', src/spatial_ref/tests.rs:115:5

---- spatial_ref::tests::transform_coordinates stdout ----
thread 'spatial_ref::tests::transform_coordinates' panicked at 'assertion failed: f > 0.99999', src/lib.rs:39:5


failures:
    raster::tests::test_get_offset
    raster::tests::test_get_scale
    spatial_ref::tests::from_epsg_to_wkt_proj4
    spatial_ref::tests::from_proj4_to_wkt
    spatial_ref::tests::transform_coordinates
    spatial_ref::tests::transform_ogr_geometry
    vector::tests::test_geom_fields

test result: FAILED. 63 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out

Travis looks to be passing all the tests, running gdal 2.0.

I'm using gdal 3.1.2 (installed via homebrew).

Is it expected for the tests to fail?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.