/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * Conversion to other units and {@linkplain org.apache.sis.referencing.cs.CoordinateSystems#swapAndScaleAxes * changes in axis order} are <strong>not</strong> managed by the returned transform. * * <p>The default implementation is as below:</p> * {@preformat java * return getContextualParameters().completeTransform(factory, this); * } * * Subclasses can override this method if they wish to use alternative implementations under some circumstances. * For example many subclasses will replace {@code this} by a specialized implementation if they detect that the * ellipsoid is actually spherical. * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. * @throws FactoryException if an error occurred while creating a transform. * * @see ContextualParameters#completeTransform(MathTransformFactory, MathTransform) */ public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { return context.completeTransform(factory, this); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * Conversion to other units and {@linkplain org.apache.sis.referencing.cs.CoordinateSystems#swapAndScaleAxes * changes in axis order} are <strong>not</strong> managed by the returned transform. * * <p>The default implementation is as below:</p> * {@preformat java * return getContextualParameters().completeTransform(factory, this); * } * * Subclasses can override this method if they wish to use alternative implementations under some circumstances. * For example many subclasses will replace {@code this} by a specialized implementation if they detect that the * ellipsoid is actually spherical. * * @param factory the factory to use for creating the transform. * @return the map projection from (λ,φ) to (<var>x</var>,<var>y</var>) coordinates. * @throws FactoryException if an error occurred while creating a transform. * * @see ContextualParameters#completeTransform(MathTransformFactory, MathTransform) */ public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { return context.completeTransform(factory, this); }
/** * Delegates to {@link ContextualParameters#completeTransform(MathTransformFactory, MathTransform)} * for this transformation and for its dependencies as well. */ private MathTransform completeTransform(final MathTransformFactory factory, final boolean create) throws FactoryException { ellipsoidToCentric.getContextualParameters().completeTransform(factory, null); centricToEllipsoid.getContextualParameters().completeTransform(factory, null); return context.completeTransform(factory, create ? this : null); }
/** * Delegates to {@link ContextualParameters#completeTransform(MathTransformFactory, MathTransform)} * for this transformation and for its dependencies as well. */ private MathTransform completeTransform(final MathTransformFactory factory, final boolean create) throws FactoryException { ellipsoidToCentric.getContextualParameters().completeTransform(factory, null); centricToEllipsoid.getContextualParameters().completeTransform(factory, null); return context.completeTransform(factory, create ? this : null); }
/** * Returns the complete transform, including conversion between degrees and radians units. */ final MathTransform completeTransform(final MathTransformFactory factory) throws FactoryException { MathTransform tr = complete; if (tr == null) { tr = context.completeTransform(factory, this); if (DefaultFactories.isDefaultInstance(MathTransformFactory.class, factory)) { // No need to synchronize since DefaultMathTransformFactory returns unique instances. complete = tr; } } return tr; }
/** * Returns the complete transform, including conversion between degrees and radians units. */ final MathTransform completeTransform(final MathTransformFactory factory) throws FactoryException { MathTransform tr = complete; if (tr == null) { tr = context.completeTransform(factory, this); if (DefaultFactories.isDefaultInstance(MathTransformFactory.class, factory)) { // No need to synchronize since DefaultMathTransformFactory returns unique instances. complete = tr; } } return tr; }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { Mercator kernel = this; if ((variant & SPHERICAL) != 0 || eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { AlbersEqualArea kernel = this; if (eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { LambertConicConformal kernel = this; if (eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { CylindricalEqualArea kernel = this; if (variant == Initializer.AUTHALIC_RADIUS || eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { TransverseMercator kernel = this; if (eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { Mercator kernel = this; if ((variant & SPHERICAL) != 0 || eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { LambertConicConformal kernel = this; if (eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { PolarStereographic kernel = this; if (eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { TransverseMercator kernel = this; if (eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { PolarStereographic kernel = this; if (eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { CylindricalEqualArea kernel = this; if (variant == Initializer.AUTHALIC_RADIUS || eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Returns the sequence of <cite>normalization</cite> → {@code this} → <cite>denormalization</cite> transforms * 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>. * * <p>The non-linear part of the returned transform will be {@code this} transform, except if the ellipsoid * is spherical. In the later case, {@code this} transform will 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. * @throws FactoryException if an error occurred while creating a transform. */ @Override public MathTransform createMapProjection(final MathTransformFactory factory) throws FactoryException { AlbersEqualArea kernel = this; if (eccentricity == 0) { kernel = new Spherical(this); } return context.completeTransform(factory, kernel); }
/** * Tests {@link ContextualParameters#completeTransform(MathTransformFactory, MathTransform)} * with identity normalization / denormalization transform. The complete transform should be * equals to the kernel (often the same instance, but not necessarily because of caching). * * @throws FactoryException should never happen. */ @Test public void testSameTransform() throws FactoryException { final ContextualParameters p = create(1, 1); p.parameter("Mandatory 1").setValue(4); final MathTransform kernel = MathTransforms.linear(3, 4); assertEquals(kernel, p.completeTransform(DefaultMathTransformFactoryTest.factory(), kernel)); try { p.parameter("Mandatory 1").setValue(10); fail("Shall not be allowed to modify an immutable instance."); } catch (UnsupportedOperationException e) { // This is the expected exception. final String message = e.getMessage(); assertTrue(message, message.contains("ParameterValue")); } }
/** * Convenience method for creating an instance from an ellipsoid. */ private void createGeodeticConversion(final Ellipsoid ellipsoid, boolean is3D) throws FactoryException { final MathTransformFactory factory = DefaultFactories.forBuildin(MathTransformFactory.class); transform = EllipsoidToCentricTransform.createGeodeticConversion(factory, ellipsoid, is3D); /* * If the ellipsoid is a sphere, then EllipsoidToCentricTransform.createGeodeticConversion(…) created a * SphericalToCartesian instance instead than an EllipsoidToCentricTransform instance. Create manually * the EllipsoidToCentricTransform here and wrap the two transform in a comparator for making sure that * the two implementations are consistent. */ if (ellipsoid.isSphere()) { EllipsoidToCentricTransform tr = new EllipsoidToCentricTransform( ellipsoid.getSemiMajorAxis(), ellipsoid.getSemiMinorAxis(), ellipsoid.getAxisUnit(), is3D, EllipsoidToCentricTransform.TargetType.CARTESIAN); transform = new TransformResultComparator(transform, tr.context.completeTransform(factory, tr), 1E-2); } }