/** * Checks if the transformation is a pure scale/translate instance (using the provided tolerance * factor) * * @param transform The {@link MathTransform} to check. * @param EPS The tolerance factor. * @return {@code true} if the provided transformation is a simple scale and translate, {@code * false} otherwise. */ public static boolean isScaleTranslate(final MathTransform transform, final double EPS) { if (!(transform instanceof AffineTransform)) { return false; } final AffineTransform at = (AffineTransform) transform; final double rotation = Math.abs(XAffineTransform.getRotation(at)); return rotation < EPS; // This is enough for returning 'false' if 'scale' is NaN. }
/** * Tries to estimate if the supplied affine transform is either a scale and translate transform * or if it contains a rotations which is an integer multiple of PI/2. * * @param gridToCRS an instance of {@link AffineTransform} to check against. * @param EPS tolerance value for comparisons. * @return {@code true} if this transform is "simple", {@code false} otherwise. */ public static boolean isSimpleGridToWorldTransform( final AffineTransform gridToCRS, double EPS) { final double rotation = XAffineTransform.getRotation(gridToCRS); // Checks if there is a valid rotation value (it could be 0). If the result is an integer, // then there is no rotation and skew or there is a rotation multiple of PI/2. Note that // there is no need to check explicitly for NaN rotation angle since such value will be // propagated as NaN by every math functions used here, and (NaN < EPS) returns false. final double quadrantRotation = Math.abs(rotation / (Math.PI / 2)); return Math.abs(quadrantRotation - Math.floor(quadrantRotation)) < EPS; }
private double computeScale( ReferencedEnvelope envelope, Rectangle paintArea, AffineTransform worldToScreen, Map hints) { if (getScaleComputationMethod().equals(SCALE_ACCURATE)) { try { return RendererUtilities.calculateScale( envelope, paintArea.width, paintArea.height, hints); } catch (Exception e) // probably either (1) no CRS (2) error xforming { LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); } } if (XAffineTransform.getRotation(worldToScreen) != 0.0) { return RendererUtilities.calculateOGCScaleAffine( envelope.getCoordinateReferenceSystem(), worldToScreen, hints); } return RendererUtilities.calculateOGCScale(envelope, paintArea.width, hints); }
if (worldToScreen != null && XAffineTransform.getRotation(worldToScreen) != 0.0) { finalWorldToGrid = new AffineTransform(worldToScreen); finalGridToWorld = finalWorldToGrid.createInverse();
/** * Checks if the transformation is a pure scale/translate instance (using the * provided tolerance factor) * * @param transform The {@link MathTransform} to check. * @param EPS The tolerance factor. * @return {@code true} if the provided transformation is a simple scale and translate, * {@code false} otherwise. */ public static boolean isScaleTranslate(final MathTransform transform, final double EPS) { if (!(transform instanceof AffineTransform)) { return false; } final AffineTransform at = (AffineTransform) transform; final double rotation = Math.abs(XAffineTransform.getRotation(at)); return rotation < EPS; // This is enough for returning 'false' if 'scale' is NaN. }
/** * Tries to estimate if the supplied affine transform is either a scale and * translate transform or if it contains a rotations which is an integer * multiple of PI/2. * * @param gridToCRS an instance of {@link AffineTransform} to check against. * @param EPS tolerance value for comparisons. * @return {@code true} if this transform is "simple", {@code false} otherwise. */ public static boolean isSimpleGridToWorldTransform(final AffineTransform gridToCRS, double EPS) { final double rotation = XAffineTransform.getRotation(gridToCRS); // Checks if there is a valid rotation value (it could be 0). If the result is an integer, // then there is no rotation and skew or there is a rotation multiple of PI/2. Note that // there is no need to check explicitly for NaN rotation angle since such value will be // propagated as NaN by every math functions used here, and (NaN < EPS) returns false. final double quadrantRotation = Math.abs(rotation / (Math.PI/2)); return Math.abs(quadrantRotation - Math.floor(quadrantRotation)) < EPS; }
/** * Tries to estimate if the supplied affine transform is either a scale and * translate transform or if it contains a rotations which is an integer * multiple of PI/2. * * @param sourceGridToWorldTransform an instance of {@link AffineTransform} to check against. * @param EPS tolerance value for comparisons. * @return <code>true</code> if this transform is "simple", <code>false</code> otherwise. */ public static boolean isSimpleGridToWorldTransform( final AffineTransform sourceGridToWorldTransform, double EPS) { final double rotationEsteem = XAffineTransform.getRotation(sourceGridToWorldTransform); // check if there is a valid rotation value (it could be 0!) if (!Double.isNaN(rotationEsteem)) { double badRotation=Math.abs(rotationEsteem/(Math.PI/2)); if(Math.abs(badRotation-Math.floor(badRotation))<EPS) // there is no rotation and skew or there is a rotation multiple of PI/2 return true; } return false; } }
/** * Checks the transformation is a pure scale/translate instance (using a tolerance) * @param transform * @return */ private boolean isScaleTranslate(MathTransform transform) { if(!(transform instanceof AffineTransform)) return false; final AffineTransform at = new AffineTransform((AffineTransform) transform); XAffineTransform.round(at, EPS); final double rotation= XAffineTransform.getRotation(at); final boolean retVal =(Math.abs(rotation)==0); return retVal; }
final double rotation = XAffineTransform.getRotation(gridToWorldTransform); if (swapXY == -1) throw new DataSourceException(
assertEquals(1, XAffineTransform.getScaleX0(tr), EPS); assertEquals(1, XAffineTransform.getScaleY0(tr), EPS); assertEquals(0, XAffineTransform.getRotation(tr), EPS); assertEquals(1, XAffineTransform.getSwapXY(tr)); assertEquals(f, XAffineTransform.getFlip(tr)); assertEquals(1, XAffineTransform.getScaleX0(tr), EPS); assertEquals(1, XAffineTransform.getScaleY0(tr), EPS); assertEquals(r, XAffineTransform.getRotation(tr), EPS); assertEquals(1, XAffineTransform.getSwapXY(tr)); assertEquals(f, XAffineTransform.getFlip(tr)); assertEquals(1, XAffineTransform.getScaleX0(tr), EPS); assertEquals(1, XAffineTransform.getScaleY0(tr), EPS); assertEquals(r, XAffineTransform.getRotation(tr), EPS); assertEquals(-1, XAffineTransform.getSwapXY(tr)); assertEquals(f, XAffineTransform.getFlip(tr)); assertEquals(2, XAffineTransform.getScaleX0(tr), EPS); assertEquals(3, XAffineTransform.getScaleY0(tr), EPS); assertEquals(0, XAffineTransform.getRotation(tr), EPS); assertEquals(1, XAffineTransform.getSwapXY(tr)); assertEquals(f, XAffineTransform.getFlip(tr)); assertEquals(2, XAffineTransform.getScaleX0(tr), EPS); assertEquals(3, XAffineTransform.getScaleY0(tr), EPS); assertEquals(r, XAffineTransform.getRotation(tr), EPS); assertEquals(-1, XAffineTransform.getSwapXY(tr)); assertEquals(f, XAffineTransform.getFlip(tr));
private double computeScale(ReferencedEnvelope envelope, CoordinateReferenceSystem crs, Rectangle paintArea, AffineTransform worldToScreen, Map hints) { if(getScaleComputationMethod().equals(SCALE_ACCURATE)) { try { return RendererUtilities.calculateScale(envelope, paintArea.width, paintArea.height, hints); } catch (Exception e) // probably either (1) no CRS (2) error xforming { LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); } } if (XAffineTransform.getRotation(worldToScreen) != 0.0) { return RendererUtilities.calculateOGCScaleAffine(envelope.getCoordinateReferenceSystem(), worldToScreen, hints); } return RendererUtilities.calculateOGCScale(envelope, paintArea.width, hints); }
private double computeScale(ReferencedEnvelope envelope, Rectangle paintArea, AffineTransform worldToScreen, Map hints) { if(getScaleComputationMethod().equals(SCALE_ACCURATE)) { try { return RendererUtilities.calculateScale(envelope, paintArea.width, paintArea.height, hints); } catch (Exception e) // probably either (1) no CRS (2) error xforming { LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); } } if (XAffineTransform.getRotation(worldToScreen) != 0.0) { return RendererUtilities.calculateOGCScaleAffine(envelope.getCoordinateReferenceSystem(), worldToScreen, hints); } return RendererUtilities.calculateOGCScale(envelope, paintArea.width, hints); }
double rotation = XAffineTransform.getRotation(modifiedRasterToModel);
if (Math.abs(XAffineTransform.getRotation(at)) != 0.0) { return RendererUtilities.calculateOGCScaleAffine( getCoordinateReferenceSystem(), at, hints);
if (worldToScreen != null && XAffineTransform.getRotation(worldToScreen) != 0.0) { finalWorldToGrid = new AffineTransform(worldToScreen); finalGridToWorld = finalWorldToGrid.createInverse();
XAffineTransform.round(gridToWorldTransform, ROTATION_EPS); final double rotation = XAffineTransform .getRotation(gridToWorldTransform); if (swapXY == -1) throw new DataSourceException(
XAffineTransform.round(gridToWorldTransform, ROTATION_EPS); final double rotation = XAffineTransform .getRotation(gridToWorldTransform); if (swapXY == -1) throw new DataSourceException(