-
Notifications
You must be signed in to change notification settings - Fork 19
/
multipolygon.rs
31 lines (26 loc) · 953 Bytes
/
multipolygon.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use crate::geo_traits::MultiPolygonTrait;
use crate::io::geozero::scalar::polygon::process_polygon;
use crate::scalar::MultiPolygon;
use arrow_array::OffsetSizeTrait;
use geozero::{GeomProcessor, GeozeroGeometry};
pub(crate) fn process_multi_polygon<P: GeomProcessor>(
geom: &impl MultiPolygonTrait<T = f64>,
geom_idx: usize,
processor: &mut P,
) -> geozero::error::Result<()> {
processor.multipolygon_begin(geom.num_polygons(), geom_idx)?;
for polygon_idx in 0..geom.num_polygons() {
let polygon = geom.polygon(polygon_idx).unwrap();
process_polygon(&polygon, false, polygon_idx, processor)?;
}
processor.multipolygon_end(geom_idx)?;
Ok(())
}
impl<O: OffsetSizeTrait> GeozeroGeometry for MultiPolygon<'_, O> {
fn process_geom<P: GeomProcessor>(&self, processor: &mut P) -> geozero::error::Result<()>
where
Self: Sized,
{
process_multi_polygon(self, 0, processor)
}
}