Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Send trait to vector structs #419

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ impl<'a> Default for LayerOptions<'a> {
}
}

unsafe impl Send for LayerOptions<'_> {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is safe, because the struct contains references to types that are not Sync. But LayerOptions generally doesn't need to be Send anyway because it's just a pack of parameters.


// 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.
Expand Down
4 changes: 3 additions & 1 deletion src/spatial_ref/srs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ impl SpatialRef {
}
}

unsafe impl Send for SpatialRef {}

#[derive(Debug, Clone)]
/// Defines the bounding area of valid use for a [`SpatialRef`].
///
Expand Down Expand Up @@ -635,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]]");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CI is happy with this change, then so am I. But if not, it probably needs a version check; see e.g. a0d1d30

}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions src/vector/defn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ impl Defn {
}
}

unsafe impl Send for Defn {}

pub struct FieldIterator<'a> {
defn: &'a Defn,
c_feature_defn: OGRFeatureDefnH,
Expand Down
2 changes: 2 additions & 0 deletions src/vector/feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ impl<'a> Feature<'a> {
}
}

unsafe impl Send for Feature<'_> {}

pub struct FieldValueIterator<'a> {
feature: &'a Feature<'a>,
idx: i32,
Expand Down
2 changes: 2 additions & 0 deletions src/vector/geometry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ impl Debug for GeometryRef<'_> {
}
}

unsafe impl Send for GeometryRef<'_> {}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
2 changes: 2 additions & 0 deletions src/vector/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ impl<'a> Layer<'a> {
}
}

unsafe impl Send for Layer<'_> {}

/// Layer in a vector dataset
///
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/vector/ops/transformations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
Loading