@Test @Category(UnitTest.class) public void tileBounds() { for (int z = 1; z < TMSUtils.MAXZOOMLEVEL; z++) { double res = TMSUtils.resolution(z, ts); Bounds zero = TMSUtils.tileBounds(0, 0, z, ts); Assert.assertEquals("Bad ll lat", -90.0, zero.s, 0.0001); Assert.assertEquals("Bad ll lon", -180.0, zero.w, 0.0001); Assert.assertEquals("Bad ur lat", -90.0 + (res * ts), zero.n, 0.0001); Assert.assertEquals("Bad ur lon", -180.0 + (res * ts), zero.e, 0.0001); Bounds max = TMSUtils.tileBounds((int) (2 * Math.pow(2, z - 1)) - 1, (int) (Math.pow(2, z - 1)) - 1, z, ts); Assert.assertEquals("Bad ll lat", 90.0 - (res * ts), max.s, 0.0001); Assert.assertEquals("Bad ll lon", 180.0 - (res * ts), max.w, 0.0001); Assert.assertEquals("Bad ur lat", 90.0, max.n, 0.0001); Assert.assertEquals("Bad ur lon", 180.0, max.e, 0.0001); if (z > 1) { Bounds middle = TMSUtils.tileBounds((int) (2 * Math.pow(2, z - 1)) / 2, (int) (Math.pow(2, z - 1)) / 2, z, ts); Assert.assertEquals("Bad ll lat", 0.0, middle.s, 0.0001); Assert.assertEquals("Bad ll lon", 0.0, middle.w, 0.0001); Assert.assertEquals("Bad ur lat", 0.0 + (res * ts), middle.n, 0.0001); Assert.assertEquals("Bad ur lon", 0.0 + (res * ts), middle.e, 0.0001); } } Bounds ll = TMSUtils.tileBounds(tiles.getMinX(), tiles.getMinY(), zoom, ts); Bounds ur = TMSUtils.tileBounds(tiles.getMaxX(), tiles.getMaxY(), zoom, ts); Assert.assertEquals("Bad ll lat", tb.s, ll.s, 0.0001); Assert.assertEquals("Bad ll lon", tb.w, ll.w, 0.0001); Assert.assertEquals("Bad ur lat", tb.n, ur.s, 0.0001); Assert.assertEquals("Bad ur lon", tb.e, ur.w, 0.0001); }
public static Bounds tileBounds(long tx, long ty, int zoom, int tilesize) { double res = resolution(zoom, tilesize); return new Bounds(tx * tilesize * res - 180.0, ty * tilesize * res - 90.0, (tx + 1) * tilesize * res - 180.0, (ty + 1) * tilesize * res - 90.0); }
TMSUtils { public static Bounds tileBounds(long tx, long ty, int zoom, int tilesize) { double res = resolution(zoom, tilesize); return new Bounds(tx * tilesize * res - 180.0, ty * tilesize * res - 90.0, (tx + 1) * tilesize * res - 180.0, (ty + 1) * tilesize * res - 90.0); } }
TMSUtils { public static Bounds tileBounds(long tx, long ty, int zoom, int tilesize) { double res = resolution(zoom, tilesize); return new Bounds(tx * tilesize * res - 180.0, ty * tilesize * res - 90.0, (tx + 1) * tilesize * res - 180.0, (ty + 1) * tilesize * res - 90.0); }  }
TMSUtils { public static Bounds tileBounds(long tx, long ty, int zoom, int tilesize) { double res = resolution(zoom, tilesize); return new Bounds(tx * tilesize * res - 180.0, ty * tilesize * res - 90.0, (tx + 1) * tilesize * res - 180.0, (ty + 1) * tilesize * res - 90.0); }  static Bounds limit(Bounds bounds); static TileBounds boundsToTile(Bounds bounds, int zoom,
    int tilesize); static TileBounds boundsToTileExact(Bounds bounds, int zoom,
    int tilesize); static Tile calculateTile(Tile tile, int srcZoom, int dstZoom,
    int tilesize); static boolean isValidTile(long tx, long ty, int zoomlevel); static Pixel latLonToPixels(double lat, double lon, int zoom,
    int tilesize); static Pixel latLonToPixelsUL(double lat, double lon, int zoom,
    int tilesize); static Tile latLonToTile(double lat, double lon, int zoom,
    int tilesize); static Pixel latLonToTilePixel(double lat, double lon, long tx,
    long ty, int zoom, int tilesize); static Pixel latLonToTilePixelUL(double lat, double lon, long tx,
    long ty, int zoom, int tilesize); static long numXTiles(int zoomlevel); static long numYTiles(int zoomlevel); static Tile pixelsToTile(double px, double py, int tilesize); static Tile pixelsULToTile(double px, double py, int zoom,
    int tilesize); static LatLon pixelToLatLon(long px, long py, int zoom,
    int tilesize); static LatLon pixelToLatLonUL(long px, long py, int zoom,
    int tilesize); static LatLon tilePixelToLatLon(long px, long py, Tile tile, int zoom,
    int tilesize); static LatLon tilePixelULToLatLon(long px, long py, Tile tile, int zoom,
    int tilesize); static double resolution(int zoom, int tilesize); static Bounds tileBounds(long tx, long ty, int zoom, int tilesize); static Bounds tileBounds(Tile tile, int zoom, int tilesize); static Bounds tileBounds(Bounds bounds, int zoom, int tilesize); static double[] tileBoundsArray(long tx, long ty, int zoom,
    int tilesize); static Tile tileid(long tileid, int zoomlevel); static long tileid(long tx, long ty, int zoomlevel); static long maxTileId(int zoomlevel); static double[] tileSWNEBoundsArray(long tx, long ty, int zoom,
    int tilesize); static Bounds tileToBounds(TileBounds bounds, int zoom,
    int tilesize); static int zoomForPixelSize(double pixelSize, int tilesize); }
