From 0f7a2ce8d52378fc39e9a368ce6fbfd02056387e Mon Sep 17 00:00:00 2001 From: "Simeon H.K. Fitch" Date: Sun, 7 May 2023 18:35:20 -0400 Subject: [PATCH 1/4] Updated `set.rs` docs to be more consistent with those in `predicates.rs`. --- src/vector/ops/set.rs | 51 +++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/src/vector/ops/set.rs b/src/vector/ops/set.rs index fc3a6d391..f47cf1e3b 100644 --- a/src/vector/ops/set.rs +++ b/src/vector/ops/set.rs @@ -4,20 +4,27 @@ use crate::vector::Geometry; /// /// These methods provide set operations over two geometries, producing a new geometry. impl Geometry { - /// Compute intersection. + /// Computes the [geometric intersection][intersection] of `self` and `other`. /// - /// Generates a new geometry which is the region of intersection of - /// the two geometries operated on. Call intersects (Not yet implemented) - /// to check if there is a region of intersection. - /// Geometry validity is not checked. In case you are unsure of the - /// validity of the input geometries, call IsValid() before, - /// otherwise the result might be wrong. + /// Generates a new geometry which is the region of intersection of the two geometries operated on. + /// + /// # Notes + /// * If you only need to determine if two geometries intersect and don't require + /// the resultant region, use [`Geometry::intersects`]. + /// * Geometry validity is not checked, and invalid geometry will generate unpredictable results. + /// Use [`Geometry::is_valid`] if validity might be in question. + /// * If GEOS is *not* enabled, this function will always return `None`. + /// You may check for GEOS support with [`VersionInfo::has_geos`][has_geos]. /// /// # Returns - /// `Some(geometry)` if both Geometries contain pointers - /// `None` if either geometry is missing the GDAL pointer, or there is an error. + /// * `Some(geometry)`: a new `Geometry` representing the computed intersection + /// * `None`: when the geometries do not intersect or result could not be computed + /// + /// See: [`OGR_G_Intersection`][OGR_G_Intersection] /// - /// See: [`OGR_G_Intersection`](https://gdal.org/api/vector_c_api.html#_CPPv418OGR_G_Intersection12OGRGeometryH12OGRGeometryH) + /// [OGR_G_Intersection]: https://gdal.org/api/vector_c_api.html#_CPPv418OGR_G_Intersection12OGRGeometryH12OGRGeometryH + /// [intersection]: https://en.wikipedia.org/wiki/Intersection_(geometry) + /// [has_geos]: crate::version::VersionInfo::has_geos pub fn intersection(&self, other: &Self) -> Option { if !self.has_gdal_ptr() { return None; @@ -33,19 +40,25 @@ impl Geometry { Some(unsafe { Geometry::with_c_geometry(ogr_geom, true) }) } - /// Compute union. + /// Computes the [geometric union][union] of `self` and `other`. /// - /// Generates a new geometry which is the region of union of - /// the two geometries operated on. - /// Geometry validity is not checked. In case you are unsure of the - /// validity of the input geometries, call IsValid() before, - /// otherwise the result might be wrong. + /// Generates a new geometry which is the union of the two geometries operated on. + /// + /// # Notes + /// * Geometry validity is not checked, and invalid geometry will generate unpredictable results. + /// Use [`Geometry::is_valid`] if validity might be in question. + /// * If GEOS is *not* enabled, this function will always return `None`. + /// You may check for GEOS support with [`VersionInfo::has_geos`][has_geos]. /// /// # Returns - /// `Some(geometry)` if both Geometries contain pointers. - /// `None` if either geometry is missing the GDAL pointer, or there is an error. + /// * `Some(geometry)`: a new `Geometry` representing the computed union + /// * `None`: when the union was not able to be computed + /// + /// See: [`OGR_G_Union`][OGR_G_Union] /// - /// See: [`OGR_G_Union`](https://gdal.org/api/vector_c_api.html#_CPPv419OGR_G_UnionCascaded12OGRGeometryH) + /// [OGR_G_Union]: https://gdal.org/api/vector_c_api.html#_CPPv411OGR_G_Union12OGRGeometryH12OGRGeometryH + /// [union]: https://en.wikipedia.org/wiki/Constructive_solid_geometry#Workings + /// [has_geos]: crate::version::VersionInfo::has_geos pub fn union(&self, other: &Self) -> Option { if !self.has_gdal_ptr() { return None; From 94081b9737d95cea6e9f3595a3c410e2240bd19b Mon Sep 17 00:00:00 2001 From: "Simeon H.K. Fitch" Date: Tue, 9 May 2023 13:04:46 -0400 Subject: [PATCH 2/4] Update src/vector/ops/set.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurențiu Nicola --- src/vector/ops/set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector/ops/set.rs b/src/vector/ops/set.rs index f47cf1e3b..d5bfe8e8c 100644 --- a/src/vector/ops/set.rs +++ b/src/vector/ops/set.rs @@ -14,7 +14,7 @@ impl Geometry { /// * Geometry validity is not checked, and invalid geometry will generate unpredictable results. /// Use [`Geometry::is_valid`] if validity might be in question. /// * If GEOS is *not* enabled, this function will always return `None`. - /// You may check for GEOS support with [`VersionInfo::has_geos`][has_geos]. + /// You may check for GEOS support with [`VersionInfo::has_geos`][has_geos]. /// /// # Returns /// * `Some(geometry)`: a new `Geometry` representing the computed intersection From 54c9e55eb6d6af369691ff6c345c2e20289898a6 Mon Sep 17 00:00:00 2001 From: "Simeon H.K. Fitch" Date: Tue, 9 May 2023 13:04:58 -0400 Subject: [PATCH 3/4] Update src/vector/ops/set.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurențiu Nicola --- src/vector/ops/set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector/ops/set.rs b/src/vector/ops/set.rs index d5bfe8e8c..313a781e3 100644 --- a/src/vector/ops/set.rs +++ b/src/vector/ops/set.rs @@ -48,7 +48,7 @@ impl Geometry { /// * Geometry validity is not checked, and invalid geometry will generate unpredictable results. /// Use [`Geometry::is_valid`] if validity might be in question. /// * If GEOS is *not* enabled, this function will always return `None`. - /// You may check for GEOS support with [`VersionInfo::has_geos`][has_geos]. + /// You may check for GEOS support with [`VersionInfo::has_geos`][has_geos]. /// /// # Returns /// * `Some(geometry)`: a new `Geometry` representing the computed union From 89ebd4df1a084be5b345710b7ca42f71afa6e97d Mon Sep 17 00:00:00 2001 From: "Simeon H.K. Fitch" Date: Tue, 9 May 2023 13:05:11 -0400 Subject: [PATCH 4/4] Update src/vector/ops/set.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Laurențiu Nicola --- src/vector/ops/set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vector/ops/set.rs b/src/vector/ops/set.rs index 313a781e3..b920772b9 100644 --- a/src/vector/ops/set.rs +++ b/src/vector/ops/set.rs @@ -52,7 +52,7 @@ impl Geometry { /// /// # Returns /// * `Some(geometry)`: a new `Geometry` representing the computed union - /// * `None`: when the union was not able to be computed + /// * `None`: when the union could not be computed /// /// See: [`OGR_G_Union`][OGR_G_Union] ///