/** * Converts a longitude coordinate (in degrees) to the tile X number at a certain scale factor. * * @param longitude the longitude coordinate that should be converted. * @param scaleFactor the scale factor at which the coordinate should be converted. * @return the tile X number of the longitude value. */ public static int longitudeToTileXWithScaleFactor(double longitude, double scaleFactor) { return pixelXToTileXWithScaleFactor(longitudeToPixelXWithScaleFactor(longitude, scaleFactor, DUMMY_TILE_SIZE), scaleFactor, DUMMY_TILE_SIZE); }
@Test public void pixelXToTileXTest() { for (int tileSize : TILE_SIZES) { for (byte zoomLevel = ZOOM_LEVEL_MIN; zoomLevel <= ZOOM_LEVEL_MAX; ++zoomLevel) { Assert.assertEquals(0, MercatorProjection.pixelXToTileX(0, zoomLevel, tileSize)); Assert.assertEquals(0, MercatorProjection.pixelXToTileXWithScaleFactor(0, MercatorProjection.zoomLevelToScaleFactor(zoomLevel), tileSize)); } } }
/** * Converts a longitude coordinate (in degrees) to the tile X number at a certain scale factor. * * @param longitude the longitude coordinate that should be converted. * @param scaleFactor the scale factor at which the coordinate should be converted. * @return the tile X number of the longitude value. */ public static int longitudeToTileXWithScaleFactor(double longitude, double scaleFactor) { return pixelXToTileXWithScaleFactor(longitudeToPixelXWithScaleFactor(longitude, scaleFactor, DUMMY_TILE_SIZE), scaleFactor, DUMMY_TILE_SIZE); }