Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/georust/gdal into pr/rman…
Browse files Browse the repository at this point in the history
…oka/161
  • Loading branch information
jdroenner committed Apr 25, 2021
2 parents dfee71c + 9bd2b3d commit 3fe326a
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 137 deletions.
241 changes: 127 additions & 114 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

## Unreleased

* **Breaking**: Make `Layer::features` iterator reset to
- **Breaking**: Make `Layer::features` iterator reset to
beginning, and borrow mutably.
* closes <https://github.com/georust/gdal/issues/159>

* **Breaking**: [Enforce borrow
- closes <https://github.com/georust/gdal/issues/159>

- **Breaking**: [Enforce borrow
semantics](https://github.com/georust/gdal/pull/161) on
methods of `Dataset`, `RasterBand`, and `Layer`.

1. Methods that do not modify the underlying structure take `&self`.
1. Methods that modify the underlying structure take `&mut self`.

Expand All @@ -21,42 +23,45 @@
// band needs to be mutable to set no-data value
band.set_no_data_value(0.0)?;
```

* Implement wrapper for `OGR_L_TestCapability`
* <https://github.com/georust/gdal/pull/160>

* **Breaking**: Use `DatasetOptions` to pass as `Dataset::open_ex` parameters and
add support for extended open flags.

```rust
use gdal::{ Dataset, DatasetOptions }

let dataset = Dataset::open_ex(
"roads.geojson",
DatasetOptions {
open_flags: GdalOpenFlags::GDAL_OF_UPDATE|GdalOpenFlags::GDAL_OF_VECTOR,
..DatasetOptions::default()
}
)
.unwrap();
```

`GDALAccess` values are supported using [`From`] implementation

```rust
Dataset::open_ex(
"roads.geojson",
DatasetOptions {
open_flags: GDALAccess::GA_Update.into(),
..DatasetOptions::default()
},
)
.unwrap();
```

* Add more functions to SpatialRef implementation
* <https://github.com/georust/gdal/pull/145>
* **Breaking**: Change `Feature::field` return type from

- **Breaking**: Upgrade to `ndarray 0.15`
- <https://github.com/georust/gdal/pull/175>
- Implement wrapper for `OGR_L_TestCapability`

- <https://github.com/georust/gdal/pull/160>

- **Breaking**: Use `DatasetOptions` to pass as `Dataset::open_ex` parameters and
add support for extended open flags.

```rust
use gdal::{ Dataset, DatasetOptions }

let dataset = Dataset::open_ex(
"roads.geojson",
DatasetOptions {
open_flags: GdalOpenFlags::GDAL_OF_UPDATE|GdalOpenFlags::GDAL_OF_VECTOR,
..DatasetOptions::default()
}
)
.unwrap();
```

`GDALAccess` values are supported using [`From`] implementation

```rust
Dataset::open_ex(
"roads.geojson",
DatasetOptions {
open_flags: GDALAccess::GA_Update.into(),
..DatasetOptions::default()
},
)
.unwrap();
```

- Add more functions to SpatialRef implementation
- <https://github.com/georust/gdal/pull/145>
- **Breaking**: Change `Feature::field` return type from
`Result<FieldValue>` to `Result<Option<FieldValue>>`. Fields
can be null. Before this change, if a field was null, the value
returned was the default value for the underlying type.
Expand Down Expand Up @@ -86,93 +91,101 @@
.into_string()
.unwrap();
```
* <https://github.com/georust/gdal/pull/134>
* Fixed potential race condition wrt. GDAL driver initialization
* <https://github.com/georust/gdal/pull/166>
* Add basic support to read overviews
* Added a `Dataset::build_overviews` method
* <https://github.com/georust/gdal/pull/164>
* BREAKING: update geo-types to 0.7.0. geo-types Coordinate<T> now implement `Debug`
* <https://github.com/georust/gdal/pull/146>
* Deprecated `SpatialRef::get_axis_mapping_strategy` - migrate to

- <https://github.com/georust/gdal/pull/134>

- Fixed potential race condition wrt. GDAL driver initialization
- <https://github.com/georust/gdal/pull/166>
- Add basic support to read overviews
- Added a `Dataset::build_overviews` method
- <https://github.com/georust/gdal/pull/164>
- BREAKING: update geo-types to 0.7.0. geo-types Coordinate<T> now implement `Debug`
- <https://github.com/georust/gdal/pull/146>
- Deprecated `SpatialRef::get_axis_mapping_strategy` - migrate to
`SpatialRef::axis_mapping_strategy` instead.
* Add support for reading and setting rasterband colour interpretations
* <https://github.com/georust/gdal/pull/144>
- Add support for reading and setting rasterband colour interpretations
- <https://github.com/georust/gdal/pull/144>
- Fixed memory leak in `Geometry::from_wkt`
- <https://github.com/georust/gdal/pull/172>

## 0.7.1
* fix docs.rs build for gdal-sys
* <https://github.com/georust/gdal/pull/128>

- fix docs.rs build for gdal-sys
- <https://github.com/georust/gdal/pull/128>

## 0.6.0 - 0.7.0
* Dataset layer iteration and FieldValue types
* https://github.com/georust/gdal/pull/126
* Fix i8 ptr instead of c_char ptr passed to OSRImportFromESRI()
* <https://github.com/georust/gdal/pull/123>
* Rename spatial_reference to spatial_ref
* <https://github.com/georust/gdal/pull/114>
* Replace get_extent force flag by get_extent and try_get_extent
* <https://github.com/georust/gdal/pull/113>
* Add support for transactions on datasets
* <https://github.com/georust/gdal/pull/109>
* Add feature_count{,_force} and implement Iterator::size_hint
* <https://github.com/georust/gdal/pull/108>
* Replace failure with thiserror
* <https://github.com/georust/gdal/pull/103>
* Ability to read into preallocated slice for rasterband
* <https://github.com/georust/gdal/pull/100>
* Datasets are Send (requires GDAL >= 2.3)
* <https://github.com/georust/gdal/pull/99>
* User GDALOpenEx
* <https://github.com/georust/gdal/pull/97>
* GDAL 2.0 conform structure / drop GDAL 1.x
* <https://github.com/georust/gdal/pull/96>
* Inplace functions use mutable refs
* <https://github.com/georust/gdal/pull/93>
* Detect GDAL version at build time / remove version features
* <https://github.com/georust/gdal/pull/92>
* Add support for delaunay_triangulation and simplify functions
* <https://github.com/georust/gdal/pull/91>
* Add support for 3d points
* <https://github.com/georust/gdal/pull/90>
* Additional metadata retrieval options
* <https://github.com/georust/gdal/pull/88>
* Support for GDAL 3 in CI
* <https://github.com/georust/gdal/pull/86>
* Support for Integer64
* <https://github.com/georust/gdal/pull/80>
* Geometry Intersection trait
* <https://github.com/georust/gdal/pull/78>
* Rust 2018
* <https://github.com/georust/gdal/pull/75>
* support for date and time fields
* <https://github.com/georust/gdal/pull/72>
* Prebuild bindings
* <https://github.com/georust/gdal/pull/69>
* Support for ndarray
* <https://github.com/georust/gdal/pull/68>

- Dataset layer iteration and FieldValue types
- https://github.com/georust/gdal/pull/126
- Fix i8 ptr instead of c_char ptr passed to OSRImportFromESRI()
- <https://github.com/georust/gdal/pull/123>
- Rename spatial_reference to spatial_ref
- <https://github.com/georust/gdal/pull/114>
- Replace get_extent force flag by get_extent and try_get_extent
- <https://github.com/georust/gdal/pull/113>
- Add support for transactions on datasets
- <https://github.com/georust/gdal/pull/109>
- Add feature_count{,\_force} and implement Iterator::size_hint
- <https://github.com/georust/gdal/pull/108>
- Replace failure with thiserror
- <https://github.com/georust/gdal/pull/103>
- Ability to read into preallocated slice for rasterband
- <https://github.com/georust/gdal/pull/100>
- Datasets are Send (requires GDAL >= 2.3)
- <https://github.com/georust/gdal/pull/99>
- User GDALOpenEx
- <https://github.com/georust/gdal/pull/97>
- GDAL 2.0 conform structure / drop GDAL 1.x
- <https://github.com/georust/gdal/pull/96>
- Inplace functions use mutable refs
- <https://github.com/georust/gdal/pull/93>
- Detect GDAL version at build time / remove version features
- <https://github.com/georust/gdal/pull/92>
- Add support for delaunay_triangulation and simplify functions
- <https://github.com/georust/gdal/pull/91>
- Add support for 3d points
- <https://github.com/georust/gdal/pull/90>
- Additional metadata retrieval options
- <https://github.com/georust/gdal/pull/88>
- Support for GDAL 3 in CI
- <https://github.com/georust/gdal/pull/86>
- Support for Integer64
- <https://github.com/georust/gdal/pull/80>
- Geometry Intersection trait
- <https://github.com/georust/gdal/pull/78>
- Rust 2018
- <https://github.com/georust/gdal/pull/75>
- support for date and time fields
- <https://github.com/georust/gdal/pull/72>
- Prebuild bindings
- <https://github.com/georust/gdal/pull/69>
- Support for ndarray
- <https://github.com/georust/gdal/pull/68>

## 0.5.0

* [Bump geo-types from 0.3 -> 0.4](https://github.com/georust/gdal/pull/71)
* [Allow reading block-size of Rasters](https://github.com/georust/gdal/pull/67)
* [Add prebuilt-bindings GDAL 2.3 and GDAL 2.4](https://github.com/georust/gdal/pull/69)
* [Make GdalType trait public](https://github.com/georust/gdal/pull/66)
* [RasterBand to Ndarray, with failure](https://github.com/georust/gdal/pull/68)
- [Bump geo-types from 0.3 -> 0.4](https://github.com/georust/gdal/pull/71)
- [Allow reading block-size of Rasters](https://github.com/georust/gdal/pull/67)
- [Add prebuilt-bindings GDAL 2.3 and GDAL 2.4](https://github.com/georust/gdal/pull/69)
- [Make GdalType trait public](https://github.com/georust/gdal/pull/66)
- [RasterBand to Ndarray, with failure](https://github.com/georust/gdal/pull/68)

## 0.4.0
* [Migrate to the `geo-types` crate](https://github.com/georust/gdal/pull/60)
* [Replace `error-chain` with `failure`](https://github.com/georust/gdal/pull/58)
* [Use `bindgen` to generate the low-level bindings](https://github.com/georust/gdal/pull/55)

- [Migrate to the `geo-types` crate](https://github.com/georust/gdal/pull/60)
- [Replace `error-chain` with `failure`](https://github.com/georust/gdal/pull/58)
- [Use `bindgen` to generate the low-level bindings](https://github.com/georust/gdal/pull/55)

## 0.3.0

* [Add support for creating a SpatialRef from a esri "wkt" definition](https://github.com/georust/gdal/pull/37)
* [Travis now uses GDAL 2.x](https://github.com/georust/gdal/pull/36)
* [API extensions](https://github.com/georust/gdal/pull/35)
* [Extend the existing possibilities of writing ogr datasets](https://github.com/georust/gdal/pull/31)
* [Allow to transform ogr geometries to other SRS](https://github.com/georust/gdal/pull/29)
* [Move ffi into a seperate crate](https://github.com/georust/gdal/pull/26)
* [Added rasterband.rs and moved all band functions](https://github.com/georust/gdal/pull/24)
- [Add support for creating a SpatialRef from a esri "wkt" definition](https://github.com/georust/gdal/pull/37)
- [Travis now uses GDAL 2.x](https://github.com/georust/gdal/pull/36)
- [API extensions](https://github.com/georust/gdal/pull/35)
- [Extend the existing possibilities of writing ogr datasets](https://github.com/georust/gdal/pull/31)
- [Allow to transform ogr geometries to other SRS](https://github.com/georust/gdal/pull/29)
- [Move ffi into a seperate crate](https://github.com/georust/gdal/pull/26)
- [Added rasterband.rs and moved all band functions](https://github.com/georust/gdal/pull/24)

## 0.2.1

* [First version of metadata handling](https://github.com/georust/gdal/pull/21)
- [First version of metadata handling](https://github.com/georust/gdal/pull/21)
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ thiserror = "1.0"
libc = "0.2"
geo-types = { version = "0.7.0" }
gdal-sys = { path = "gdal-sys", version = "^0.3"}
ndarray = {version = "0.14", optional = true }
ndarray = {version = "0.15", optional = true }
chrono = { version = "0.4", optional = true }
bitflags = "1.2"

Expand Down
2 changes: 1 addition & 1 deletion gdal-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ edition = "2018"
libc = "0.2"

[build-dependencies]
bindgen = { version = "0.57", optional = true }
bindgen = { version = "0.58", optional = true }
pkg-config = "0.3"
semver = "0.11"
12 changes: 6 additions & 6 deletions gdal-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ pub fn write_bindings(include_paths: Vec<String>, out_path: &Path) {
.header("wrapper.h")
.constified_enum_module(".*")
.ctypes_prefix("libc")
.whitelist_function("CPL.*")
.whitelist_function("GDAL.*")
.whitelist_function("OGR.*")
.whitelist_function("OSR.*")
.whitelist_function("OCT.*")
.whitelist_function("VSI.*");
.allowlist_function("CPL.*")
.allowlist_function("GDAL.*")
.allowlist_function("OGR.*")
.allowlist_function("OSR.*")
.allowlist_function("OCT.*")
.allowlist_function("VSI.*");

for path in include_paths {
builder = builder.clang_arg("-I");
Expand Down
1 change: 1 addition & 0 deletions gdal-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(clippy::upper_case_acronyms)]

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
12 changes: 6 additions & 6 deletions src/spatial_ref/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ fn comparison() {
let spatial_ref4 = SpatialRef::from_proj4("+proj=longlat +datum=WGS84 +no_defs ").unwrap();
let spatial_ref5 = SpatialRef::from_esri("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]]").unwrap();

assert_eq!(true, spatial_ref1 == spatial_ref2);
assert_eq!(false, spatial_ref2 == spatial_ref3);
assert_eq!(true, spatial_ref4 == spatial_ref2);
assert_eq!(true, spatial_ref5 == spatial_ref4);
assert!(spatial_ref1 == spatial_ref2);
assert!(spatial_ref2 != spatial_ref3);
assert!(spatial_ref4 == spatial_ref2);
assert!(spatial_ref5 == spatial_ref4);
}

#[test]
Expand Down Expand Up @@ -155,7 +155,7 @@ fn failing_transformation() {

let trafo = CoordTransform::new(&wgs84, &dhd_2).unwrap();
let r = trafo.transform_coords(&mut x, &mut y, &mut z);
assert_eq!(r.is_err(), true);
assert!(r.is_err());

let wgs84 = SpatialRef::from_epsg(4326).unwrap();
let webmercator = SpatialRef::from_epsg(3857).unwrap();
Expand All @@ -174,7 +174,7 @@ fn failing_transformation() {
let trafo = CoordTransform::new(&wgs84, &webmercator).unwrap();
let r = trafo.transform_coords(&mut x, &mut y, &mut z);

assert_eq!(r.is_err(), true);
assert!(r.is_err());
if let GdalError::InvalidCoordinateRange { .. } = r.unwrap_err() {
// assert_eq!(msg, &Some("latitude or longitude exceeded limits".into()));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/vector/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ impl<'a> Feature<'a> {
if rv != OGRErr::OGRERR_NONE {
return Err(GdalError::OgrError {
err: rv,
method_name: "OGR_G_SetGeometry",
method_name: "OGR_F_SetGeometry",
});
}
self.geometry[0] = geom;
Expand Down
8 changes: 5 additions & 3 deletions src/vector/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::spatial_ref::{CoordTransform, SpatialRef};
use crate::utils::{_last_null_pointer_err, _string};
use gdal_sys::{self, OGRErr, OGRGeometryH, OGRwkbGeometryType};
use libc::{c_double, c_int, c_void};
use libc::{c_char, c_double, c_int, c_void};
use std::cell::RefCell;
use std::ffi::CString;
use std::fmt::{self, Debug};
Expand Down Expand Up @@ -48,7 +48,7 @@ impl Geometry {
/// This method operates on a raw C pointer
pub unsafe fn set_c_geometry(&self, c_geometry: OGRGeometryH) {
assert!(!self.has_gdal_ptr());
assert_eq!(self.owned, false);
assert!(!self.owned);
*(self.c_geometry_ref.borrow_mut()) = Some(c_geometry);
}

Expand All @@ -75,7 +75,9 @@ impl Geometry {
/// [WKT](https://en.wikipedia.org/wiki/Well-known_text) string.
pub fn from_wkt(wkt: &str) -> Result<Geometry> {
let c_wkt = CString::new(wkt)?;
let mut c_wkt_ptr = c_wkt.into_raw();
// OGR_G_CreateFromWkt does not write to the pointed-to memory, but this is not reflected
// in its signature (`char**` instead of `char const**`), so we need a scary looking cast.
let mut c_wkt_ptr = c_wkt.as_ptr() as *mut c_char;
let mut c_geom = null_mut();
let rv = unsafe { gdal_sys::OGR_G_CreateFromWkt(&mut c_wkt_ptr, null_mut(), &mut c_geom) };
if rv != OGRErr::OGRERR_NONE {
Expand Down
1 change: 1 addition & 0 deletions src/vector/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::{convert::TryInto, ffi::CString, marker::PhantomData};
use crate::errors::*;

/// Layer capabilities
#[allow(clippy::upper_case_acronyms)]
pub enum LayerCaps {
/// Layer capability for random read
OLCRandomRead,
Expand Down
Loading

0 comments on commit 3fe326a

Please sign in to comment.