From 3b4236e2fbded37ecb972d6061be476bc4d9ce3b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 12 May 2022 01:42:37 +0100 Subject: [PATCH] mformat 2: Actually implement the outline resizing Signed-off-by: Ian Jackson --- src/shapelib.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/shapelib.rs b/src/shapelib.rs index 65e0242f..ed46e30f 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -114,6 +114,10 @@ pub enum LibraryLoadError { FilesListFieldsMustBeAtStart(usize), #[error("piece defines multiple faces in multiple ways")] MultipleMultipleFaceDefinitions, + #[error("outline specified both size and numeric scale")] + OutlineContradictoryScale, + #[error("{0}")] CoordinateOverflow(#[from] CoordinateOverflow), + #[error("{0}")] MaterialsFormatIncompat(#[from] materials_format::Incompat< LibraryLoadMFIncompat @@ -692,7 +696,19 @@ impl GroupData { (None, SD::Stretch(s)) => of_stretch(s), }; - let outline = self.d.outline.shape().load(size); + let osize = { + let (osize, oscale) = self.d.outline.size_scale(); + let osize = resolve_square_size(&osize)?; + match (osize, oscale) { + (Some(osize), None ) => osize, + (None, Some(&oscale)) => (size * oscale)?, + (None, None ) => size, + (Some(_), Some(_) ) => + throw!(LLE::OutlineContradictoryScale) + } + }; + + let outline = self.d.outline.shape().load(osize); (FaceTransform { scale: scale.coords, centre: centre.coords }, outline) } else { -- 2.30.2