From 57bb3b9663e8146df994ad146119a989980a9ab7 Mon Sep 17 00:00:00 2001 From: Milos Markovic Date: Wed, 5 Jul 2023 08:48:24 +0200 Subject: [PATCH 1/2] Added Send trait to vector structs --- src/dataset.rs | 2 ++ src/spatial_ref/srs.rs | 2 ++ src/vector/defn.rs | 2 ++ src/vector/feature.rs | 2 ++ src/vector/geometry.rs | 2 ++ src/vector/layer.rs | 2 ++ 6 files changed, 12 insertions(+) diff --git a/src/dataset.rs b/src/dataset.rs index e02487dab..c52b11211 100644 --- a/src/dataset.rs +++ b/src/dataset.rs @@ -282,6 +282,8 @@ impl<'a> Default for LayerOptions<'a> { } } +unsafe impl Send for LayerOptions<'_> {} + // GDAL Docs state: The returned dataset should only be accessed by one thread at a time. // See: https://gdal.org/api/raster_c_api.html#_CPPv48GDALOpenPKc10GDALAccess // Additionally, VRT Datasets are not safe before GDAL 2.3. diff --git a/src/spatial_ref/srs.rs b/src/spatial_ref/srs.rs index 64353a4ec..f19dd6c00 100644 --- a/src/spatial_ref/srs.rs +++ b/src/spatial_ref/srs.rs @@ -594,6 +594,8 @@ impl SpatialRef { } } +unsafe impl Send for SpatialRef {} + #[derive(Debug, Clone)] /// Defines the bounding area of valid use for a [`SpatialRef`]. /// diff --git a/src/vector/defn.rs b/src/vector/defn.rs index 2e8daf5b2..35f70ef57 100644 --- a/src/vector/defn.rs +++ b/src/vector/defn.rs @@ -61,6 +61,8 @@ impl Defn { } } +unsafe impl Send for Defn {} + pub struct FieldIterator<'a> { defn: &'a Defn, c_feature_defn: OGRFeatureDefnH, diff --git a/src/vector/feature.rs b/src/vector/feature.rs index 872605eda..3ed823c05 100644 --- a/src/vector/feature.rs +++ b/src/vector/feature.rs @@ -668,6 +668,8 @@ impl<'a> Feature<'a> { } } +unsafe impl Send for Feature<'_> {} + pub struct FieldValueIterator<'a> { feature: &'a Feature<'a>, idx: i32, diff --git a/src/vector/geometry.rs b/src/vector/geometry.rs index 54a337c85..a4c589549 100644 --- a/src/vector/geometry.rs +++ b/src/vector/geometry.rs @@ -381,6 +381,8 @@ impl Debug for GeometryRef<'_> { } } +unsafe impl Send for GeometryRef<'_> {} + #[cfg(test)] mod tests { use super::*; diff --git a/src/vector/layer.rs b/src/vector/layer.rs index 84ba9b381..c1d2ec20f 100644 --- a/src/vector/layer.rs +++ b/src/vector/layer.rs @@ -137,6 +137,8 @@ impl<'a> Layer<'a> { } } +unsafe impl Send for Layer<'_> {} + /// Layer in a vector dataset /// /// ``` From 07010b0a9c08b8c17f799b527ae59609b7d34124 Mon Sep 17 00:00:00 2001 From: Milos Markovic Date: Wed, 5 Jul 2023 09:41:54 +0200 Subject: [PATCH 2/2] Fixed failing tests. --- src/spatial_ref/srs.rs | 2 +- src/vector/ops/transformations.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spatial_ref/srs.rs b/src/spatial_ref/srs.rs index f19dd6c00..4efd6f8ef 100644 --- a/src/spatial_ref/srs.rs +++ b/src/spatial_ref/srs.rs @@ -637,7 +637,7 @@ mod tests { #[cfg(not(major_ge_3))] assert_eq!(spatial_ref.to_wkt().unwrap(), "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]]"); #[cfg(major_ge_3)] - assert_eq!(spatial_ref.to_wkt().unwrap(), "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]]"); + assert_eq!(spatial_ref.to_wkt().unwrap(), "PROJCS[\"unknown\",GEOGCS[\"unknown\",DATUM[\"Unknown based on GRS 1980 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]]"); } #[test] diff --git a/src/vector/ops/transformations.rs b/src/vector/ops/transformations.rs index e41e701aa..fcf4dd414 100644 --- a/src/vector/ops/transformations.rs +++ b/src/vector/ops/transformations.rs @@ -255,7 +255,7 @@ mod tests { let triangles = Geometry::from_wkt( "POLYGON ((20 35,10 10,30 5,45 20,20 35),(30 20,20 15,20 25,30 20))", )?; - assert_eq!(donut.simplify_preserve_topology(100.0)?, triangles); + assert_eq!(donut.simplify_preserve_topology(20.0)?, triangles); Ok(()) }