You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2019/02/27 11:10:05 UTC
[sis] branch geoapi-4.0 updated: MathTransform2D.transform(Shape)
now throws an exception if the transform result in NaN of infinite
coordinates. We do not allow such coordinates because accepting NaN here
results in failures later anyway,
when using some Java2D objects like java.awt.geom.Area.
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
The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
new 009819e MathTransform2D.transform(Shape) now throws an exception if the transform result in NaN of infinite coordinates. We do not allow such coordinates because accepting NaN here results in failures later anyway, when using some Java2D objects like java.awt.geom.Area.
009819e is described below
commit 009819e2d2751100548ae8ba2a60aac96c7be3fa
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Feb 27 12:08:12 2019 +0100
MathTransform2D.transform(Shape) now throws an exception if the transform result in NaN of infinite coordinates.
We do not allow such coordinates because accepting NaN here results in failures later anyway, when using some Java2D objects like java.awt.geom.Area.
---
.../apache/sis/internal/referencing/Resources.java | 10 +++++++++
.../sis/internal/referencing/Resources.properties | 2 ++
.../internal/referencing/Resources_fr.properties | 2 ++
.../transform/AbstractMathTransform2D.java | 24 +++++++++++++++++-----
4 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
index cf0e8bb..5c89e58 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.java
@@ -129,11 +129,21 @@ public final class Resources extends IndexedResourceBundle {
public static final short CanNotSeparateTransform_3 = 83;
/**
+ * Can not transform the ({0,number}, {1,number}) coordinates.
+ */
+ public static final short CanNotTransformCoordinates_2 = 85;
+
+ /**
* Can not transform envelope to a geodetic reference system.
*/
public static final short CanNotTransformEnvelopeToGeodetic = 8;
/**
+ * Can not transform the given geometry.
+ */
+ public static final short CanNotTransformGeometry = 86;
+
+ /**
* Can not use the {0} geodetic parameters: {1}
*/
public static final short CanNotUseGeodeticParameters_2 = 9;
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
index 0e26dad..17d7b7b 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources.properties
@@ -54,7 +54,9 @@ CanNotParseCombinedReference_2 = Can not parse component {1} in the combined
CanNotSeparateCRS_1 = Can not separate the \u201c{0}\u201d coordinate reference system into sub-components.
CanNotSeparateTransform_3 = Can not separate the transform because result would have {2} {0,choice,0#source|1#target} dimension{2,choice,1#|2#s} instead of {1}.
CanNotSeparateTargetDimension_1 = Target dimension {0} depends on excluded source dimensions.
+CanNotTransformCoordinates_2 = Can not transform the ({0,number}, {1,number}) coordinates.
CanNotTransformEnvelopeToGeodetic = Can not transform envelope to a geodetic reference system.
+CanNotTransformGeometry = Can not transform the given geometry.
CanNotUseGeodeticParameters_2 = Can not use the {0} geodetic parameters: {1}
ColinearAxisDirections_2 = Axis directions {0} and {1} are colinear.
CoordinateOperationNotFound_2 = Coordinate conversion of transformation from system \u201c{0}\u201d to \u201c{1}\u201d has not been found.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
index 3e25983..a4feee5 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/Resources_fr.properties
@@ -59,7 +59,9 @@ CanNotSeparateCRS_1 = Ne peut pas s\u00e9parer le syst\u00e8me de
CanNotSeparateTransform_3 = Ne peut pas s\u00e9parer la transformation parce-que le r\u00e9sultat aurait {2} dimension{2,choice,1#|2#s} en {0,choice,0#entr\u00e9|1#sortie} au lieu de {1}.
CanNotSeparateTargetDimension_1 = La dimension de destination {0} d\u00e9pend de dimensions sources qui ont \u00e9t\u00e9 exclues.
CanNotParseCombinedReference_2 = Ne peut pas d\u00e9coder la composante {1} dans l\u2019{0,choice,0#URN|1#URL} combin\u00e9.
+CanNotTransformCoordinates_2 = Ne peut pas transformer les coordonn\u00e9es ({0,number}; {1,number}).
CanNotTransformEnvelopeToGeodetic = Ne peut pas transformer l\u2019enveloppe vers un r\u00e9f\u00e9rentiel g\u00e9od\u00e9sique.
+CanNotTransformGeometry = Ne peut pas transformer la g\u00e9om\u00e9trie donn\u00e9e.
CanNotUseGeodeticParameters_2 = Ne peut pas utiliser les param\u00e8tres g\u00e9od\u00e9siques {0}\u202f: {1}
ColinearAxisDirections_2 = Les directions d\u2019axes {0} et {1} sont colin\u00e9aires.
CoordinateOperationNotFound_2 = La conversion ou transformation des coordonn\u00e9es du syst\u00e8me \u00ab\u202f{0}\u202f\u00bb vers \u00ab\u202f{1}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9e.
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
index d393ceb..c0ed690 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/AbstractMathTransform2D.java
@@ -186,8 +186,12 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl
mt.transform(buffer, 0, buffer, 0, 1);
px = buffer[0];
py = buffer[1];
- path.moveTo(px, py);
- continue;
+ if (Double.isFinite(px) && Double.isFinite(py)) {
+ path.moveTo(px, py);
+ continue;
+ } else {
+ throw new TransformException(Resources.format(Resources.Keys.CanNotTransformCoordinates_2, ax, ay));
+ }
}
case PathIterator.SEG_LINETO: {
/*
@@ -254,10 +258,20 @@ public abstract class AbstractMathTransform2D extends AbstractMathTransform impl
horizontal);
px = buffer[2];
py = buffer[3];
- if (ctrlPoint != null) {
- path.quadTo(ctrlPoint.getX(), ctrlPoint.getY(), px, py);
+ if (Double.isFinite(px) && Double.isFinite(py)) {
+ if (ctrlPoint == null) {
+ path.lineTo(px, py);
+ } else {
+ final double cx = ctrlPoint.getX();
+ final double cy = ctrlPoint.getY();
+ if (Double.isFinite(cx) && Double.isFinite(cy)) {
+ path.quadTo(cx, cy, px, py);
+ } else {
+ throw new TransformException(Resources.format(Resources.Keys.CanNotTransformGeometry));
+ }
+ }
} else {
- path.lineTo(px, py);
+ throw new TransformException(Resources.format(Resources.Keys.CanNotTransformCoordinates_2, ax, ay));
}
}
/*