예제 #1
0
 @Test
 public void test_parse_formatter_output() {
   try {
     FileInputStream in = new FileInputStream(new File(TEST_GPX_INPUT));
     List<GpsTrack> tracks = new GpxParser().parse(in);
     assertEquals(tracks.size(), 1);
     GpsTrack track = tracks.get(0);
     assertEquals(1758, track.size());
   } catch (Exception e) {
     fail(e.toString());
   }
 }
예제 #2
0
  @Test
  public void test_thinned_track() {
    try {
      GpxParser parser = new GpxParser();
      FileInputStream gpxIn = new FileInputStream(new File(TEST_GPX_INPUT));
      List<GpsTrack> gpxTracks = parser.parse(gpxIn);
      GpsTrack gpxTrack = gpxTracks.get(0);

      GpsTrack thinned = gpxTrack.getThinnedTrack();
    } catch (Exception e) {
      fail(e.toString());
    }
  }
예제 #3
0
  private static List<GpsTrack> buildTestGpsTracks(int n) {
    GpsTrack track = new GpsTrack();
    for (float i = 0; i < n; i++) {
      float lat = i + 0.1f;
      float lon = i + 0.2f;
      float ele = i + 0.3f;
      Date time = new Date((long) i);
      GpsLocation loc = new GpsLocation(lat, lon, ele, time);
      track.add(loc);
    }

    List<GpsTrack> tracks = new ArrayList<GpsTrack>(1);
    tracks.add(track);
    return tracks;
  }
예제 #4
0
 /**
  * Creates a new Geotag entry for the given attachment and track. NOTE: I'm basically ignoring
  * errors here for now. Note that DataAccessExceptions do NOT actually propagate up the call stack
  * from here. They are caught and logged, but do NOT stop or undo the creation of the attachment.
  *
  * @param fileName
  * @param track
  * @throws DataAccessException
  */
 public void createGeotag(String fileName, GpsTrack track) throws DataAccessException {
   try {
     Attachment attachment = new AttachmentDao().findByFileName(fileName);
     Geotag tag = new Geotag(track.getCenter());
     tag.setAttachmentId(attachment.getAttachmentId());
     tag.setMapId(attachment.getAttachmentId());
     new GeotagDao().create(tag);
   } catch (Exception e) {
     log.error("Unable to create geotag for attachment.", e);
   }
 }
예제 #5
0
  @Test
  public void test_strava_compare() {
    try {
      GpxParser parser = new GpxParser();
      FileInputStream gpxIn = new FileInputStream(new File(TEST_GPX_INPUT));
      List<GpsTrack> gpxTracks = parser.parse(gpxIn);
      GpsTrack gpxTrack = gpxTracks.get(0);

      FileInputStream stravaIn = new FileInputStream(new File(TEST_STRAVA_INPUT));
      List<GpsTrack> stravaTracks = parser.parse(stravaIn);
      GpsTrack stravaTrack = stravaTracks.get(0);

      assertEquals(
          stravaTrack.size() + " != " + gpxTrack.size(), stravaTrack.size(), gpxTrack.size());

      for (int i = 0; i < stravaTrack.size(); i++) {
        GpsLocation g = gpxTrack.get(i);
        GpsLocation s = stravaTrack.get(i);
        assertTrue(g + " != " + s, g.equals(s));
      }
    } catch (Exception e) {
      fail(e.toString());
    }
  }