@Test public void testCheckReciprocal() throws TransformException, FactoryException { final double[] dst = new double[PROJECTED.length]; MapProjection mt = createGoogleMercator(); mt.transform(GEOGRAPHIC, 0, dst, 0, PROJECTED.length / 2); for (int i = 0; i < PROJECTED.length; i++) { assertEquals(PROJECTED[i], dst[i], 0.1); } for (int i = 0; i < PROJECTED.length / 2; i++) { Point2D src = new Point2D.Double(GEOGRAPHIC[i * 2 + 0], GEOGRAPHIC[i * 2 + 1]); Point2D target = new Point2D.Double(PROJECTED[i * 2 + 0], PROJECTED[i * 2 + 1]); assertEquals(true, mt.checkReciprocal(src, target, false)); assertEquals(true, mt.checkReciprocal(target, src, true)); } mt.inverse().transform(PROJECTED, 0, dst, 0, PROJECTED.length / 2); for (int i = 0; i < GEOGRAPHIC.length; i++) { assertEquals(GEOGRAPHIC[i], dst[i], 0.0001); } }
protected boolean checkReciprocal(Point2D point, final Point2D target, final boolean inverse) throws ProjectionException { if (SKIP_SANITY_CHECKS) { return true; } if (!(point instanceof CheckPoint)) try { point = new CheckPoint(point); final double longitude; final double latitude; final double distance; if (inverse) { point = inverse().transform(point, point); distance = orthodromicDistance(point, target); longitude = point.getX(); latitude = point.getY(); } else { longitude = point.getX(); latitude = point.getY(); point = transform(point, point); distance = point.distance(target); } if (distance > getToleranceForAssertions(longitude, latitude)) { throw new ProjectionException( Errors.format( ErrorKeys.PROJECTION_CHECK_FAILED_$4, distance, new Longitude(longitude - toDegrees(centralMeridian)), new Latitude(latitude - toDegrees(latitudeOfOrigin)), getName())); } } catch (ProjectionException exception) { throw exception; } catch (TransformException exception) { throw new ProjectionException(exception); } return true; }
MapProjection extends AbstractMathTransform implements MathTransform2D, Serializable { protected boolean checkReciprocal(Point2D point, final Point2D target, final boolean inverse) throws ProjectionException { if (SKIP_SANITY_CHECKS) { return true; } if (!(point instanceof CheckPoint)) try { point = new CheckPoint(point); final double longitude; final double latitude; final double distance; if (inverse) { point = inverse().transform(point, point); distance = orthodromicDistance(point, target); longitude = point.getX(); latitude = point.getY(); } else { longitude = point.getX(); latitude = point.getY(); point = transform(point, point); distance = point.distance(target); } if (distance > getToleranceForAssertions(longitude, latitude)) { throw new ProjectionException( Errors.format( ErrorKeys.PROJECTION_CHECK_FAILED_$4, distance, new Longitude(longitude - toDegrees(centralMeridian)), new Latitude(latitude - toDegrees(latitudeOfOrigin)), getName())); } } catch (ProjectionException exception) { throw exception; } catch (TransformException exception) { throw new ProjectionException(exception); } return true; } }
MapProjection extends AbstractMathTransform implements MathTransform2D, Serializable { protected boolean checkReciprocal(Point2D point, final Point2D target, final boolean inverse) throws ProjectionException { if (SKIP_SANITY_CHECKS) { return true; } if (!(point instanceof CheckPoint)) try { point = new CheckPoint(point); final double longitude; final double latitude; final double distance; if (inverse) { point = inverse().transform(point, point); distance = orthodromicDistance(point, target); longitude = point.getX(); latitude = point.getY(); } else { longitude = point.getX(); latitude = point.getY(); point = transform(point, point); distance = point.distance(target); } if (distance > getToleranceForAssertions(longitude, latitude)) { throw new ProjectionException( Errors.format( ErrorKeys.PROJECTION_CHECK_FAILED_$4, distance, new Longitude(longitude - toDegrees(centralMeridian)), new Latitude(latitude - toDegrees(latitudeOfOrigin)), getName())); } } catch (ProjectionException exception) { throw exception; } catch (TransformException exception) { throw new ProjectionException(exception); } return true; } protected  MapProjection(final ParameterValueGroup values);   MapProjection(final ParameterValueGroup values, Collection<GeneralParameterDescriptor> expected); }
MapProjection extends AbstractMathTransform implements MathTransform2D, Serializable { protected boolean checkReciprocal(Point2D point, final Point2D target, final boolean inverse) throws ProjectionException { if (SKIP_SANITY_CHECKS) { return true; } if (!(point instanceof CheckPoint)) try { point = new CheckPoint(point); final double longitude; final double latitude; final double distance; if (inverse) { point = inverse().transform(point, point); distance = orthodromicDistance(point, target); longitude = point.getX(); latitude = point.getY(); } else { longitude = point.getX(); latitude = point.getY(); point = transform(point, point); distance = point.distance(target); } if (distance > getToleranceForAssertions(longitude, latitude)) { throw new ProjectionException( Errors.format( ErrorKeys.PROJECTION_CHECK_FAILED_$4, distance, new Longitude(longitude - toDegrees(centralMeridian)), new Latitude(latitude - toDegrees(latitudeOfOrigin)), getName())); } } catch (ProjectionException exception) { throw exception; } catch (TransformException exception) { throw new ProjectionException(exception); } return true; } protected  MapProjection(final ParameterValueGroup values);   MapProjection(final ParameterValueGroup values, Collection<GeneralParameterDescriptor> expected); @Override abstract ParameterDescriptorGroup getParameterDescriptors(); @Override ParameterValueGroup getParameterValues(); final int getSourceDimensions(); final int getTargetDimensions(); @Override final Point2D transform(final Point2D ptSrc, Point2D ptDst); final void transform(
            final double[] srcPts, int srcOff, final double[] dstPts, int dstOff, int numPts); @Override final void transform(
            final float[] srcPts, int srcOff, final float[] dstPts, int dstOff, int numPts); @Override final MathTransform2D inverse(); static synchronized void resetWarnings(); @Override int hashCode(); @Override boolean equals(final Object object); }
