Skip to content

Commit

Permalink
Rename the function and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Atreyagaurav committed Jan 3, 2024
1 parent 05f46c4 commit 83d60c6
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ impl DriverManager {
/// use gdal::DriverManager;
/// # fn main() -> gdal::errors::Result<()> {
/// let compatible_drivers =
/// DriverManager::get_drivers_for_filename("test.gpkg", true)
/// DriverManager::guess_drivers_for_write("test.gpkg", true)
/// .iter()
/// .map(|d| d.short_name())
/// .collect::<Vec<String>>();
Expand All @@ -437,7 +437,7 @@ impl DriverManager {
/// ```text
/// ["GPKG"]
/// ```
pub fn get_drivers_for_filename(filename: &str, is_vector: bool) -> Vec<Driver> {
pub fn guess_drivers_for_write(filename: &str, is_vector: bool) -> Vec<Driver> {
let ext = {
let filename = filename.to_ascii_lowercase();
let e = match filename.rsplit_once('.') {
Expand Down Expand Up @@ -557,41 +557,41 @@ mod tests {
fn test_driver_extension() {
// convert the driver into short_name for testing purposes
let drivers = |filename, is_vector| {
DriverManager::get_drivers_for_filename(filename, is_vector)
DriverManager::guess_drivers_for_write(filename, is_vector)
.iter()
.map(|d| d.short_name())
.collect::<HashSet<String>>()
};
let gdal_version: i64 = crate::version::version_info("VERSION_NUM").parse().unwrap();
if DriverManager::get_driver_by_name("ESRI Shapefile").is_ok() {
assert!(drivers("test.shp", true).contains("ESRI Shapefile"));
assert!(drivers("my.test.shp", true).contains("ESRI Shapefile"));
// `shp.zip` only supported from gdal version 3.1
// https://gdal.org/drivers/vector/shapefile.html#compressed-files
if gdal_version >= 3010000 {
assert!(drivers("test.shp.zip", true).contains("ESRI Shapefile"));
assert!(drivers("my.test.shp.zip", true).contains("ESRI Shapefile"));
}
}
if DriverManager::get_driver_by_name("GPKG").is_ok() {
assert!(drivers("test.gpkg", true).contains("GPKG"));
assert!(drivers("my.test.gpkg", true).contains("GPKG"));
// `gpkg.zip` only supported from gdal version 3.7
// https://gdal.org/drivers/vector/gpkg.html#compressed-files
if gdal_version >= 3070000 {
assert!(drivers("test.gpkg.zip", true).contains("GPKG"));
assert!(drivers("my.test.gpkg.zip", true).contains("GPKG"));
}
}
if DriverManager::get_driver_by_name("GTiff").is_ok() {
assert!(drivers("test.tiff", false).contains("GTiff"));
assert!(drivers("my.test.tiff", false).contains("GTiff"));
}
if DriverManager::get_driver_by_name("netCDF").is_ok() {
assert!(drivers("test.nc", false).contains("netCDF"));
}
if DriverManager::get_driver_by_name("Elasticsearch").is_ok() {
// Elasticsearch short name was ElasticSearch in older versions
if gdal_version >= 3010000 {
assert!(drivers("ES:test", true).contains("Elasticsearch"));
} else {
assert!(drivers("ES:test", true).contains("ElasticSearch"));
}
if DriverManager::get_driver_by_name("PostgreSQL").is_ok() {
assert!(drivers("PG:test", true).contains("PostgreSQL"));
}
}
}

0 comments on commit 83d60c6

Please sign in to comment.