Exemplo n.º 1
0
 /**
  * @param canvas
  * @param ctx
  */
 private void drawTFR(Canvas canvas, DrawingContext ctx) {
   TFRShape.draw(ctx, mService.getTFRShapes(), null == mPointProjection);
 }
Exemplo n.º 2
0
    /* (non-Javadoc)
     * @see android.os.AsyncTask#doInBackground(Params[])
     */
    @Override
    protected String doInBackground(Object... vals) {
      Thread.currentThread().setName("Closest");
      if (null == mService) {
        return null;
      }

      String airport = null;
      lon = (Double) vals[0];
      lat = (Double) vals[1];

      // if the user is moving instead of doing a long press, give them a chance
      // to cancel us before we start doing anything
      try {
        Thread.sleep(200);
      } catch (Exception e) {
      }

      if (isCancelled()) return "";

      /*
       * Get TFR tfr if touched on its top
       */
      LinkedList<TFRShape> shapes = null;
      List<AirSigMet> mets = null;
      if (null != mService) {
        shapes = mService.getTFRShapes();
        if (!mPref.useAdsbWeather()) {
          mets = mService.getInternetWeatherCache().getAirSigMet();
        }
      }
      if (null != shapes) {
        for (int shape = 0; shape < shapes.size(); shape++) {
          TFRShape cshape = shapes.get(shape);
          /*
           * Set TFR tfr
           */
          String txt = cshape.getTextIfTouched(lon, lat);
          if (null != txt) {
            tfr += txt + "\n--\n";
          }
        }
      }
      /*
       * Air/sigmets
       */
      if (null != mets) {
        for (int i = 0; i < mets.size(); i++) {
          MetShape cshape = mets.get(i).shape;
          if (null != cshape) {
            /*
             * Set MET tfr
             */
            String txt = cshape.getTextIfTouched(lon, lat);
            if (null != txt) {
              textMets += txt + "\n--\n";
            }
          }
        }
      }

      airport = mService.getDBResource().findClosestAirportID(lon, lat);
      if (isCancelled()) {
        return "";
      }

      if (null == airport) {
        airport = "" + Helper.truncGeo(lat) + "&" + Helper.truncGeo(lon);
      } else {
        freq = mService.getDBResource().findFrequencies(airport);
        if (isCancelled()) {
          return "";
        }

        taf = mService.getDBResource().getTAF(airport);
        if (isCancelled()) {
          return "";
        }

        metar = mService.getDBResource().getMETAR(airport);
        if (isCancelled()) {
          return "";
        }

        runways = mService.getDBResource().findRunways(airport);
        if (isCancelled()) {
          return "";
        }

        elev = mService.getDBResource().findElev(airport);
        if (isCancelled()) {
          return "";
        }

        LinkedList<String> fl = mService.getDBResource().findFuelCost(airport);
        if (fl.size() == 0) {
          // If fuel not available, show its not
          fuel = mContext.getString(R.string.NotAvailable);
        } else {
          fuel = "";
        }
        // Concat all fuel reports
        for (String s : fl) {
          fuel += s + "\n\n";
        }
        if (isCancelled()) return "";

        LinkedList<String> cm = mService.getDBResource().findRatings(airport);
        if (cm.size() == 0) {
          // If ratings not available, show its not
          ratings = mContext.getString(R.string.NotAvailable);
        } else {
          ratings = "";
        }
        // Concat all fuel reports
        for (String s : cm) {
          ratings += s + "\n\n";
        }
        if (isCancelled()) return "";
      }

      /*
       * ADSB gets this info from weather cache
       */
      if (!mPref.useAdsbWeather()) {
        aireps = mService.getDBResource().getAireps(lon, lat);
        if (isCancelled()) {
          return "";
        }

        wa = mService.getDBResource().getWindsAloft(lon, lat);
        if (isCancelled()) {
          return "";
        }

        sua = mService.getDBResource().getSua(lon, lat);
        if (isCancelled()) {
          return "";
        }

        if (mLayer != null) {
          layer = mLayer.getDate();
        }
        if (isCancelled()) {
          return "";
        }
      }

      mPointProjection =
          new Projection(mGpsParams.getLongitude(), mGpsParams.getLatitude(), lon, lat);
      return airport;
    }