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 f70bb327ff4d3944af9a7742d89b085079642bcf Author: Martin Desruisseaux <[email protected]> AuthorDate: Mon May 2 18:01:01 2022 +0200 Before to replace a map projection by a spherical optimization, verify if it is safe to do so. If user created a subclasses, we should not do such replacement because it would ignore user's code. --- .../apache/sis/referencing/operation/projection/AlbersEqualArea.java | 4 ++-- .../apache/sis/referencing/operation/projection/CassiniSoldner.java | 4 ++-- .../sis/referencing/operation/projection/CylindricalEqualArea.java | 4 ++-- .../sis/referencing/operation/projection/LambertConicConformal.java | 4 ++-- .../org/apache/sis/referencing/operation/projection/Mercator.java | 4 ++-- .../operation/projection/ModifiedAzimuthalEquidistant.java | 4 ++-- .../sis/referencing/operation/projection/ObliqueStereographic.java | 4 ++-- .../sis/referencing/operation/projection/PolarStereographic.java | 4 ++-- .../org/apache/sis/referencing/operation/projection/Polyconic.java | 4 ++-- .../org/apache/sis/referencing/operation/projection/Sinusoidal.java | 4 ++-- .../sis/referencing/operation/projection/TransverseMercator.java | 4 ++-- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AlbersEqualArea.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AlbersEqualArea.java index c72a3df34d..575da204f1 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AlbersEqualArea.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/AlbersEqualArea.java @@ -210,7 +210,7 @@ public class AlbersEqualArea extends EqualAreaProjection { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory The factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -219,7 +219,7 @@ public class AlbersEqualArea extends EqualAreaProjection { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { AlbersEqualArea kernel = this; - if (eccentricity == 0) { + if (eccentricity == 0 && getClass() == AlbersEqualArea.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CassiniSoldner.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CassiniSoldner.java index aadd54246e..10b368415a 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CassiniSoldner.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CassiniSoldner.java @@ -217,7 +217,7 @@ public class CassiniSoldner extends MeridianArcBased { * as a whole. The transform returned by this method expects (<var>longitude</var>, <var>latitude</var>) * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation. + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation. * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -226,7 +226,7 @@ public class CassiniSoldner extends MeridianArcBased { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { CassiniSoldner kernel = this; - if (eccentricity == 0 && variant == null) { + if ((eccentricity == 0 && variant == null) && getClass() == CassiniSoldner.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CylindricalEqualArea.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CylindricalEqualArea.java index 8ecd0f4b67..b669140786 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CylindricalEqualArea.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/CylindricalEqualArea.java @@ -214,7 +214,7 @@ public class CylindricalEqualArea extends EqualAreaProjection { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -223,7 +223,7 @@ public class CylindricalEqualArea extends EqualAreaProjection { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { CylindricalEqualArea kernel = this; - if (variant == Variant.SPHERICAL || eccentricity == 0) { + if ((variant == Variant.SPHERICAL || eccentricity == 0) && getClass() == CylindricalEqualArea.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConicConformal.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConicConformal.java index d5d311c3e7..a20dcb8a44 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConicConformal.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConicConformal.java @@ -407,7 +407,7 @@ public class LambertConicConformal extends ConformalProjection { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -416,7 +416,7 @@ public class LambertConicConformal extends ConformalProjection { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { LambertConicConformal kernel = this; - if (eccentricity == 0) { + if (eccentricity == 0 && getClass() == LambertConicConformal.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java index cddb5f0827..88b3bb0ece 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java @@ -374,7 +374,7 @@ public class Mercator extends ConformalProjection { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -383,7 +383,7 @@ public class Mercator extends ConformalProjection { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { Mercator kernel = this; - if (variant.spherical || eccentricity == 0) { + if ((variant.spherical || eccentricity == 0) && getClass() == Mercator.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java index 1d7d59499d..744aea5089 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ModifiedAzimuthalEquidistant.java @@ -139,7 +139,7 @@ public class ModifiedAzimuthalEquidistant extends AzimuthalEquidistant { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -148,7 +148,7 @@ public class ModifiedAzimuthalEquidistant extends AzimuthalEquidistant { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { AzimuthalEquidistant kernel = this; - if (eccentricity == 0) { + if (eccentricity == 0 && getClass() == ModifiedAzimuthalEquidistant.class) { kernel = new AzimuthalEquidistant(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java index 9a6cf818fd..4796e00475 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueStereographic.java @@ -230,7 +230,7 @@ public class ObliqueStereographic extends NormalizedProjection { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -250,7 +250,7 @@ public class ObliqueStereographic extends NormalizedProjection { } } ObliqueStereographic kernel = this; - if (eccentricity == 0) { + if (eccentricity == 0 && getClass() == ObliqueStereographic.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java index 6861708782..510bbd2251 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java @@ -284,7 +284,7 @@ public class PolarStereographic extends ConformalProjection { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -293,7 +293,7 @@ public class PolarStereographic extends ConformalProjection { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { PolarStereographic kernel = this; - if (eccentricity == 0) { + if (eccentricity == 0 && getClass() == PolarStereographic.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Polyconic.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Polyconic.java index b4bf84d41a..4170432dc8 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Polyconic.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Polyconic.java @@ -152,7 +152,7 @@ public class Polyconic extends MeridianArcBased { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -161,7 +161,7 @@ public class Polyconic extends MeridianArcBased { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { Polyconic kernel = this; - if (eccentricity == 0) { + if (eccentricity == 0 && getClass() == Polyconic.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Sinusoidal.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Sinusoidal.java index 38a12c3142..808d9e439d 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Sinusoidal.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Sinusoidal.java @@ -92,7 +92,7 @@ public class Sinusoidal extends MeridianArcBased { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -101,7 +101,7 @@ public class Sinusoidal extends MeridianArcBased { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { Sinusoidal kernel = this; - if (eccentricity == 0) { + if (eccentricity == 0 && getClass() == Sinusoidal.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); diff --git a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java index c1a07dc8da..dfb7fc647b 100644 --- a/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java +++ b/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java @@ -354,7 +354,7 @@ public class TransverseMercator extends NormalizedProjection { * coordinates in <em>degrees</em> and returns (<var>x</var>,<var>y</var>) coordinates in <em>metres</em>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid - * is spherical. In the latter case, {@code this} transform will be replaced by a simplified implementation.</p> + * is spherical. In the latter case, {@code this} transform may be replaced by a simplified implementation.</p> * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. @@ -363,7 +363,7 @@ public class TransverseMercator extends NormalizedProjection { @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { TransverseMercator kernel = this; - if (eccentricity == 0) { + if (eccentricity == 0 && getClass() == TransverseMercator.class) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel);
