/** * Draw metar map from ADSB * * @param ctx * @param map * @param shouldDraw */ public static void drawMetars( DrawingContext ctx, HashMap<String, Metar> map, boolean shouldDraw) { if (0 == ctx.pref.showLayer() || (!shouldDraw) || (!ctx.pref.useAdsbWeather())) { // This shows only for metar layer, and when adsb is used return; } Set<String> keys = map.keySet(); for (String key : keys) { Metar m = map.get(key); if (!isOnScreen(ctx.origin, m.lat, m.lon)) { continue; } float x = (float) ctx.origin.getOffsetX(m.lon); float y = (float) ctx.origin.getOffsetY(m.lat); ctx.paint.setColor(WeatherHelper.metarColor(m.flightCategory)); ctx.paint.setAlpha(ctx.pref.showLayer()); ctx.canvas.drawCircle(x, y, ctx.dip2pix * 8, ctx.paint); ctx.paint.setAlpha(255); } }
/* (non-Javadoc) * @see android.os.AsyncTask#onPostExecute(java.lang.Object) */ @Override protected void onPostExecute(String airport) { if (null != mGestureCallBack && null != mPointProjection && null != airport) { mLongTouchDestination = new LongTouchDestination(); mLongTouchDestination.airport = airport; mLongTouchDestination.info = Math.round(mPointProjection.getDistance()) + Preferences.distanceConversionUnit + "(" + mPointProjection.getGeneralDirectionFrom(mGpsParams.getDeclinition()) + ") " + Helper.correctConvertHeading( Math.round( Helper.getMagneticHeading( mPointProjection.getBearing(), mGpsParams.getDeclinition()))) + '\u00B0'; /* * Clear old weather */ mService.getAdsbWeather().sweep(); /* * Do not background ADSB weather as its a RAM opertation and quick, * also avoids concurrent mod exception. */ if (mPref.useAdsbWeather()) { taf = mService.getAdsbWeather().getTaf(airport); metar = mService.getAdsbWeather().getMETAR(airport); aireps = mService.getAdsbWeather().getAireps(lon, lat); wa = mService.getAdsbWeather().getWindsAloft(lon, lat); layer = mService.getAdsbWeather().getNexrad().getDate(); } else { boolean inWeatherOld = mService.getInternetWeatherCache().isOld(mPref.getExpiryTime()); if (inWeatherOld) { // expired weather and TFR text do not show taf = null; metar = null; aireps = null; textMets = null; tfr = null; wa = null; } } if (null != aireps) { for (Airep a : aireps) { a.updateTextWithLocation(lon, lat, mGpsParams.getDeclinition()); } } if (null != wa) { wa.updateStationWithLocation(lon, lat, mGpsParams.getDeclinition()); } mLongTouchDestination.tfr = tfr; mLongTouchDestination.taf = taf; mLongTouchDestination.metar = metar; mLongTouchDestination.airep = aireps; mLongTouchDestination.mets = textMets; mLongTouchDestination.wa = wa; mLongTouchDestination.freq = freq; mLongTouchDestination.sua = sua; mLongTouchDestination.layer = layer; mLongTouchDestination.fuel = fuel; mLongTouchDestination.ratings = ratings; if (metar != null) { mLongTouchDestination.performance = WeatherHelper.getMetarTime(metar.rawText) + "\n" + mContext.getString(R.string.DensityAltitude) + " " + WeatherHelper.getDensityAltitude(metar.rawText, elev) + "\n" + mContext.getString(R.string.BestRunway) + " " + WeatherHelper.getBestRunway(metar.rawText, runways); } // If the long press event has already occurred, we need to do the gesture callback here if (mDoCallbackWhenDone) { mGestureCallBack.gestureCallBack(GestureInterface.LONG_PRESS, mLongTouchDestination); } } invalidate(); }