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 041101c87c6f3db994d7a63a0ee84881130a04a0 Author: Martin Desruisseaux <[email protected]> AuthorDate: Thu Jan 14 17:34:27 2021 +0100 Arbitrarily draw isolines with a line tickness of 1/8 of source pixel size, for making apparent when zoom is becoming too strong for data resolution. --- .../apache/sis/gui/coverage/CoverageCanvas.java | 5 ++-- .../org/apache/sis/gui/coverage/RenderingData.java | 27 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java index 60d4f73..91abb4a 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/CoverageCanvas.java @@ -711,9 +711,10 @@ public class CoverageCanvas extends MapCanvasAWT { gr.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); gr.drawRenderedImage(prefetchedImage, resampledToDisplay); if (isolines != null) { - AffineTransform at = gr.getTransform(); + final AffineTransform at = gr.getTransform(); final Stroke st = gr.getStroke(); - gr.setStroke(new BasicStroke(0)); + // Arbitrarily use a line tickness of 1/8 of source pixel size for making apparent when zoom is strong. + gr.setStroke(new BasicStroke(data.getDataPixelSize(objectivePOI) / 8)); gr.transform((AffineTransform) objectiveToDisplay); // This cast is safe in PlanarCanvas subclass. for (final IsolineRenderer.Snapshot s : isolines) { s.paint(gr, objectiveAOI); diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RenderingData.java b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RenderingData.java index 4ed6077..7dfb293 100644 --- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RenderingData.java +++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RenderingData.java @@ -31,6 +31,7 @@ import java.awt.geom.NoninvertibleTransformException; import org.opengis.util.FactoryException; import org.opengis.geometry.DirectPosition; import org.opengis.referencing.datum.PixelInCell; +import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.CoordinateOperation; import org.opengis.referencing.operation.MathTransform; import org.opengis.referencing.operation.TransformException; @@ -498,6 +499,32 @@ final class RenderingData implements Cloneable { } /** + * Returns an estimation of the size of data pixels, in objective CRS. + * + * @param objectivePOI point of interest in objective CRS. + * @return an estimation of the source pixel size at the given location. + */ + final float getDataPixelSize(final DirectPosition objectivePOI) { + if (objectiveToCenter != null) try { + final Matrix d = objectiveToCenter.derivative(objectivePOI); + double sum = 0; + for (int j=d.getNumRow(); --j >= 0;) { + for (int i=d.getNumCol(); --i >= 0;) { + final double v = d.getElement(j, i); + sum += v*v; + } + } + final float r = (float) (1 / Math.sqrt(sum)); + if (r > 0 && r != Float.POSITIVE_INFINITY) { + return r; + } + } catch (TransformException e) { + recoverableException(e); + } + return 0; + } + + /** * Converts the given bounds from objective coordinates to pixel coordinates in the source coverage. * * @param bounds objective coordinates.
