code: public static int hashLengthToCoverBoundingBox(double topLeftLat, double topLeftLon,
              double bottomRightLat, double bottomRightLon) {
          boolean isEven = true;
          double minLat = -90.0, maxLat = 90;
          double minLon = -180.0, maxLon = 180.0;
  
          for (int bits = 0; bits < MAX_HASH_LENGTH * 5; bits++) {
              if (isEven) {
                  double mid = (minLon + maxLon) / 2;
                  if (topLeftLon >= mid) {
                      if (bottomRightLon < mid)
                          return bits / 5;
                      minLon = mid;
                  } else {
                      if (bottomRightLon >= mid)
                          return bits / 5;
                      maxLon = mid;
                  }
              } else {
                  double mid = (minLat + maxLat) / 2;
                  if (topLeftLat >= mid) {
                      if (bottomRightLat < mid)
                          return bits / 5;
                      minLat = mid;
                  } else {
                      if (bottomRightLat >= mid)
                          return bits / 5;
                      maxLat = mid;
                  }
              }
  
              isEven = !isEven;
          }
          return MAX_HASH_LENGTH;
      }
docs: Returns the maximum length of hash that covers the bounding box. If no
  hash can enclose the bounding box then 0 is returned.
  
  @param topLeftLat
  latitude of top left point (north west)
  @param topLeftLon
  longitude of top left point (north west)
  @param bottomRightLat
  latitude of bottom right point (south east)
  @param bottomRightLon
  longitude of bottom right point (south east)
  @return length of the hash