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 String GetCOD(String nws_current, String radar_type) { String url = ""; try { String sig_html_tmp = UtilityDownload.GetStringFromURL( "http://climate.cod.edu/flanis/nexrad/?type=" + nws_current + "-" + radar_type + "-0-6"); Pattern p = Pattern.compile( "<img src=\"(http://climate.cod.edu/data/nexrad/.*?g[i0][ft][A]{0,1})\" "); // gif or // g0tA Matcher m = p.matcher(sig_html_tmp); while (m.find()) { url = m.group(1); } } catch (Exception e) { } return url; }
public static String GetHTMLandParse(String url, Pattern p) { String content = ""; try { Matcher m = p.matcher(UtilityDownload.GetStringFromURL(url)); m.find(); content = m.group(1); } catch (Exception e) { } return content; }
public static String GetHTMLandParseSep(String url, String match_str) { String content = ""; try { Pattern p = Pattern.compile(match_str); Matcher m = p.matcher(UtilityDownload.GetStringFromURLSep(url)); m.find(); content = m.group(1); } catch (Exception e) { } return content; }
public static String[] GetHTMLandParseMultipeFirstMatch( String url, String match_str, int number) { String[] result = new String[number]; try { Pattern p = Pattern.compile(match_str); Matcher m = p.matcher(UtilityDownload.GetStringFromURL(url)); m.find(); for (int i = 0; i < number; i++) { result[i] = m.group(i + 1); } } catch (Exception e) { } return result; }
@Override protected String doInBackground(String... params) { // conus is 3400x1600 39.725 97.00 if (!nws_radar_mosaic_sector_current.equals("alaska")) ld = UtilityUSImgNWSMosaic.NWSMosaic( getBaseContext(), nws_radar_mosaic_sector_current, spotters); else ld = UtilityImg.BitmapToLayerDrawable( getBaseContext(), UtilityDownload.getBitmapFromURL( "http://radar.weather.gov/ridge/Conus/RadarImg/alaska.gif")); return "Executed"; }
@Override protected String doInBackground(String... params) { if (!prod.startsWith("2")) { OGLR.ConstructPolygons(rid1, prod, "", url_str); if (MyApplication.sti_default && !archive_mode) OGLR.ConstructSTILines(); else OGLR.DeconstructSTILines(); if (MyApplication.hi_default && !archive_mode) OGLR.ConstructHI(); else OGLR.DeconstructHI(); if (MyApplication.tvs_default && !archive_mode) OGLR.ConstructTVS(); else OGLR.DeconstructTVS(); } else { if (img_url.equals("NVW")) img_url = UtilityUSImgCOD.GetCODNVW(rid1, "NVW"); bitmap = UtilityDownload.getBitmapFromURL(img_url); } return "Executed"; }
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; }
public static String GetNWSPRE(String url) { return Parse(UtilityDownload.GetStringFromURLSep(url), MyApplication.pre2_pattern); }