@Test @Category(UnitTest.class) public void pixelsULToTile() { Tile zero = TMSUtils.pixelsULToTile(0, 0, 1, ts); Assert.assertEquals("Bad ll tile x", 0, zero.tx); Assert.assertEquals("Bad ll tile y", 0, zero.ty); for (int z = 1; z < TMSUtils.MAXZOOMLEVEL; z++) { double numYTiles = Math.pow(2, z - 1); double numXTiles = 2.0 * numYTiles; double maxXTile = numXTiles - 1.0; double numYPixels = numYTiles * ts; double numXPixels = (2.0 * numYPixels); double maxPixelX = numXPixels - 1.0; double maxPixelY = numYPixels - 1.0; Tile max = TMSUtils.pixelsULToTile(maxPixelX, maxPixelY, z, ts); Assert.assertEquals("Bad ll tile x at zoom " + z, (long) maxXTile, max.tx); Assert.assertEquals("Bad ll tile y at zoom " + z, 0, max.ty); Tile middle = TMSUtils.pixelsULToTile(numXPixels / 2, numYPixels / 2, z, ts); Assert.assertEquals("Bad ll pixel x at zoom " + z, (long) (numXTiles) / 2, middle.tx); Assert.assertEquals("Bad ll pixel y at zoom " + z, Math.max(0, (long) (numYTiles) / 2 - 1), middle.ty); Tile third = TMSUtils.pixelsULToTile(numXPixels / 3, numYPixels / 3, z, ts); Assert.assertEquals("Bad ll pixel x at zoom " + z, (long) (numXTiles) / 3, third.tx); Assert.assertEquals("Bad ll pixel y at zoom " + z, Math.max(0, (long) (2.0 * numYTiles / 3.0)), third.ty); } Tile ll = TMSUtils.pixelsToTile(px.getMinX(), px.getMinY(), ts); Tile ur = TMSUtils.pixelsToTile(px.getMaxX(), px.getMaxY(), ts); Assert.assertEquals("Bad ll tile x at zoom ", tiles.getMinX(), ll.tx); Assert.assertEquals("Bad ll tile y at zoom ", tiles.getMinY(), ll.ty); Assert.assertEquals("Bad ur tile x at zoom ", tiles.getMaxX(), ur.tx); Assert.assertEquals("Bad ur tile y at zoom ", tiles.getMaxY(), ur.ty); }
public static Tile pixelsULToTile(double px, double py, int zoom, int tilesize) { Tile tileFromBottom = pixelsToTile(px, py, tilesize); return new Tile(tileFromBottom.tx, numYTiles(zoom) - tileFromBottom.ty - 1); }
TMSUtils { public static Tile pixelsULToTile(double px, double py, int zoom, int tilesize) { Tile tileFromBottom = pixelsToTile(px, py, tilesize); return new Tile(tileFromBottom.tx, numYTiles(zoom) - tileFromBottom.ty - 1); } }
TMSUtils { public static Tile pixelsULToTile(double px, double py, int zoom, int tilesize) { Tile tileFromBottom = pixelsToTile(px, py, tilesize); return new Tile(tileFromBottom.tx, numYTiles(zoom) - tileFromBottom.ty - 1); }  }
TMSUtils { public static Tile pixelsULToTile(double px, double py, int zoom, int tilesize) { Tile tileFromBottom = pixelsToTile(px, py, tilesize); return new Tile(tileFromBottom.tx, numYTiles(zoom) - tileFromBottom.ty - 1); }  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 Tile pixelsULToTile(double px, double py, int zoom, int tilesize) { Tile tileFromBottom = pixelsToTile(px, py, tilesize); return new Tile(tileFromBottom.tx, numYTiles(zoom) - tileFromBottom.ty - 1); }  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; }