@Test @Category(UnitTest.class) public void latLonToTile() { for (int z = 1; z < TMSUtils.MAXZOOMLEVEL; z++) { Tile min = TMSUtils.latLonToTile(-90.0, -180.0, z, ts); Assert.assertEquals("Bad ll tile x", 0, (int) min.tx); Assert.assertEquals("Bad ll tile y", 0, (int) min.ty); Tile max = TMSUtils.latLonToTile(90.0, 180.0, z, ts); Assert.assertEquals("Bad ll tile x", (long) (2 * Math.pow(2, z - 1)), max.tx); Assert.assertEquals("Bad ll tile y", (long) (Math.pow(2, z - 1)), max.ty); Tile middle = TMSUtils.latLonToTile(0.0, 0.0, z, ts); Assert.assertEquals("Bad ll pixel x", (long) (Math.pow(2, z - 1) * 2.0) / 2, middle.tx); Assert.assertEquals("Bad ll pixel y", (long) (Math.pow(2, z - 1)) / 2, middle.ty); Tile third = TMSUtils.latLonToTile(-30.0, -60.0, z, ts); Assert.assertEquals("Bad ll pixel x", (long) (Math.pow(2, z - 1) * 2.0) / 3, third.tx); Assert.assertEquals("Bad ll pixel y", (long) (Math.pow(2, z - 1)) / 3, third.ty); } Tile ll = TMSUtils.latLonToTile(b.s, b.w, zoom, ts); Assert.assertEquals("Bad ll tile x", tiles.getMinX(), ll.tx); Assert.assertEquals("Bad ll tile y", tiles.getMinY(), ll.ty); Tile ur = TMSUtils.latLonToTile(b.n, b.e, zoom, ts); Assert.assertEquals("Bad ur tile x", tiles.getMaxX(), ur.tx); Assert.assertEquals("Bad ur tile y", tiles.getMaxY(), ur.ty); Tile check = TMSUtils.latLonToTile(0.0, 0.00001, 1, MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT_INT); Assert.assertEquals(1, check.tx); Assert.assertEquals(0, check.ty); check = TMSUtils.latLonToTile(0.00001, -180.0, 2, MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT_INT); Assert.assertEquals(0, check.tx); Assert.assertEquals(1, check.ty); }
public static Tile latLonToTile(double lat, double lon, int zoom, int tilesize) { return latLonToTile(lat, lon, zoom, tilesize, false); }
TMSUtils { public static Tile latLonToTile(double lat, double lon, int zoom, int tilesize) { return latLonToTile(lat, lon, zoom, tilesize, false); } }
TMSUtils { public static Tile latLonToTile(double lat, double lon, int zoom, int tilesize) { return latLonToTile(lat, lon, zoom, tilesize, false); }  }
TMSUtils { public static Tile latLonToTile(double lat, double lon, int zoom, int tilesize) { return latLonToTile(lat, lon, zoom, tilesize, false); }  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 latLonToTile(double lat, double lon, int zoom, int tilesize) { return latLonToTile(lat, lon, zoom, tilesize, false); }  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; }