code: public static int pixelXToTileX(double pixelX, byte zoomLevel, int tileSize) {
          return (int) Math.min(Math.max(pixelX / tileSize, 0), Math.pow(2, zoomLevel) - 1);
      }
docs: Converts a pixel X coordinate to the tile X number.
  
  @param pixelX    the pixel X coordinate that should be converted.
  @param zoomLevel the zoom level at which the coordinate should be converted.
  @return the tile X number.