Skip to content

Commit d9d987f

Browse files
authored
feat(pyo3-geoarrow): add add_triangle and add_line for BoundingRect (#1397)
1 parent f32ed77 commit d9d987f

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

rust/pyo3-geoarrow/src/scalar/bounding_rect.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::ops::Add;
22

33
use geo_traits::{
4-
CoordTrait, GeometryCollectionTrait, GeometryTrait, GeometryType, LineStringTrait,
4+
CoordTrait, GeometryCollectionTrait, GeometryTrait, GeometryType, LineStringTrait, LineTrait,
55
MultiLineStringTrait, MultiPointTrait, MultiPolygonTrait, PointTrait, PolygonTrait, RectTrait,
6-
UnimplementedGeometryCollection, UnimplementedLine, UnimplementedLineString,
6+
TriangleTrait, UnimplementedGeometryCollection, UnimplementedLine, UnimplementedLineString,
77
UnimplementedMultiLineString, UnimplementedMultiPoint, UnimplementedMultiPolygon,
88
UnimplementedPoint, UnimplementedPolygon, UnimplementedTriangle,
99
};
@@ -108,6 +108,18 @@ impl BoundingRect {
108108
}
109109
}
110110

111+
pub fn add_triangle(&mut self, triangle: &impl TriangleTrait<T = f64>) {
112+
for coord in triangle.coords() {
113+
self.add_coord(&coord);
114+
}
115+
}
116+
117+
pub fn add_line(&mut self, line: &impl LineTrait<T = f64>) {
118+
for coord in line.coords() {
119+
self.add_coord(&coord);
120+
}
121+
}
122+
111123
pub fn add_geometry(&mut self, geometry: &impl GeometryTrait<T = f64>) {
112124
use GeometryType::*;
113125

@@ -120,7 +132,8 @@ impl BoundingRect {
120132
MultiPolygon(g) => self.add_multi_polygon(g),
121133
GeometryCollection(g) => self.add_geometry_collection(g),
122134
Rect(g) => self.add_rect(g),
123-
Triangle(_) | Line(_) => todo!(),
135+
Triangle(g) => self.add_triangle(g),
136+
Line(g) => self.add_line(g),
124137
}
125138
}
126139

0 commit comments

Comments
 (0)