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