Skip to content

Commit

Permalink
Merge #393
Browse files Browse the repository at this point in the history
393: Pass `GDT_Unknown` for vector layers r=metasim a=lnicola

- [x] I agree to follow the project's [code of conduct](https://github.com/georust/gdal/blob/master/CODE_OF_CONDUCT.md).
- [x] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users.
---

Closes #392

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
  • Loading branch information
bors[bot] and lnicola committed May 8, 2023
2 parents f1aa109 + 938aff5 commit 0511f90
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::cpl::CslStringList;
use crate::dataset::Dataset;
use crate::gdal_major_object::MajorObject;
use crate::metadata::Metadata;
use crate::raster::{GdalType, RasterCreationOption};
use crate::raster::{GdalDataType, GdalType, RasterCreationOption};
use crate::utils::{_last_cpl_err, _last_null_pointer_err, _path_to_c_string, _string};

use crate::errors::*;
Expand Down Expand Up @@ -181,22 +181,24 @@ impl Driver {
bands: isize,
options: &[RasterCreationOption],
) -> Result<Dataset> {
Self::_create_with_band_type_with_options::<T>(
Self::_create_with_band_type_with_options(
self,
filename.as_ref(),
size_x,
size_y,
bands,
T::datatype(),
options,
)
}

fn _create_with_band_type_with_options<T: GdalType>(
fn _create_with_band_type_with_options(
&self,
filename: &Path,
size_x: isize,
size_y: isize,
bands: isize,
data_type: GdalDataType,
options: &[RasterCreationOption],
) -> Result<Dataset> {
let mut options_c = CslStringList::new();
Expand All @@ -212,7 +214,7 @@ impl Driver {
size_x as c_int,
size_y as c_int,
bands as c_int,
T::gdal_ordinal(),
data_type as u32,
options_c.as_ptr(),
)
};
Expand All @@ -227,7 +229,15 @@ impl Driver {
/// Convenience for creating a vector-only dataset from a compatible driver.
/// [Details](https://gdal.org/api/gdaldriver_cpp.html#_CPPv4N10GDALDriver6CreateEPKciii12GDALDataType12CSLConstList)
pub fn create_vector_only<P: AsRef<Path>>(&self, filename: P) -> Result<Dataset> {
self.create_with_band_type::<u8, _>(filename, 0, 0, 0)
let options = [];
self._create_with_band_type_with_options(
filename.as_ref(),
0,
0,
0,
GdalDataType::Unknown,
&options,
)
}

/// Delete named dataset.
Expand Down

0 comments on commit 0511f90

Please sign in to comment.