Skip to content

Commit

Permalink
3d wkb (#726)
Browse files Browse the repository at this point in the history
For #662
  • Loading branch information
kylebarron authored Aug 27, 2024
1 parent 389429e commit 536066e
Show file tree
Hide file tree
Showing 16 changed files with 412 additions and 132 deletions.
16 changes: 9 additions & 7 deletions src/array/linestring/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,18 +388,20 @@ impl<const D: usize> TryFrom<(&dyn Array, &Field)> for LineStringArray<i64, D> {
}
}

impl<O: OffsetSizeTrait, G: LineStringTrait<T = f64>> From<Vec<Option<G>>>
for LineStringArray<O, 2>
impl<O: OffsetSizeTrait, G: LineStringTrait<T = f64>, const D: usize> From<Vec<Option<G>>>
for LineStringArray<O, D>
{
fn from(other: Vec<Option<G>>) -> Self {
let mut_arr: LineStringBuilder<O, 2> = other.into();
let mut_arr: LineStringBuilder<O, D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait, G: LineStringTrait<T = f64>> From<&[G]> for LineStringArray<O, 2> {
impl<O: OffsetSizeTrait, G: LineStringTrait<T = f64>, const D: usize> From<&[G]>
for LineStringArray<O, D>
{
fn from(other: &[G]) -> Self {
let mut_arr: LineStringBuilder<O, 2> = other.into();
let mut_arr: LineStringBuilder<O, D> = other.into();
mut_arr.into()
}
}
Expand All @@ -417,11 +419,11 @@ impl<O: OffsetSizeTrait, const D: usize> From<LineStringArray<O, D>> for MultiPo
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for LineStringArray<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for LineStringArray<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
let mut_arr: LineStringBuilder<O, 2> = value.try_into()?;
let mut_arr: LineStringBuilder<O, D> = value.try_into()?;
Ok(mut_arr.into())
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/array/linestring/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ impl<O: OffsetSizeTrait, const D: usize> From<LineStringBuilder<O, D>> for Gener
}
}

impl<O: OffsetSizeTrait, G: LineStringTrait<T = f64>> From<&[G]> for LineStringBuilder<O, 2> {
impl<O: OffsetSizeTrait, G: LineStringTrait<T = f64>, const D: usize> From<&[G]>
for LineStringBuilder<O, D>
{
fn from(geoms: &[G]) -> Self {
Self::from_line_strings(geoms, Default::default(), Default::default())
}
Expand Down
16 changes: 9 additions & 7 deletions src/array/mixed/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,31 +671,33 @@ impl<const D: usize> TryFrom<(&dyn Array, &Field)> for MixedGeometryArray<i64, D
}
}

impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>> TryFrom<&[G]> for MixedGeometryArray<O, 2> {
impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>, const D: usize> TryFrom<&[G]>
for MixedGeometryArray<O, D>
{
type Error = GeoArrowError;

fn try_from(geoms: &[G]) -> Result<Self> {
let mut_arr: MixedGeometryBuilder<O, 2> = geoms.try_into()?;
let mut_arr: MixedGeometryBuilder<O, D> = geoms.try_into()?;
Ok(mut_arr.into())
}
}

impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>> TryFrom<&[Option<G>]>
for MixedGeometryArray<O, 2>
impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>, const D: usize> TryFrom<&[Option<G>]>
for MixedGeometryArray<O, D>
{
type Error = GeoArrowError;

fn try_from(geoms: &[Option<G>]) -> Result<Self> {
let mut_arr: MixedGeometryBuilder<O, 2> = geoms.try_into()?;
let mut_arr: MixedGeometryBuilder<O, D> = geoms.try_into()?;
Ok(mut_arr.into())
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for MixedGeometryArray<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for MixedGeometryArray<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
let mut_arr: MixedGeometryBuilder<O, 2> = value.try_into()?;
let mut_arr: MixedGeometryBuilder<O, D> = value.try_into()?;
Ok(mut_arr.into())
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/array/mixed/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,16 +520,18 @@ impl<O: OffsetSizeTrait, const D: usize> From<MixedGeometryBuilder<O, D>>
}
}

impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>> TryFrom<&[G]> for MixedGeometryBuilder<O, 2> {
impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>, const D: usize> TryFrom<&[G]>
for MixedGeometryBuilder<O, D>
{
type Error = GeoArrowError;

fn try_from(geoms: &[G]) -> Result<Self> {
Self::from_geometries(geoms, Default::default(), Default::default(), true)
}
}

impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>> TryFrom<&[Option<G>]>
for MixedGeometryBuilder<O, 2>
impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>, const D: usize> TryFrom<&[Option<G>]>
for MixedGeometryBuilder<O, D>
{
type Error = GeoArrowError;

Expand All @@ -538,7 +540,7 @@ impl<O: OffsetSizeTrait, G: GeometryTrait<T = f64>> TryFrom<&[Option<G>]>
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for MixedGeometryBuilder<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for MixedGeometryBuilder<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> std::result::Result<Self, Self::Error> {
Expand Down
16 changes: 8 additions & 8 deletions src/array/multilinestring/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,20 +443,20 @@ impl<const D: usize> TryFrom<(&dyn Array, &Field)> for MultiLineStringArray<i64,
}
}

impl<O: OffsetSizeTrait, G: MultiLineStringTrait<T = f64>> From<Vec<Option<G>>>
for MultiLineStringArray<O, 2>
impl<O: OffsetSizeTrait, G: MultiLineStringTrait<T = f64>, const D: usize> From<Vec<Option<G>>>
for MultiLineStringArray<O, D>
{
fn from(other: Vec<Option<G>>) -> Self {
let mut_arr: MultiLineStringBuilder<O, 2> = other.into();
let mut_arr: MultiLineStringBuilder<O, D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait, G: MultiLineStringTrait<T = f64>> From<&[G]>
for MultiLineStringArray<O, 2>
impl<O: OffsetSizeTrait, G: MultiLineStringTrait<T = f64>, const D: usize> From<&[G]>
for MultiLineStringArray<O, D>
{
fn from(other: &[G]) -> Self {
let mut_arr: MultiLineStringBuilder<O, 2> = other.into();
let mut_arr: MultiLineStringBuilder<O, D> = other.into();
mut_arr.into()
}
}
Expand All @@ -475,11 +475,11 @@ impl<O: OffsetSizeTrait, const D: usize> From<MultiLineStringArray<O, D>> for Po
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for MultiLineStringArray<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for MultiLineStringArray<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
let mut_arr: MultiLineStringBuilder<O, 2> = value.try_into()?;
let mut_arr: MultiLineStringBuilder<O, D> = value.try_into()?;
Ok(mut_arr.into())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/multilinestring/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ impl<O: OffsetSizeTrait, G: MultiLineStringTrait<T = f64>, const D: usize> From<
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for MultiLineStringBuilder<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for MultiLineStringBuilder<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
Expand Down
16 changes: 9 additions & 7 deletions src/array/multipoint/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,27 +378,29 @@ impl<const D: usize> TryFrom<(&dyn Array, &Field)> for MultiPointArray<i64, D> {
}
}

impl<O: OffsetSizeTrait, G: MultiPointTrait<T = f64>> From<Vec<Option<G>>>
for MultiPointArray<O, 2>
impl<O: OffsetSizeTrait, G: MultiPointTrait<T = f64>, const D: usize> From<Vec<Option<G>>>
for MultiPointArray<O, D>
{
fn from(other: Vec<Option<G>>) -> Self {
let mut_arr: MultiPointBuilder<O, 2> = other.into();
let mut_arr: MultiPointBuilder<O, D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait, G: MultiPointTrait<T = f64>> From<&[G]> for MultiPointArray<O, 2> {
impl<O: OffsetSizeTrait, G: MultiPointTrait<T = f64>, const D: usize> From<&[G]>
for MultiPointArray<O, D>
{
fn from(other: &[G]) -> Self {
let mut_arr: MultiPointBuilder<O, 2> = other.into();
let mut_arr: MultiPointBuilder<O, D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for MultiPointArray<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for MultiPointArray<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
let mut_arr: MultiPointBuilder<O, 2> = value.try_into()?;
let mut_arr: MultiPointBuilder<O, D> = value.try_into()?;
Ok(mut_arr.into())
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/array/multipoint/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ impl<O: OffsetSizeTrait, const D: usize> From<MultiPointBuilder<O, D>> for Gener
}
}

impl<O: OffsetSizeTrait, G: MultiPointTrait<T = f64>> From<&[G]> for MultiPointBuilder<O, 2> {
impl<O: OffsetSizeTrait, G: MultiPointTrait<T = f64>, const D: usize> From<&[G]>
for MultiPointBuilder<O, D>
{
fn from(geoms: &[G]) -> Self {
Self::from_multi_points(geoms, Default::default(), Default::default())
}
Expand Down
16 changes: 9 additions & 7 deletions src/array/multipolygon/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,27 +525,29 @@ impl<const D: usize> TryFrom<(&dyn Array, &Field)> for MultiPolygonArray<i64, D>
}
}

impl<O: OffsetSizeTrait, G: MultiPolygonTrait<T = f64>> From<Vec<Option<G>>>
for MultiPolygonArray<O, 2>
impl<O: OffsetSizeTrait, G: MultiPolygonTrait<T = f64>, const D: usize> From<Vec<Option<G>>>
for MultiPolygonArray<O, D>
{
fn from(other: Vec<Option<G>>) -> Self {
let mut_arr: MultiPolygonBuilder<O, 2> = other.into();
let mut_arr: MultiPolygonBuilder<O, D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait, G: MultiPolygonTrait<T = f64>> From<&[G]> for MultiPolygonArray<O, 2> {
impl<O: OffsetSizeTrait, G: MultiPolygonTrait<T = f64>, const D: usize> From<&[G]>
for MultiPolygonArray<O, D>
{
fn from(other: &[G]) -> Self {
let mut_arr: MultiPolygonBuilder<O, 2> = other.into();
let mut_arr: MultiPolygonBuilder<O, D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for MultiPolygonArray<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for MultiPolygonArray<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
let mut_arr: MultiPolygonBuilder<O, 2> = value.try_into()?;
let mut_arr: MultiPolygonBuilder<O, D> = value.try_into()?;
Ok(mut_arr.into())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/multipolygon/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ impl<O: OffsetSizeTrait, G: MultiPolygonTrait<T = f64>, const D: usize> From<Vec
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for MultiPolygonBuilder<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for MultiPolygonBuilder<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
Expand Down
12 changes: 6 additions & 6 deletions src/array/point/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,25 +304,25 @@ impl<const D: usize> TryFrom<(&dyn Array, &Field)> for PointArray<D> {
}
}

impl<G: PointTrait<T = f64>> From<Vec<Option<G>>> for PointArray<2> {
impl<G: PointTrait<T = f64>, const D: usize> From<Vec<Option<G>>> for PointArray<D> {
fn from(other: Vec<Option<G>>) -> Self {
let mut_arr: PointBuilder<2> = other.into();
let mut_arr: PointBuilder<D> = other.into();
mut_arr.into()
}
}

impl<G: PointTrait<T = f64>> From<&[G]> for PointArray<2> {
impl<G: PointTrait<T = f64>, const D: usize> From<&[G]> for PointArray<D> {
fn from(other: &[G]) -> Self {
let mut_arr: PointBuilder<2> = other.into();
let mut_arr: PointBuilder<D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for PointArray<2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for PointArray<D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self, Self::Error> {
let mut_arr: PointBuilder<2> = value.try_into()?;
let mut_arr: PointBuilder<D> = value.try_into()?;
Ok(mut_arr.into())
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/array/polygon/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,25 +438,29 @@ impl<const D: usize> TryFrom<(&dyn Array, &Field)> for PolygonArray<i64, D> {
}
}

impl<O: OffsetSizeTrait, G: PolygonTrait<T = f64>> From<Vec<Option<G>>> for PolygonArray<O, 2> {
impl<O: OffsetSizeTrait, G: PolygonTrait<T = f64>, const D: usize> From<Vec<Option<G>>>
for PolygonArray<O, D>
{
fn from(other: Vec<Option<G>>) -> Self {
let mut_arr: PolygonBuilder<O, 2> = other.into();
let mut_arr: PolygonBuilder<O, D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait, G: PolygonTrait<T = f64>> From<&[G]> for PolygonArray<O, 2> {
impl<O: OffsetSizeTrait, G: PolygonTrait<T = f64>, const D: usize> From<&[G]>
for PolygonArray<O, D>
{
fn from(other: &[G]) -> Self {
let mut_arr: PolygonBuilder<O, 2> = other.into();
let mut_arr: PolygonBuilder<O, D> = other.into();
mut_arr.into()
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for PolygonArray<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for PolygonArray<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
let mut_arr: PolygonBuilder<O, 2> = value.try_into()?;
let mut_arr: PolygonBuilder<O, D> = value.try_into()?;
Ok(mut_arr.into())
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/array/polygon/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ impl<O: OffsetSizeTrait, G: PolygonTrait<T = f64>, const D: usize> From<Vec<Opti
}
}

impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for PolygonBuilder<O, 2> {
impl<O: OffsetSizeTrait, const D: usize> TryFrom<WKBArray<O>> for PolygonBuilder<O, D> {
type Error = GeoArrowError;

fn try_from(value: WKBArray<O>) -> Result<Self> {
Expand Down
8 changes: 4 additions & 4 deletions src/array/rect/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,16 @@ impl<const D: usize> TryFrom<(&dyn Array, &Field)> for RectArray<D> {
}
}

impl<G: RectTrait<T = f64>> From<&[G]> for RectArray<2> {
impl<G: RectTrait<T = f64>, const D: usize> From<&[G]> for RectArray<D> {
fn from(other: &[G]) -> Self {
let mut_arr: RectBuilder<2> = other.into();
let mut_arr: RectBuilder<D> = other.into();
mut_arr.into()
}
}

impl<G: RectTrait<T = f64>> From<Vec<Option<G>>> for RectArray<2> {
impl<G: RectTrait<T = f64>, const D: usize> From<Vec<Option<G>>> for RectArray<D> {
fn from(other: Vec<Option<G>>) -> Self {
let mut_arr: RectBuilder<2> = other.into();
let mut_arr: RectBuilder<D> = other.into();
mut_arr.into()
}
}
Loading

0 comments on commit 536066e

Please sign in to comment.