use crate::Cell;
use crate::errors::*;
use geo::{LineString, MultiPoint, Point, Polygon};
impl Cell {
pub fn from_geopoint(point: Point, res: u8) -> Result<Self, QuadbinError> {
Cell::from_point(point.y(), point.x(), res)
}
pub fn from_multipoint(
multipoint: MultiPoint,
res: u8,
) -> impl Iterator<Item = Result<Self, QuadbinError>> {
multipoint
.into_iter()
.map(move |point| Cell::from_geopoint(point, res))
}
pub fn to_polygon(&self) -> Polygon {
let bbox = self.to_bbox();
Polygon::new(
LineString::from(vec![
(bbox[0], bbox[1]), (bbox[2], bbox[1]), (bbox[2], bbox[3]), (bbox[0], bbox[3]), (bbox[0], bbox[1]), ]),
vec![],
)
}
}