/** * This method performs the computation using the methods suggested by the OGC SLD * specification, page 26. * * @param CRS the coordinate reference system. Used to check if we are operating in degrees or * meters. * @param worldToScreen the transformation mapping world coordinates to screen coordinates. * Might specify a rotation in addition to translation and scaling. * @return */ public static double calculateOGCScaleAffine( CoordinateReferenceSystem crs, AffineTransform worldToScreen, Map hints) { double scale = XAffineTransform.getScale(worldToScreen); // if it's geodetic, we're dealing with lat/lon unit measures if (crs instanceof GeographicCRS) { return (OGC_DEGREE_TO_METERS * getDpi(hints)) / (scale * 0.0254); } else { return (getDpi(hints)) / (scale * 0.0254); } }
/** * This method performs the computation using the methods suggested by the OGC SLD specification, page 26. * @param CRS the coordinate reference system. Used to check if we are operating in degrees or * meters. * @param worldToScreen the transformation mapping world coordinates to screen coordinates. Might * specify a rotation in addition to translation and scaling. * @return */ public static double calculateOGCScaleAffine(CoordinateReferenceSystem crs,AffineTransform worldToScreen, Map hints) { double scale = XAffineTransform.getScale(worldToScreen); // if it's geodetic, we're dealing with lat/lon unit measures if(crs instanceof GeographicCRS) { return (OGC_DEGREE_TO_METERS * getDpi(hints))/(scale * 0.0254); } else { return (getDpi(hints))/(scale * 0.0254); } }
/** * Returns the scale of the "grid to CRS" transform, or {@link Double#NaN} if unknown. * * @param coverage The coverage for which to get the "grid to CRS" scale, or {@code null}. * @return The "grid to CRS" scale, or {@code NaN} if none or if the transform is not affine. */ protected static double getScale(final Coverage coverage) { final AffineTransform gridToCRS = getAffineTransform(coverage); return (gridToCRS != null) ? XAffineTransform.getScale(gridToCRS) : Double.NaN; }
final double tolerance = XAffineTransform.getScale(sourceCornerGridToWorld); if (cropRoi != null || !intersectionEnvelope.equals(sourceEnvelope, tolerance / 2.0, false)) {
cropEnvelope.getCoordinateReferenceSystem(), XAffineTransform.transform(sourceGridToWorldTransform, finalGridRange,null))); assert testEnvelope.equals(cropEnvelope, XAffineTransform.getScale(sourceGridToWorldTransform)/2,false );
final double tolerance = XAffineTransform.getScale(sourceGridToWorld); if (!intersectionEnvelope .equals(sourceEnvelope, tolerance / 2.0, false)) {
final double tolerance = XAffineTransform.getScale(sourceCornerGridToWorld); if (cropRoi != null || !intersectionEnvelope.equals(sourceEnvelope, tolerance / 2.0, false)) { cropEnvelope = intersectionEnvelope.clone();