Class ReprojectionTile

java.lang.Object
org.openstreetmap.gui.jmapviewer.Tile
org.openstreetmap.josm.gui.layer.imagery.ReprojectionTile

public class ReprojectionTile extends org.openstreetmap.gui.jmapviewer.Tile
Tile class that stores a reprojected version of the original tile.
Since:
11858
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected TileAnchor
     
    protected boolean
     
    private double
     
    private final org.openstreetmap.gui.jmapviewer.Tile
     

    Fields inherited from class org.openstreetmap.gui.jmapviewer.Tile

    error, ERROR_IMAGE, error_message, image, key, loaded, loading, LOADING_IMAGE, metadata, source, xtile, ytile, zoom
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReprojectionTile(org.openstreetmap.gui.jmapviewer.interfaces.TileSource source, int xtile, int ytile, int zoom)
    Constructs a new ReprojectionTile.
    ReprojectionTile(org.openstreetmap.gui.jmapviewer.Tile tile)
    Create a reprojection tile for a specific tile
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the position of the tile inside the image.
    private static Dimension
    getDimension(ProjectionBounds bounds, double scale)
     
    double
    Get the scale that was used for reprojecting the tile.
    void
    Invalidate tile - mark it as not loaded.
    protected Integer
    limitScale(double lenOrig, double lenNow)
    Make sure, the image is not scaled up too much.
    void
    loadImage(InputStream inputStream)
     
    boolean
    needsUpdate(double currentScale)
    Check if it is necessary to refresh the cache to match the current mapview scale and get optimized image quality.
    private static ProjectionBounds
    pbMarginAndAlign(ProjectionBounds box, double scale, double margin)
     
    private void
     
    void
     
    private EastNorth
    tileToEastNorth(int x, int y, int z)
     
    protected void
    Transforms the given image.

    Methods inherited from class org.openstreetmap.gui.jmapviewer.Tile

    equals, finishLoading, getErrorMessage, getImage, getKey, getMetadata, getSource, getStatus, getTileKey, getTileSource, getTileXY, getUrl, getValue, getXtile, getYtile, getZoom, hasError, hashCode, initLoading, isLoaded, isLoading, loadingCanceled, loadPlaceholderFromCache, paint, paint, putValue, setError, setError, setLoaded, toString

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • ReprojectionTile

      public ReprojectionTile(org.openstreetmap.gui.jmapviewer.interfaces.TileSource source, int xtile, int ytile, int zoom)
      Constructs a new ReprojectionTile.
      Parameters:
      source - source tile
      xtile - X coordinate
      ytile - Y coordinate
      zoom - zoom level
    • ReprojectionTile

      public ReprojectionTile(org.openstreetmap.gui.jmapviewer.Tile tile)
      Create a reprojection tile for a specific tile
      Parameters:
      tile - The tile to use
  • Method Details

    • getAnchor

      Get the position of the tile inside the image.
      Returns:
      the position of the tile inside the image
      See Also:
      • Tile.getImage()
    • getNativeScale

      public double getNativeScale()
      Get the scale that was used for reprojecting the tile.

      This is not necessarily the mapview scale, but may be adjusted to avoid excessively large cache image.

      Returns:
      the scale that was used for reprojecting the tile
    • needsUpdate

      public boolean needsUpdate(double currentScale)
      Check if it is necessary to refresh the cache to match the current mapview scale and get optimized image quality.

      When the maximum zoom is exceeded, this method will generally return false.

      Parameters:
      currentScale - the current mapview scale
      Returns:
      true if the tile should be reprojected again from the source image.
    • loadImage

      public void loadImage(InputStream inputStream) throws IOException
      Overrides:
      loadImage in class org.openstreetmap.gui.jmapviewer.Tile
      Throws:
      IOException
    • setImage

      public void setImage(BufferedImage image)
      Overrides:
      setImage in class org.openstreetmap.gui.jmapviewer.Tile
    • invalidate

      public void invalidate()
      Invalidate tile - mark it as not loaded.
    • reset

      private void reset()
    • tileToEastNorth

      private EastNorth tileToEastNorth(int x, int y, int z)
    • transform

      protected void transform(BufferedImage imageIn)
      Transforms the given image.
      Parameters:
      imageIn - tile image to reproject
    • pbMarginAndAlign

      private static ProjectionBounds pbMarginAndAlign(ProjectionBounds box, double scale, double margin)
    • getDimension

      private static Dimension getDimension(ProjectionBounds bounds, double scale)
    • limitScale

      protected Integer limitScale(double lenOrig, double lenNow)
      Make sure, the image is not scaled up too much.

      This would not give any significant improvement in image quality and may exceed the user's memory. The correction factor is a power of 2.

      Parameters:
      lenOrig - tile size of original image
      lenNow - (averaged) tile size of warped image
      Returns:
      factor to shrink if limit is exceeded; 1 if it is already at the limit, but no change needed; null if it is well below the limit and can still be scaled up by at least a factor of 2.