From 8788c9245add2d3a80737263744283b538c29140 Mon Sep 17 00:00:00 2001 From: Jay Kickliter Date: Tue, 7 Nov 2023 13:39:42 -0700 Subject: [PATCH] [nasadem] fix polygons and add len fn --- nasadem/src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nasadem/src/lib.rs b/nasadem/src/lib.rs index 971beb9..f3c9307 100755 --- a/nasadem/src/lib.rs +++ b/nasadem/src/lib.rs @@ -224,6 +224,13 @@ impl Tile { } } + /// Returns the number of samples in this tile. + #[allow(clippy::len_without_is_empty)] + pub fn len(&self) -> usize { + let (x, y) = self.dimensions; + x * y + } + /// Returns the lowest elevation sample in this tile. pub fn min_elevation(&self) -> i16 { let mut min_elevation = self.min_elevation.load(Ordering::Relaxed); @@ -314,8 +321,8 @@ impl Tile { fn xy_to_polygon(&self, (x, y): (usize, usize)) -> Polygon { #[allow(clippy::cast_precision_loss)] let center = Coord { - x: self.sw_corner_center.x + (y as C * C::from(self.resolution)) / ARCSEC_PER_DEG, - y: self.sw_corner_center.y + (x as C * C::from(self.resolution)) / ARCSEC_PER_DEG, + x: self.sw_corner_center.x + (x as C * C::from(self.resolution)) / ARCSEC_PER_DEG, + y: self.sw_corner_center.y + (y as C * C::from(self.resolution)) / ARCSEC_PER_DEG, }; polygon(¢er, C::from(self.resolution)) }