Ejemplo n.º 1
0
  @Override
  public void endDocument() throws SAXException {
    System.out.println("Number of tracks: " + gpxDocument.getTracks().size()); // $NON-NLS-1$

    //		double totalDistance = 0d;
    //
    //		GeoPosition previousPoint = null;
    //		for (GeoPosition point : points) {
    //			if (previousPoint != null) {
    //				totalDistance += GeoUtils.distance(previousPoint, point);
    //			}
    //			previousPoint = point;
    //		}
    //
    //		System.out.println("Total distance: " + totalDistance + " km");
  }
Ejemplo n.º 2
0
  @Override
  public void startElement(
      final String namespaceURI, final String localName, final String qName, final Attributes attrs)
      throws SAXException {

    final String eName = ("".equals(localName)) ? qName : localName; // $NON-NLS-1$

    if ("trk".equals(eName)) { // $NON-NLS-1$
      final Track track = new Track();
      gpxDocument.addTrack(track);
      currentTrack = track;
    }

    if ("trkseg".equals(eName)) { // $NON-NLS-1$
      final TrackSegment segment = new TrackSegment();
      currentTrack.addSegment(segment);
      currentTrackSegment = segment;
    }

    if ("trkpt".equals(eName)) { // $NON-NLS-1$
      final String sLat = attrs.getValue("lat"); // $NON-NLS-1$
      final String sLon = attrs.getValue("lon"); // $NON-NLS-1$

      final double lat = Double.parseDouble(sLat);
      final double lon = Double.parseDouble(sLon);

      final GeoPosition position = new GeoPosition(lat, lon);
      final Waypoint waypoint = new Waypoint(position);
      currentTrackSegment.addTrackPoint(waypoint);
      currentWaypoint = waypoint;
    }

    if ("ele".equals(eName)) { // $NON-NLS-1$
      //			String sEle =
      //			double ele = Double.parseDouble(sEle);
      //
      //			currentWaypoint.setElevation(elevation)
    }
  }