public static LayerDrawable GetLayeredImg(
      Context c, String rid1, String product, String url, boolean spotters) {

    Bitmap bitmap;
    String cod_url;
    final String scale_type = "cod";

    if (url.equals("")) {
      cod_url = GetCOD(rid1, product);
      bitmap = UtilityDownload.getBitmapFromURL(cod_url);
    } else {
      bitmap = UtilityDownload.getBitmapFromURL(url);
    }

    if (!MyApplication.black_bg) {
      bitmap = UtilityImg.BM_BlackToWhite(bitmap);
    }

    if ((!product.equals("OHA")) && (!product.equals("NVW"))) {
      android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
      if (bitmapConfig == null) {
        bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
      }
      bitmap = bitmap.copy(bitmapConfig, true);
      UtilityCanvasMain.AddCanvasItems(bitmap, scale_type, rid1, 0, spotters, false, 22);
    }

    return UtilityImg.BitmapToLayerDrawable(c, bitmap);
  }
  public static Bitmap GetCODMosaic(
      Context context,
      String img_url,
      String image_type,
      String k,
      List<String> meso_img,
      List<String> overlay_img) {

    Bitmap bitmap = null;
    Bitmap bitmap1 = null;
    Bitmap bitmap2 = null;
    String map_url;
    String overlay_url;
    String location = "";
    Bitmap[] bitmap_arr = new Bitmap[meso_img.size() + overlay_img.size()];

    if (meso_img.size() == 0 && overlay_img.size() == 0) {
      bitmap = UtilityDownload.getBitmapFromURL(img_url);
      if (!MyApplication.black_bg && image_type.equals("rad")) {
        bitmap = UtilityImg.BM_BlackToWhite(bitmap);
      }
    } else {
      try {
        Pattern p2 = Pattern.compile("/current/(.*?)\\.");
        Matcher m2 = p2.matcher(img_url);
        while (m2.find()) {
          location = m2.group(1);
        }
      } catch (Exception e) {
      }

      map_url = img_url.replaceAll("/current/.*?gif", "/maps/");
      overlay_url = img_url.replaceAll("/current/.*?gif", "/overlays/");

      bitmap1 = UtilityDownload.getBitmapFromURL(img_url.replaceAll(".gif", ".nomap.gif"));
      if (!MyApplication.black_bg && image_type.equals("rad")) {
        bitmap1 = UtilityImg.BM_BlackToWhite(bitmap1);
      }
      bitmap2 = UtilityDownload.getBitmapFromURL(map_url + location + "_map.gif");
      try {
        int i = 0;
        for (String s : overlay_img) {

          bitmap_arr[i] = UtilityDownload.getBitmapFromURL(map_url + location + "_" + s + ".gif");
          bitmap_arr[i] = UtilityImg.eraseBG(bitmap_arr[i], -16777216); // use for black background
          i++;
        }

        for (String s : meso_img) {
          if (s.equals("rad")) {
            bitmap_arr[i] =
                UtilityDownload.getBitmapFromURL(
                    "http://climate.cod.edu/data/satellite/"
                        + k
                        + "/"
                        + location
                        + "/current/"
                        + location
                        + ".rad.nomap.gif");
          } else {
            bitmap_arr[i] =
                UtilityDownload.getBitmapFromURL(overlay_url + location + "-" + s + ".gif");
          }
          bitmap_arr[i] = UtilityImg.eraseBG(bitmap_arr[i], -16777216); // use for black background
          i++;
        }

      } catch (Exception e) {
      }

      bitmap2 = UtilityImg.eraseBG(bitmap2, -16777216); // use for black background
    }

    if (meso_img.size() == 0 && overlay_img.size() == 0) {
    } else {

      Drawable[] layers = new Drawable[2 + meso_img.size() + overlay_img.size()];
      layers[0] = new BitmapDrawable(context.getResources(), bitmap1); // radar
      Integer i = 0;
      for (@SuppressWarnings("unused") String s : overlay_img) {
        layers[1 + i] = new BitmapDrawable(context.getResources(), bitmap_arr[i]); // warnings
        i++;
      }
      for (@SuppressWarnings("unused") String s : meso_img) {
        layers[1 + i] = new BitmapDrawable(context.getResources(), bitmap_arr[i]); // warnings
        i++;
      }
      layers[2 + meso_img.size() - 1 + overlay_img.size()] =
          new BitmapDrawable(context.getResources(), bitmap2); // state
      LayerDrawable layerDrawable = new LayerDrawable(layers);
      bitmap = UtilityImg.LayerDrawableToBitmap(layerDrawable);
    }

    return bitmap;
  }