TMSUtils { public static Bounds tileBounds(long tx, long ty, int zoom, int tilesize) { double res = resolution(zoom, tilesize); return new Bounds(tx * tilesize * res - 180.0, ty * tilesize * res - 90.0, (tx + 1) * tilesize * res - 180.0, (ty + 1) * tilesize * res - 90.0); }  static Bounds limit(Bounds bounds); static TileBounds boundsToTile(Bounds bounds, int zoom,
    int tilesize); static TileBounds boundsToTileExact(Bounds bounds, int zoom,
    int tilesize); static Tile calculateTile(Tile tile, int srcZoom, int dstZoom,
    int tilesize); static boolean isValidTile(long tx, long ty, int zoomlevel); static Pixel latLonToPixels(double lat, double lon, int zoom,
    int tilesize); static Pixel latLonToPixelsUL(double lat, double lon, int zoom,
    int tilesize); static Tile latLonToTile(double lat, double lon, int zoom,
    int tilesize); static Pixel latLonToTilePixel(double lat, double lon, long tx,
    long ty, int zoom, int tilesize); static Pixel latLonToTilePixelUL(double lat, double lon, long tx,
    long ty, int zoom, int tilesize); static long numXTiles(int zoomlevel); static long numYTiles(int zoomlevel); static Tile pixelsToTile(double px, double py, int tilesize); static Tile pixelsULToTile(double px, double py, int zoom,
    int tilesize); static LatLon pixelToLatLon(long px, long py, int zoom,
    int tilesize); static LatLon pixelToLatLonUL(long px, long py, int zoom,
    int tilesize); static LatLon tilePixelToLatLon(long px, long py, Tile tile, int zoom,
    int tilesize); static LatLon tilePixelULToLatLon(long px, long py, Tile tile, int zoom,
    int tilesize); static double resolution(int zoom, int tilesize); static Bounds tileBounds(long tx, long ty, int zoom, int tilesize); static Bounds tileBounds(Tile tile, int zoom, int tilesize); static Bounds tileBounds(Bounds bounds, int zoom, int tilesize); static double[] tileBoundsArray(long tx, long ty, int zoom,
    int tilesize); static Tile tileid(long tileid, int zoomlevel); static long tileid(long tx, long ty, int zoomlevel); static long maxTileId(int zoomlevel); static double[] tileSWNEBoundsArray(long tx, long ty, int zoom,
    int tilesize); static Bounds tileToBounds(TileBounds bounds, int zoom,
    int tilesize); static int zoomForPixelSize(double pixelSize, int tilesize); final static int MAXZOOMLEVEL; }