MapProjection extends AbstractMathTransform implements MathTransform2D, Serializable { protected boolean checkReciprocal(Point2D point, final Point2D target, final boolean inverse) throws ProjectionException { if (SKIP_SANITY_CHECKS) { return true; } if (!(point instanceof CheckPoint)) try { point = new CheckPoint(point); final double longitude; final double latitude; final double distance; if (inverse) { point = inverse().transform(point, point); distance = orthodromicDistance(point, target); longitude = point.getX(); latitude = point.getY(); } else { longitude = point.getX(); latitude = point.getY(); point = transform(point, point); distance = point.distance(target); } if (distance > getToleranceForAssertions(longitude, latitude)) { throw new ProjectionException( Errors.format( ErrorKeys.PROJECTION_CHECK_FAILED_$4, distance, new Longitude(longitude - toDegrees(centralMeridian)), new Latitude(latitude - toDegrees(latitudeOfOrigin)), getName())); } } catch (ProjectionException exception) { throw exception; } catch (TransformException exception) { throw new ProjectionException(exception); } return true; } protected  MapProjection(final ParameterValueGroup values);   MapProjection(final ParameterValueGroup values, Collection<GeneralParameterDescriptor> expected); @Override abstract ParameterDescriptorGroup getParameterDescriptors(); @Override ParameterValueGroup getParameterValues(); final int getSourceDimensions(); final int getTargetDimensions(); @Override final Point2D transform(final Point2D ptSrc, Point2D ptDst); final void transform(
            final double[] srcPts, int srcOff, final double[] dstPts, int dstOff, int numPts); @Override final void transform(
            final float[] srcPts, int srcOff, final float[] dstPts, int dstOff, int numPts); @Override final MathTransform2D inverse(); static synchronized void resetWarnings(); @Override int hashCode(); @Override boolean equals(final Object object); static boolean SKIP_SANITY_CHECKS; }