Example #1
0
  /**
   * @param zoom level of the tile
   * @return how many pixels of the screen occupies one pixel of the tile
   */
  private double getTileToScreenRatio(int zoom) {
    MapView mv = Main.map.mapView;
    LatLon topLeft = mv.getLatLon(0, 0);
    LatLon botLeft = mv.getLatLon(0, tileSource.getTileSize());

    TileXY topLeftTile = tileSource.latLonToTileXY(topLeft.toCoordinate(), zoom);

    ICoordinate north =
        tileSource.tileXYToLatLon(topLeftTile.getXIndex(), topLeftTile.getYIndex(), zoom);
    ICoordinate south =
        tileSource.tileXYToLatLon(topLeftTile.getXIndex(), topLeftTile.getYIndex() + 1, zoom);

    return Math.abs((north.getLat() - south.getLat()) / (topLeft.lat() - botLeft.lat()));
  }