Class TileCoordinateConverter


  • public class TileCoordinateConverter
    extends java.lang.Object
    This class handles tile coordinate management and computes their position in the map view.
    Since:
    10651
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.awt.geom.Point2D getPixelForTile​(int x, int y, int zoom)
      Gets the top left position of the tile inside the map view.
      java.awt.geom.Point2D getPixelForTile​(org.openstreetmap.gui.jmapviewer.Tile tile)
      Gets the top left position of the tile inside the map view.
      Projecting getProjecting()
      Gets the projecting instance to use to convert between latlon and eastnorth coordinates.
      java.awt.geom.Rectangle2D getRectangleForTile​(org.openstreetmap.gui.jmapviewer.Tile tile)
      Gets the position of the tile inside the map view.
      double getScaleFactor​(int zoom)
      Returns average number of screen pixels per tile pixel for current mapview
      TileAnchor getScreenAnchorForTile​(org.openstreetmap.gui.jmapviewer.Tile tile)
      Get TileAnchor for a tile in screen pixel coordinates.
      org.openstreetmap.gui.jmapviewer.TileXY getTileforPixel​(int sx, int sy, int zoom)
      Convert screen pixel coordinate to tile position at certain zoom level.
      java.awt.Shape getTileShapeScreen​(org.openstreetmap.gui.jmapviewer.Tile tile)
      Returns a shape that approximates the outline of the tile in screen coordinates.
      private MapViewState.MapViewPoint pos​(org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate ll)  
      private MapViewState.MapViewPoint pos​(org.openstreetmap.gui.jmapviewer.interfaces.IProjected p)  
      boolean requiresReprojection()
      Return true if tiles need to be reprojected from server projection to display projection.
      org.openstreetmap.gui.jmapviewer.interfaces.IProjected shiftDisplayToServer​(EastNorth en)
      Apply reverse shift to EastNorth coordinate.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TileCoordinateConverter

        public TileCoordinateConverter​(MapView mapView,
                                       org.openstreetmap.gui.jmapviewer.interfaces.TileSource tileSource,
                                       TileSourceDisplaySettings settings)
        Create a new coordinate converter for the map view.
        Parameters:
        mapView - The map view.
        tileSource - The tile source to use when converting coordinates.
        settings - displacement settings.
        Throws:
        java.lang.NullPointerException - if one argument is null
    • Method Detail

      • shiftDisplayToServer

        public org.openstreetmap.gui.jmapviewer.interfaces.IProjected shiftDisplayToServer​(EastNorth en)
        Apply reverse shift to EastNorth coordinate.
        Parameters:
        en - EastNorth coordinate representing a pixel on screen
        Returns:
        IProjected coordinate as it would e.g. be sent to a WMS server
      • getProjecting

        public Projecting getProjecting()
        Gets the projecting instance to use to convert between latlon and eastnorth coordinates.
        Returns:
        The Projecting instance.
      • getPixelForTile

        public java.awt.geom.Point2D getPixelForTile​(int x,
                                                     int y,
                                                     int zoom)
        Gets the top left position of the tile inside the map view.
        Parameters:
        x - x tile index
        y - y tile index
        zoom - zoom level
        Returns:
        the position
      • getPixelForTile

        public java.awt.geom.Point2D getPixelForTile​(org.openstreetmap.gui.jmapviewer.Tile tile)
        Gets the top left position of the tile inside the map view.
        Parameters:
        tile - The tile
        Returns:
        The position.
      • getTileforPixel

        public org.openstreetmap.gui.jmapviewer.TileXY getTileforPixel​(int sx,
                                                                       int sy,
                                                                       int zoom)
        Convert screen pixel coordinate to tile position at certain zoom level.
        Parameters:
        sx - x coordinate (screen pixel)
        sy - y coordinate (screen pixel)
        zoom - zoom level
        Returns:
        the tile
      • getRectangleForTile

        public java.awt.geom.Rectangle2D getRectangleForTile​(org.openstreetmap.gui.jmapviewer.Tile tile)
        Gets the position of the tile inside the map view.
        Parameters:
        tile - The tile
        Returns:
        The position as a rectangle in screen coordinates
      • getTileShapeScreen

        public java.awt.Shape getTileShapeScreen​(org.openstreetmap.gui.jmapviewer.Tile tile)
        Returns a shape that approximates the outline of the tile in screen coordinates. If the tile is rectangular, this will be the exact border of the tile. The tile may be more oddly shaped due to reprojection, then it is an approximation of the tile outline.
        Parameters:
        tile - the tile
        Returns:
        tile outline in screen coordinates
      • getScaleFactor

        public double getScaleFactor​(int zoom)
        Returns average number of screen pixels per tile pixel for current mapview
        Parameters:
        zoom - zoom level
        Returns:
        average number of screen pixels per tile pixel
      • getScreenAnchorForTile

        public TileAnchor getScreenAnchorForTile​(org.openstreetmap.gui.jmapviewer.Tile tile)
        Get TileAnchor for a tile in screen pixel coordinates.
        Parameters:
        tile - the tile
        Returns:
        position of the tile in screen coordinates
      • requiresReprojection

        public boolean requiresReprojection()
        Return true if tiles need to be reprojected from server projection to display projection.
        Returns:
        true if tiles need to be reprojected from server projection to display projection