Class 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 anchor  
      protected boolean maxZoomReached  
      private double nativeScale  
      private org.openstreetmap.gui.jmapviewer.Tile 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
    • Constructor Detail

      • 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 Detail

      • getAnchor

        public TileAnchor 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.
      • 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()
      • transform

        protected void transform​(BufferedImage imageIn)
        Transforms the given image.
        Parameters:
        imageIn - tile image to reproject
      • 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.