Class GPXTrackWriter

java.lang.Object
com.here.NativeBase
com.here.sdk.navigation.GPXTrackWriter
All Implemented Interfaces:
LocationListener

public final class GPXTrackWriter extends NativeBase implements LocationListener

Writes GPX track points to GPXTrack. The instance of the class should be added as a listener to the LocationEngine for GPX track recording. Appends the new location to the back segment of the track whenever the listener is called. The following data (if provided) can be recorded and inserted into the resulting GPXTrack: latitude, longitude, altitude, time, bearingInDegrees, pitchInDegrees, speedInMetersPerSecond, horizontalAccuracyInMeters, verticalAccuracyInMeters, bearingAccuracyInDegrees, speedAccuracyInMetersPerSecond and locationTechnology.

Use case examples:

A user wants to create and save a new GPXDocument with one GPXTrack: - create GPXTrackWriter and add it as a location listener to LocationEngine. - set user parameters to getTrack() (e.g. GPXTrack.getName() or GPXTrack.getDescription()). - when writing is completed, create a new GPXDocument with a list of one GPXTrack and save the document via GPXDocument.save(java.lang.String).

A user wants to modify and save GPXTrack in the existing GPXDocument: - load GPXDocument from a file by the relevant constructor. - create GPXTrackWriter with the required track in the list GPXDocument.getTracks(), add the created instance as a location listener to LocationEngine. - when writing is completed, save the document via GPXDocument.save(java.lang.String).

The GPXDocument including all tracks is saved in the GPX file format. Hence, once saved, it can be easily shared with other applications that understand the GPX file format.

  • Constructor Details

    • GPXTrackWriter

      public GPXTrackWriter()

      Creates a new instance of GPXTrackWriter with an empty track inside.

    • GPXTrackWriter

      public GPXTrackWriter(@NonNull GPXTrack track)

      Creates a new instance of GPXTrackWriter with GPXTrack. Use this constructor to append locations to an existing track.

      Parameters:
      track -

      GPX track.

  • Method Details

    • getTrack

      @NonNull public GPXTrack getTrack()

      Gets the GPX track into which GPX track points are written.

      Returns:

      GPX track into which GPX track points are written.

    • onLocationUpdated

      public void onLocationUpdated(@NonNull Location location)

      Called each time a new location is available. In a navigation context while using the Navigator or VisualNavigator, it's required to set the Location.time parameter for each Location object so that the HERE SDK can map-match the locations properly. If the Location.time parameter is missing, the location will be ignored. For navigation, it is also recommended to provide the bearing and speed parameters for each Location object. Invoked on the main thread.

      Specified by:
      onLocationUpdated in interface LocationListener
      Parameters:
      location -

      Current location.