예제 #1
0
  /**
   * Write a flight to an in memory stream of IGC data
   *
   * @param flightid
   * @return
   * @throws IOException
   */
  private String flightToIGC(long flightid) throws IOException {
    // File cacheDir = getCacheDir();

    // FileOutputStream s = this.openFileOutput(basename,
    // MODE_WORLD_READABLE);
    ByteArrayOutputStream s = new ByteArrayOutputStream(4096);

    // This will close the file descriptor once done writing
    PositionWriter writer;

    GagglePrefs prefs = new GagglePrefs(this);

    writer =
        new IGCWriter(
            s,
            prefs.getPilotName(),
            null, // FIXME - not quite
            // right, we should
            // get this from DB
            prefs.getWingModel(),
            prefs.getPilotId());

    LocationUtils.dbToWriter(db, writer, flightid);

    byte[] contents = s.toByteArray();

    // Super skanky to pass this (big?) stuff as a string, but I'm tired of
    // fighting http post
    return new String(contents);
  }
예제 #2
0
  /**
   * Show the flight on the map
   *
   * @param flightid
   */
  private void viewFlightId(long flightid) {

    // Get all the points in that flight
    LocationList locs = new LocationList();
    PositionWriter locsWriter = new LocationListWriter(locs);
    LocationUtils.dbToWriter(db, locsWriter, flightid);

    Intent i = FlyMapActivity.createIntentLogView(this, locs);
    startActivity(i);
  }
예제 #3
0
  /**
   * Write a flight to a file
   *
   * @param flightid
   * @param filetype igc or kml
   * @return
   * @throws IOException
   */
  private File flightToFile(long flightid, String filetype) throws IOException {
    // File cacheDir = getCacheDir();

    File sdcard = Environment.getExternalStorageDirectory();
    if (!sdcard.exists()) throw new IOException(getString(R.string.sd_card_not_found));

    File tracklog = new File(sdcard, getString(R.string.tracklogs));
    if (!tracklog.exists()) tracklog.mkdir();

    String basename = getString(R.string.flight_) + flightid + "." + filetype; // FIXME, use a
    // better
    // filename
    // File fname = new File(cacheDir, basename);
    // FIXME - use getCacheDir - or even better a sdcard directory for
    // flights

    File fullname = new File(tracklog, basename);

    // FileOutputStream s = this.openFileOutput(basename,
    // MODE_WORLD_READABLE);
    FileOutputStream s = new FileOutputStream(fullname);

    // This will close the file descriptor once done writing
    PositionWriter writer;

    GagglePrefs prefs = new GagglePrefs(this);

    if (filetype.equals("igc"))
      writer =
          new IGCWriter(s, prefs.getPilotName(), null, prefs.getWingModel(), prefs.getPilotId());
    else
      writer =
          new KMLWriter(s, prefs.getPilotName(), null, prefs.getWingModel(), prefs.getPilotId());

    LocationUtils.dbToWriter(db, writer, flightid);

    return fullname;
  }