Skip to content

Commit

Permalink
Deny missing docs from geoarrow::scalar (#958)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored Dec 20, 2024
1 parent 21264b5 commit 11abe73
Show file tree
Hide file tree
Showing 23 changed files with 137 additions and 73 deletions.
34 changes: 17 additions & 17 deletions js/src/algorithm/geo/skew.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::broadcasting::BroadcastableFloat;
use crate::data::*;
use crate::scalar::Point;
// use crate::scalar::Point;
use wasm_bindgen::prelude::*;

macro_rules! impl_skew {
Expand Down Expand Up @@ -28,22 +28,22 @@ macro_rules! impl_skew {
Skew::skew_xy(&self.0, &degrees_x.0, &degrees_y.0).into()
}

/// An affine transformation which skews a geometry around a point of `origin`, sheared
/// by an angle along the x and y dimensions.
///
/// The point of origin is *usually* given as the 2D bounding box centre of the
/// geometry, in which case you can just use [`skew`](Self::skew) or
/// [`skew_xy`](Self::skew_xy), but this method allows you to specify any point.
#[wasm_bindgen(js_name = skewAroundPoint)]
pub fn skew_around_point(
&self,
degrees_x: BroadcastableFloat,
degrees_y: BroadcastableFloat,
origin: Point,
) -> Self {
use geoarrow::algorithm::geo::Skew;
Skew::skew_around_point(&self.0, &degrees_x.0, &degrees_y.0, origin.0.into()).into()
}
// /// An affine transformation which skews a geometry around a point of `origin`, sheared
// /// by an angle along the x and y dimensions.
// ///
// /// The point of origin is *usually* given as the 2D bounding box centre of the
// /// geometry, in which case you can just use [`skew`](Self::skew) or
// /// [`skew_xy`](Self::skew_xy), but this method allows you to specify any point.
// #[wasm_bindgen(js_name = skewAroundPoint)]
// pub fn skew_around_point(
// &self,
// degrees_x: BroadcastableFloat,
// degrees_y: BroadcastableFloat,
// origin: Point,
// ) -> Self {
// use geoarrow::algorithm::geo::Skew;
// Skew::skew_around_point(&self.0, &degrees_x.0, &degrees_y.0, origin.0.into()).into()
// }
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub mod ffi;
pub mod io;
// #[cfg(feature = "geodesy")]
// pub mod reproject;
#[cfg(feature = "scalar")]
pub mod scalar;
// #[cfg(feature = "scalar")]
// pub mod scalar;
#[cfg(feature = "vector")]
pub mod vector;
// pub mod transform_origin;
Expand Down
4 changes: 3 additions & 1 deletion rust/geoarrow/src/array/binary/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ use geo_traits::GeometryTrait;
///
/// This array implements [`SerializedArray`], not [`NativeArray`]. This means that you'll need to
/// parse the `WKBArray` into a native-typed GeoArrow array (such as
/// [`PointArray`][crate::array::PointArray]) before using it for computations.
/// [`GeometryArray`][crate::array::GeometryArray]) before using it for computations.
///
/// Refer to [`crate::io::wkb`] for encoding and decoding this array to the native array types.
#[derive(Debug, Clone, PartialEq)]
pub struct WKBArray<O: OffsetSizeTrait> {
pub(crate) data_type: SerializedType,
Expand Down
2 changes: 0 additions & 2 deletions rust/geoarrow/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@
//! second pass.
//!
// #![allow(missing_docs)] // FIXME

pub use binary::{WKBArray, WKBBuilder, WKBCapacity};
pub use cast::{AsChunkedNativeArray, AsNativeArray, AsSerializedArray};
pub use coord::{
Expand Down
8 changes: 4 additions & 4 deletions rust/geoarrow/src/array/wkt/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ use crate::ArrayBase;
///
/// This is semantically equivalent to `Vec<Option<WKT>>` due to the internal validity bitmap.
///
/// This array _can_ be used directly for operations, but that will incur costly encoding to and
/// from WKT on every operation. Instead, you usually want to use the WKBArray only for
/// serialization purposes (e.g. to and from [GeoParquet](https://geoparquet.org/)) but convert to
/// strongly-typed arrays (such as the [`PointArray`][crate::array::PointArray]) for computations.
/// This is a wrapper around an Arrow [GenericStringArray], but additionally stores an
/// [ArrayMetadata] so that we can persist CRS information about the data.
///
/// Refer to [`crate::io::wkt`] for encoding and decoding this array to the native array types.
#[derive(Debug, Clone, PartialEq)]
pub struct WKTArray<O: OffsetSizeTrait> {
pub(crate) data_type: SerializedType,
Expand Down
2 changes: 1 addition & 1 deletion rust/geoarrow/src/io/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Reader and writer implementations of many common geospatial file formats, including
//! interoperability with the `geozero` crate.
//! interoperability with the [`geozero`] crate.
#![allow(missing_docs)] // FIXME

Expand Down
1 change: 0 additions & 1 deletion rust/geoarrow/src/scalar/binary/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod owned;
mod scalar;

pub use owned::OwnedWKB;
pub use scalar::WKB;
2 changes: 1 addition & 1 deletion rust/geoarrow/src/scalar/binary/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct OwnedWKB<O: OffsetSizeTrait> {
}

impl<O: OffsetSizeTrait> OwnedWKB<O> {
pub fn new(arr: GenericBinaryArray<O>, geom_index: usize) -> Self {
pub(crate) fn new(arr: GenericBinaryArray<O>, geom_index: usize) -> Self {
Self { arr, geom_index }
}
}
Expand Down
8 changes: 7 additions & 1 deletion rust/geoarrow/src/scalar/binary/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ use rstar::{RTreeObject, AABB};
///
/// This is zero-cost to _create_ from a [WKBArray] but the WKB has not been preprocessed yet, so
/// it's not constant-time to access coordinate values.
///
/// This does not directly implement [GeometryTrait], because it first needs to be parsed. Use
/// [`parse`] to access an opaque object that does implement [GeometryTrait].
///
/// [`parse`]: WKB::parse
#[derive(Debug, Clone)]
pub struct WKB<'a, O: OffsetSizeTrait> {
pub(crate) arr: &'a GenericBinaryArray<O>,
Expand All @@ -27,12 +32,13 @@ impl<'a, O: OffsetSizeTrait> WKB<'a, O> {
self.as_ref()
}

pub fn into_owned_inner(self) -> (GenericBinaryArray<O>, usize) {
pub(crate) fn into_owned_inner(self) -> (GenericBinaryArray<O>, usize) {
// TODO: hard slice?
// let owned = self.into_owned();
(self.arr.clone(), self.geom_index)
}

/// Parse this WKB buffer to a geometry.
pub fn parse(&self) -> Result<impl GeometryTrait<T = f64> + use<'_, O>> {
Ok(wkb::reader::read_wkb(self.as_ref())?)
}
Expand Down
5 changes: 5 additions & 0 deletions rust/geoarrow/src/scalar/coord/combined/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ use crate::trait_::NativeScalar;
use geo_traits::to_geo::ToGeoCoord;
use geo_traits::CoordTrait;

/// An Arrow equivalent of a Coord
///
/// This implements [CoordTrait], which you can use to extract data.
#[derive(Debug, Clone)]
pub enum Coord<'a> {
/// Separated coordinate
Separated(SeparatedCoord<'a>),
/// Interleaved coordinate
Interleaved(InterleavedCoord<'a>),
}

Expand Down
3 changes: 3 additions & 0 deletions rust/geoarrow/src/scalar/coord/interleaved/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use crate::trait_::NativeScalar;
use geo_traits::to_geo::ToGeoCoord;
use geo_traits::CoordTrait;

/// An Arrow equivalent of a Coord
///
/// This implements [CoordTrait], which you can use to extract data.
#[derive(Debug, Clone)]
pub struct InterleavedCoord<'a> {
pub(crate) coords: &'a ScalarBuffer<f64>,
Expand Down
3 changes: 3 additions & 0 deletions rust/geoarrow/src/scalar/coord/separated/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use geo_traits::to_geo::ToGeoCoord;
use geo_traits::CoordTrait;
use rstar::{RTreeObject, AABB};

/// An Arrow equivalent of a Coord
///
/// This implements [CoordTrait], which you can use to extract data.
#[derive(Debug, Clone)]
pub struct SeparatedCoord<'a> {
pub(crate) buffers: &'a [ScalarBuffer<f64>; 4],
Expand Down
12 changes: 11 additions & 1 deletion rust/geoarrow/src/scalar/geometry/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,26 @@ use geo_traits::{
};
use rstar::{RTreeObject, AABB};

/// A Geometry is an enum over the various underlying _zero copy_ GeoArrow scalar types.
/// An Arrow equivalent of a Geometry
///
/// This implements [GeometryTrait], which you can use to extract data.
#[derive(Debug)]
pub enum Geometry<'a> {
/// Point geometry
Point(crate::scalar::Point<'a>),
/// LineString geometry
LineString(crate::scalar::LineString<'a>),
/// Polygon geometry
Polygon(crate::scalar::Polygon<'a>),
/// MultiPoint geometry
MultiPoint(crate::scalar::MultiPoint<'a>),
/// MultiLineString geometry
MultiLineString(crate::scalar::MultiLineString<'a>),
/// MultiPolygon geometry
MultiPolygon(crate::scalar::MultiPolygon<'a>),
/// GeometryCollection geometry
GeometryCollection(crate::scalar::GeometryCollection<'a>),
/// Rect geometry
Rect(crate::scalar::Rect<'a>),
}

Expand Down
7 changes: 5 additions & 2 deletions rust/geoarrow/src/scalar/geometrycollection/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use geo_traits::GeometryCollectionTrait;
use rstar::{RTreeObject, AABB};

/// An Arrow equivalent of a GeometryCollection
///
/// This implements [GeometryCollectionTrait], which you can use to extract data.
#[derive(Debug, Clone)]
pub struct GeometryCollection<'a> {
pub(crate) array: &'a MixedGeometryArray,
Expand All @@ -25,7 +27,7 @@ pub struct GeometryCollection<'a> {
}

impl<'a> GeometryCollection<'a> {
pub fn new(
pub(crate) fn new(
array: &'a MixedGeometryArray,
geom_offsets: &'a OffsetBuffer<i32>,
geom_index: usize,
Expand All @@ -39,7 +41,8 @@ impl<'a> GeometryCollection<'a> {
}
}

pub fn into_inner(&self) -> (&MixedGeometryArray, &OffsetBuffer<i32>, usize) {
#[allow(clippy::wrong_self_convention)]
pub(crate) fn into_inner(&self) -> (&MixedGeometryArray, &OffsetBuffer<i32>, usize) {
(self.array, self.geom_offsets, self.geom_index)
}
}
Expand Down
6 changes: 4 additions & 2 deletions rust/geoarrow/src/scalar/linestring/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use geo_traits::LineStringTrait;
use rstar::{RTreeObject, AABB};

/// An Arrow equivalent of a LineString
///
/// This implements [LineStringTrait], which you can use to extract data.
#[derive(Debug, Clone)]
pub struct LineString<'a> {
pub(crate) coords: &'a CoordBuffer,
Expand All @@ -23,7 +25,7 @@ pub struct LineString<'a> {
}

impl<'a> LineString<'a> {
pub fn new(
pub(crate) fn new(
coords: &'a CoordBuffer,
geom_offsets: &'a OffsetBuffer<i32>,
geom_index: usize,
Expand All @@ -37,7 +39,7 @@ impl<'a> LineString<'a> {
}
}

pub fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer<i32>, usize) {
pub(crate) fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer<i32>, usize) {
(
self.coords.clone(),
self.geom_offsets.clone(),
Expand Down
31 changes: 19 additions & 12 deletions rust/geoarrow/src/scalar/mod.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
//! GeoArrow scalars, which are references onto a full GeoArrow array at a specific index.
#![allow(missing_docs)] // FIXME

pub use binary::{OwnedWKB, WKB};
pub use binary::WKB;
pub use coord::{Coord, InterleavedCoord, SeparatedCoord};
pub use geometry::{Geometry, OwnedGeometry};
pub use geometrycollection::{GeometryCollection, OwnedGeometryCollection};
pub use linestring::{LineString, OwnedLineString};
pub use multilinestring::{MultiLineString, OwnedMultiLineString};
pub use multipoint::{MultiPoint, OwnedMultiPoint};
pub use multipolygon::{MultiPolygon, OwnedMultiPolygon};
pub use point::{OwnedPoint, Point};
pub use polygon::{OwnedPolygon, Polygon};
pub use rect::{OwnedRect, Rect};
pub use geometry::Geometry;
pub(crate) use geometry::OwnedGeometry;
pub use geometrycollection::GeometryCollection;
pub(crate) use geometrycollection::OwnedGeometryCollection;
pub use linestring::LineString;
pub(crate) use linestring::OwnedLineString;
pub use multilinestring::MultiLineString;
pub(crate) use multilinestring::OwnedMultiLineString;
pub use multipoint::MultiPoint;
pub(crate) use multipoint::OwnedMultiPoint;
pub use multipolygon::MultiPolygon;
pub(crate) use multipolygon::OwnedMultiPolygon;
pub(crate) use point::OwnedPoint;
pub use point::Point;
pub(crate) use polygon::OwnedPolygon;
pub use polygon::Polygon;
pub(crate) use rect::OwnedRect;
pub use rect::Rect;
pub use scalar::GeometryScalar;

mod binary;
Expand Down
8 changes: 6 additions & 2 deletions rust/geoarrow/src/scalar/multilinestring/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use geo_traits::MultiLineStringTrait;
use rstar::{RTreeObject, AABB};

/// An Arrow equivalent of a MultiLineString
///
/// This implements [MultiLineStringTrait], which you can use to extract data.
#[derive(Debug, Clone)]
pub struct MultiLineString<'a> {
pub(crate) coords: &'a CoordBuffer,
Expand All @@ -26,7 +28,7 @@ pub struct MultiLineString<'a> {
}

impl<'a> MultiLineString<'a> {
pub fn new(
pub(crate) fn new(
coords: &'a CoordBuffer,
geom_offsets: &'a OffsetBuffer<i32>,
ring_offsets: &'a OffsetBuffer<i32>,
Expand All @@ -42,7 +44,9 @@ impl<'a> MultiLineString<'a> {
}
}

pub fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer<i32>, OffsetBuffer<i32>, usize) {
pub(crate) fn into_owned_inner(
self,
) -> (CoordBuffer, OffsetBuffer<i32>, OffsetBuffer<i32>, usize) {
(
self.coords.clone(),
self.geom_offsets.clone(),
Expand Down
6 changes: 4 additions & 2 deletions rust/geoarrow/src/scalar/multipoint/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use geo_traits::MultiPointTrait;
use rstar::{RTreeObject, AABB};

/// An Arrow equivalent of a MultiPoint
///
/// This implements [MultiPointTrait], which you can use to extract data.
#[derive(Debug, Clone)]
pub struct MultiPoint<'a> {
/// Buffer of coordinates
Expand All @@ -25,7 +27,7 @@ pub struct MultiPoint<'a> {
}

impl<'a> MultiPoint<'a> {
pub fn new(
pub(crate) fn new(
coords: &'a CoordBuffer,
geom_offsets: &'a OffsetBuffer<i32>,
geom_index: usize,
Expand All @@ -39,7 +41,7 @@ impl<'a> MultiPoint<'a> {
}
}

pub fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer<i32>, usize) {
pub(crate) fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer<i32>, usize) {
(
self.coords.clone(),
self.geom_offsets.clone(),
Expand Down
6 changes: 4 additions & 2 deletions rust/geoarrow/src/scalar/multipolygon/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use geo_traits::MultiPolygonTrait;
use rstar::{RTreeObject, AABB};

/// An Arrow equivalent of a MultiPolygon
///
/// This implements [MultiPolygonTrait], which you can use to extract data.
#[derive(Debug, Clone)]
pub struct MultiPolygon<'a> {
pub(crate) coords: &'a CoordBuffer,
Expand All @@ -30,7 +32,7 @@ pub struct MultiPolygon<'a> {
}

impl<'a> MultiPolygon<'a> {
pub fn new(
pub(crate) fn new(
coords: &'a CoordBuffer,
geom_offsets: &'a OffsetBuffer<i32>,
polygon_offsets: &'a OffsetBuffer<i32>,
Expand All @@ -48,7 +50,7 @@ impl<'a> MultiPolygon<'a> {
}
}

pub fn into_owned_inner(
pub(crate) fn into_owned_inner(
self,
) -> (
CoordBuffer,
Expand Down
Loading

0 comments on commit 11abe73

Please sign in to comment.