示例#1
0
  private List<GpxRoute> extractTracks(
      GpxType gpxType, boolean hasSpeedInMeterPerSecondInsteadOfKilometerPerHour) {
    List<GpxRoute> result = new ArrayList<GpxRoute>();

    for (TrkType trkType : gpxType.getTrk()) {
      String name = trkType.getName();
      String desc = trkType.getDesc();
      List<String> descriptions = asDescription(desc);
      List<GpxPosition> positions =
          extractTrack(trkType, hasSpeedInMeterPerSecondInsteadOfKilometerPerHour);
      result.add(new GpxRoute(this, Track, name, descriptions, positions, gpxType, trkType));
    }

    return result;
  }
示例#2
0
 private List<GpxPosition> extractTrack(
     TrkType trkType, boolean hasSpeedInMeterPerSecondInsteadOfKilometerPerHour) {
   List<GpxPosition> positions = new ArrayList<GpxPosition>();
   if (trkType != null) {
     for (TrksegType trkSegType : trkType.getTrkseg()) {
       for (WptType wptType : trkSegType.getTrkpt()) {
         positions.add(
             new GpxPosition(
                 wptType.getLon(),
                 wptType.getLat(),
                 wptType.getEle(),
                 getSpeed(wptType, hasSpeedInMeterPerSecondInsteadOfKilometerPerHour),
                 getHeading(wptType),
                 parseTime(wptType.getTime()),
                 asComment(wptType.getName(), wptType.getDesc()),
                 wptType.getHdop(),
                 wptType.getPdop(),
                 wptType.getVdop(),
                 wptType.getSat(),
                 wptType));
       }
     }
   }
   return positions;
 }
示例#3
0
 private List<TrkType> createTrack(GpxRoute route, int startIndex, int endIndex) {
   ObjectFactory objectFactory = new ObjectFactory();
   List<TrkType> trkTypes = new ArrayList<TrkType>();
   TrkType trkType = route.getOrigin(TrkType.class);
   if (trkType != null) trkType.getTrkseg().clear();
   else trkType = objectFactory.createTrkType();
   if (isWriteName()) {
     trkType.setName(asRouteName(route.getName()));
     trkType.setDesc(asDescription(route.getDescription()));
   }
   trkTypes.add(trkType);
   TrksegType trksegType = objectFactory.createTrksegType();
   List<GpxPosition> positions = route.getPositions();
   for (int i = startIndex; i < endIndex; i++) {
     GpxPosition position = positions.get(i);
     WptType wptType = createWptType(position);
     if (wptType != null) trksegType.getTrkpt().add(wptType);
   }
   trkType.getTrkseg().add(trksegType);
   return trkTypes;
 }