From commits-return-13434-apmail-sis-commits-archive=sis.apache.org@sis.apache.org Sun Apr 5 20:31:56 2020 Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id 5233619E1E for ; Sun, 5 Apr 2020 20:31:56 +0000 (UTC) Received: (qmail 61250 invoked by uid 500); 5 Apr 2020 20:31:55 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 61183 invoked by uid 500); 5 Apr 2020 20:31:55 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 61083 invoked by uid 99); 5 Apr 2020 20:31:55 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Apr 2020 20:31:55 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 7E45581A13; Sun, 5 Apr 2020 20:31:55 +0000 (UTC) Date: Sun, 05 Apr 2020 20:31:58 +0000 To: "commits@sis.apache.org" Subject: [sis] 03/04: Remove (at least for now) roundIfAlmostInteger(AffineTransform) since it is not sure that the benefit is worth the risk. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: desruisseaux@apache.org In-Reply-To: <158611871538.2860.11810155248603608880@gitbox.apache.org> References: <158611871538.2860.11810155248603608880@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: sis X-Git-Refname: refs/heads/geoapi-4.0 X-Git-Reftype: branch X-Git-Rev: 84f904ed48dabd514a629d2f5e860d0402875ad1 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20200405203155.7E45581A13@gitbox.apache.org> This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git commit 84f904ed48dabd514a629d2f5e860d0402875ad1 Author: Martin Desruisseaux AuthorDate: Sun Apr 5 17:55:29 2020 +0200 Remove (at least for now) roundIfAlmostInteger(AffineTransform) since it is not sure that the benefit is worth the risk. --- .../java/org/apache/sis/image/ResamplingGrid.java | 41 ---------------------- .../org/apache/sis/image/ResamplingGridTest.java | 22 ------------ 2 files changed, 63 deletions(-) diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/ResamplingGrid.java b/core/sis-feature/src/main/java/org/apache/sis/image/ResamplingGrid.java index 399b5b0..cabe1c5 100644 --- a/core/sis-feature/src/main/java/org/apache/sis/image/ResamplingGrid.java +++ b/core/sis-feature/src/main/java/org/apache/sis/image/ResamplingGrid.java @@ -32,7 +32,6 @@ import org.apache.sis.util.resources.Errors; import org.apache.sis.io.wkt.Formatter; import static java.lang.Math.abs; -import static java.lang.Math.rint; /** @@ -80,17 +79,6 @@ final class ResamplingGrid extends AbstractMathTransform2D { static final double TOLERANCE = 0.125; /** - * A small tolerance factor for comparisons of floating point numbers. We use the smallest - * accuracy possible for the {@code float} type for integer numbers different than zero, - * as computed by: - * - * {@preformat java - * Math.nextUp(1f) - 1f; - * } - */ - static final double EPS = 1.1920929E-7; - - /** * Number of tiles in this grid. A {@link ResamplingGrid} tile is a rectangular region inside which * bilinear interpolations can be used with acceptable errors. {@link ResamplingGrid} tiles are not * necessarily coincident with image tiles. @@ -303,7 +291,6 @@ affine: if (depth.width == 0 && depth.height == 0) { m01 / height, m11 / height, p.getX(), p.getY()); tr.translate(-xcnt, -ycnt); - roundIfAlmostInteger(tr); /* * Since the affine transform that we built is a kind of average computed from bounds center, * we need to compare with the four corners for making sure that its precision is sufficient. @@ -511,34 +498,6 @@ affine: if (depth.width == 0 && depth.height == 0) { } /** - * If scale and shear coefficients are close to integers, replaces their current values by their rounded values. - * The scale and shear coefficients are handled in a "all or nothing" way; either all of them or none are rounded. - * The translation terms are handled separately, provided that the scale and shear coefficients have been rounded. - * - * @param tr the transform to round. Rounding will be applied in place. - */ - static void roundIfAlmostInteger(final AffineTransform tr) { - double r; - final double m00, m01, m10, m11; - if (abs((m00 = rint(r=tr.getScaleX())) - r) <= EPS && - abs((m01 = rint(r=tr.getShearX())) - r) <= EPS && - abs((m11 = rint(r=tr.getScaleY())) - r) <= EPS && - abs((m10 = rint(r=tr.getShearY())) - r) <= EPS) - { - /* - * At this point the scale and shear coefficients can been rounded to integers. - * Continue only if this rounding does not make the transform non-invertible. - */ - if ((m00!=0 || m01!=0) && (m10!=0 || m11!=0)) { - double m02, m12; - if (abs((r = rint(m02=tr.getTranslateX())) - m02) <= EPS) m02=r; - if (abs((r = rint(m12=tr.getTranslateY())) - m12) <= EPS) m12=r; - tr.setTransform(m00, m10, m01, m11, m02, m12); - } - } - } - - /** * Formats a pseudo-WKT representation of this transform for debugging purpose. */ @Override diff --git a/core/sis-feature/src/test/java/org/apache/sis/image/ResamplingGridTest.java b/core/sis-feature/src/test/java/org/apache/sis/image/ResamplingGridTest.java index 0570eed..3577168 100644 --- a/core/sis-feature/src/test/java/org/apache/sis/image/ResamplingGridTest.java +++ b/core/sis-feature/src/test/java/org/apache/sis/image/ResamplingGridTest.java @@ -20,7 +20,6 @@ import java.util.Arrays; import java.util.Random; import java.awt.Dimension; import java.awt.Rectangle; -import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; import org.apache.sis.geometry.Shapes2D; import org.opengis.referencing.operation.MathTransform; @@ -49,27 +48,6 @@ import static org.opengis.test.Assert.*; */ public final strictfp class ResamplingGridTest extends TestCase { /** - * Tests the {@link ResamplingGrid#roundIfAlmostInteger(AffineTransform)} method. - */ - @Test - public void testRoundIfAlmostInteger() { - final AffineTransform test = new AffineTransform(4, 0, 0, 4, -400, -1186); - final AffineTransform copy = new AffineTransform(test); - ResamplingGrid.roundIfAlmostInteger(test); - assertEquals("Translation terms were already integers, so the " + - "transform should not have been modified.", copy, test); - - test.translate(ResamplingGrid.EPS/8, -ResamplingGrid.EPS/8); - ResamplingGrid.roundIfAlmostInteger(test); - assertEquals("Translation terms should have been rounded.", copy, test); - - test.translate(ResamplingGrid.EPS*2, -ResamplingGrid.EPS*2); - ResamplingGrid.roundIfAlmostInteger(test); - assertFalse("Treshold was smaller than the translation, so the " + - "transform should not have been modified.", copy.equals(test)); - } - - /** * Tests {@link ResamplingGrid#create(MathTransform2D, MathTransform2D, Rectangle)} with an affine transform. * The method should detect the affine case and return an equal transform (not necessarily the same instance). *