From 938aff5bcfaf01de3dfa0f2d15e59ec441510361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Fri, 5 May 2023 12:27:02 +0300 Subject: [PATCH] Pass GDT_Unknown for vector layers --- src/driver.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 26b431e7c..06b0953d9 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -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::*; @@ -181,22 +181,24 @@ impl Driver { bands: isize, options: &[RasterCreationOption], ) -> Result { - Self::_create_with_band_type_with_options::( + 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( + fn _create_with_band_type_with_options( &self, filename: &Path, size_x: isize, size_y: isize, bands: isize, + data_type: GdalDataType, options: &[RasterCreationOption], ) -> Result { let mut options_c = CslStringList::new(); @@ -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(), ) }; @@ -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>(&self, filename: P) -> Result { - self.create_with_band_type::(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.