code: public static int pixelYToTileYWithScaleFactor(double pixelY, double scaleFactor, int tileSize) {
          return (int) Math.min(Math.max(pixelY / tileSize, 0), scaleFactor - 1);
      }
docs: Converts a pixel Y coordinate to the tile Y number.
  
  @param pixelY      the pixel Y coordinate that should be converted.
  @param scaleFactor the scale factor at which the coordinate should be converted.
  @return the tile Y number.