Class GpxData

    • Constructor Detail

      • GpxData

        public GpxData()
        Constructs a new GpxData.
      • GpxData

        public GpxData​(boolean initializing)
        Constructs a new GpxData that is currently being initialized, so no listeners will be fired until endUpdate() is called.
        Parameters:
        initializing - true
        Since:
        15496
    • Method Detail

      • mergeFrom

        public void mergeFrom​(GpxData other)
        Merges data from another object.
        Parameters:
        other - existing GPX data
      • mergeFrom

        public void mergeFrom​(GpxData other,
                              boolean cutOverlapping,
                              boolean connect)
        Merges data from another object.
        Parameters:
        other - existing GPX data
        cutOverlapping - whether overlapping parts of the given track should be removed
        connect - whether the tracks should be connected on cuts
        Since:
        14338
      • getTracks

        public Collection<IGpxTrackgetTracks()
        Get all tracks contained in this data set, without any guaranteed order.
        Returns:
        The tracks.
      • getOrderedTracks

        public List<IGpxTrackgetOrderedTracks()
        Get all tracks contained in this data set, ordered chronologically.
        Returns:
        The tracks in chronological order.
        Since:
        18207
      • clearTracks

        private void clearTracks()
        Clear all tracks, empties the current privateTracks container, helper method for some gpx manipulations.
      • addTrack

        public void addTrack​(IGpxTrack track)
        Add a new track
        Parameters:
        track - The new track
        Since:
        12156
      • removeTrack

        public void removeTrack​(IGpxTrack track)
        Remove a track
        Parameters:
        track - The old track
        Since:
        12156
      • combineTracksToSegmentedTrack

        public void combineTracksToSegmentedTrack()
        Combine tracks into a single, segmented track. The attributes of the first track are used, the rest discarded.
        Since:
        13210
      • ensureUniqueName

        public static String ensureUniqueName​(Map<String,​Object> attrs,
                                              Map<String,​Integer> counts,
                                              String srcLayerName)
        Ensures a unique name among gpx layers
        Parameters:
        attrs - attributes of/for an gpx track, written to if the name appeared previously in counts.
        counts - a HashMap of previously seen names, associated with their count.
        srcLayerName - Source layer name
        Returns:
        the unique name for the gpx track.
        Since:
        15397
      • splitTrackSegmentsToTracks

        public void splitTrackSegmentsToTracks​(String srcLayerName)
        Split tracks so that only single-segment tracks remain. Each segment will make up one individual track after this operation.
        Parameters:
        srcLayerName - Source layer name
        Since:
        15397
      • splitTracksToLayers

        public void splitTracksToLayers​(String srcLayerName)
        Split tracks into layers, the result is one layer for each track. If this layer currently has only one GpxTrack this is a no-operation. The new GpxLayers are added to the LayerManager, the original GpxLayer is untouched as to preserve potential route or wpt parts.
        Parameters:
        srcLayerName - Source layer name
        Since:
        15397
      • getTrackCount

        public int getTrackCount()
        Replies the current number of tracks in this GpxData
        Returns:
        track count
        Since:
        13210
      • getTrackSegsCount

        public int getTrackSegsCount()
        Replies the accumulated total of all track segments, the sum of segment counts for each track present.
        Returns:
        track segments count
        Since:
        13210
      • getRoutes

        public Collection<GpxRoutegetRoutes()
        Gets the list of all routes defined in this data set.
        Returns:
        The routes
        Since:
        12156
      • addRoute

        public void addRoute​(GpxRoute route)
        Add a new route
        Parameters:
        route - The new route
        Since:
        12156
      • removeRoute

        public void removeRoute​(GpxRoute route)
        Remove a route
        Parameters:
        route - The old route
        Since:
        12156
      • addWaypoint

        public void addWaypoint​(WayPoint waypoint)
        Add a new waypoint
        Parameters:
        waypoint - The new waypoint
        Since:
        12156
      • removeWaypoint

        public void removeWaypoint​(WayPoint waypoint)
        Remove a waypoint
        Parameters:
        waypoint - The old waypoint
        Since:
        12156
      • hasTrackPoints

        public boolean hasTrackPoints()
        Determines if this GPX data has one or more track points
        Returns:
        true if this GPX data has track points, false otherwise
      • hasRoutePoints

        public boolean hasRoutePoints()
        Determines if this GPX data has one or more route points
        Returns:
        true if this GPX data has route points, false otherwise
      • isEmpty

        public boolean isEmpty()
        Determines if this GPX data is empty (i.e. does not contain any point)
        Returns:
        true if this GPX data is empty, false otherwise
      • getMetaBounds

        public Bounds getMetaBounds()
        Returns the bounds defining the extend of this data, as read in metadata, if any. If no bounds is defined in metadata, null is returned. There is no guarantee that data entirely fit in this bounds, as it is not recalculated. To get recalculated bounds, see recalculateBounds(). To get downloaded areas, see dataSources.
        Returns:
        the bounds defining the extend of this data, or null.
        Since:
        7575
        See Also:
        recalculateBounds(), dataSources
      • recalculateBounds

        public Bounds recalculateBounds()
        Calculates the bounding box of available data and returns it. The bounds are not stored internally, but recalculated every time this function is called.
        To get bounds as read from metadata, see getMetaBounds().
        To get downloaded areas, see dataSources.
        FIXME might perhaps use visitor pattern?
        Returns:
        the bounds
        See Also:
        getMetaBounds(), dataSources
      • length

        public double length()
        calculates the sum of the lengths of all track segments
        Returns:
        the length in meters
      • getMinMaxTimeForAllTracks

        public Optional<IntervalgetMinMaxTimeForAllTracks()
        Returns minimum and maximum timestamps for all tracks Warning: there are lot of track with broken timestamps, so we just ignore points from future and from year before 1970 in this method
        Returns:
        minimum and maximum as interval
        Since:
        7319
      • nearestPointOnTrack

        public WayPoint nearestPointOnTrack​(EastNorth p,
                                            double tolerance)
        Makes a WayPoint at the projection of point p onto the track providing p is less than tolerance away from the track
        Parameters:
        p - : the point to determine the projection for
        tolerance - : must be no further than this from the track
        Returns:
        the closest point on the track to p, which may be the first or last point if off the end of a segment, or may be null if nothing close enough
      • getLinesIterable

        public Iterable<LinegetLinesIterable​(boolean... trackVisibility)
        Iterate over all track segments and over all routes.
        Parameters:
        trackVisibility - An array indicating which tracks should be included in the iteration. Can be null, then all tracks are included.
        Returns:
        an Iterable object, which iterates over all track segments and over all routes
      • resetEastNorthCache

        public void resetEastNorthCache()
        Resets the internal caches of east/north coordinates.
      • put

        public void put​(String key,
                        Object value)
        Description copied from class: WithAttributes
        Put a key / value pair as a new attribute. Overrides key / value pair with the same key (if present).
        Specified by:
        put in interface IWithAttributes
        Overrides:
        put in class WithAttributes
        Parameters:
        key - the key
        value - the value
      • invalidate

        public void invalidate()
        Fires event listeners and sets the modified flag to true.
      • fireInvalidate

        private void fireInvalidate​(boolean setModified)
      • beginUpdate

        public void beginUpdate()
        Begins updating this GpxData and prevents listeners from being fired.
        Since:
        15496
      • endUpdate

        public void endUpdate()
        Finishes updating this GpxData and fires listeners if required.
        Since:
        15496
      • isModified

        public boolean isModified()
        Determines whether anything has been modified.
        Returns:
        whether anything has been modified (e.g. colors)
        Since:
        15496
      • setModified

        public void setModified​(boolean value)
        Sets the modified flag to the value.
        Specified by:
        setModified in interface IGpxLayerPrefs
        Parameters:
        value - modified flag
        Since:
        15496
      • clear

        public void clear()
        Removes all gpx elements
        Since:
        17439