Exemplo n.º 1
0
  private List<GpxPosition> extractRouteWithGarminExtensions(
      RteType rteType, boolean hasSpeedInMeterPerSecondInsteadOfKilometerPerHour) {
    List<GpxPosition> positions = new ArrayList<GpxPosition>();
    if (rteType != null) {
      for (WptType wptType : rteType.getRtept()) {
        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));

        ExtensionsType extensions = wptType.getExtensions();
        if (extensions != null) {
          for (Object any : extensions.getAny()) {
            if (any instanceof JAXBElement) {
              Object anyValue = ((JAXBElement) any).getValue();
              if (anyValue instanceof RoutePointExtensionT) {
                RoutePointExtensionT routePoint = (RoutePointExtensionT) anyValue;
                for (AutoroutePointT autoroutePoint : routePoint.getRpt()) {
                  positions.add(
                      new GpxPosition(
                          autoroutePoint.getLon(),
                          autoroutePoint.getLat(),
                          null,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null,
                          null));
                }
              }
            }
          }
        }
      }
    }
    return positions;
  }
Exemplo n.º 2
0
 private Double getHeading(WptType wptType) {
   Double result = null;
   ExtensionsType extensions = wptType.getExtensions();
   if (extensions != null) {
     for (Object any : extensions.getAny()) {
       if (any instanceof Element) {
         Element element = (Element) any;
         if ("course".equals(element.getLocalName()))
           result = parseDouble(element.getTextContent());
       }
     }
   }
   if (result == null) result = parseHeading(wptType.getCmt());
   return result;
 }
Exemplo n.º 3
0
 private Double getSpeed(
     WptType wptType, boolean hasSpeedInMeterPerSecondInsteadOfKilometerPerHour) {
   Double result = null;
   ExtensionsType extensions = wptType.getExtensions();
   if (extensions != null) {
     for (Object any : extensions.getAny()) {
       if (any instanceof Element) {
         Element element = (Element) any;
         if ("speed".equals(element.getLocalName())) {
           result = parseDouble(element.getTextContent());
           // the exceptional case is converted from m/s to Km/h
           if (hasSpeedInMeterPerSecondInsteadOfKilometerPerHour) result = asKmh(result);
         }
       }
     }
   }
   if (result == null) result = parseSpeed(wptType.getCmt());
   if (result == null) result = parseSpeed(wptType.getName());
   if (result == null) result = parseSpeed(wptType.getDesc());
   return result;
 }