Class TileCoordinateConverter

java.lang.Object
org.openstreetmap.josm.gui.layer.imagery.TileCoordinateConverter

public class TileCoordinateConverter extends Object
This class handles tile coordinate management and computes their position in the map view.
Since:
10651
  • Field Details

  • Constructor Details

    • 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:
      NullPointerException - if one argument is null
  • Method Details

    • pos

      private MapViewState.MapViewPoint pos(org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate ll)
    • pos

      private MapViewState.MapViewPoint pos(org.openstreetmap.gui.jmapviewer.interfaces.IProjected p)
    • 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

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

      public 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 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 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 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