public class GpxData extends WithAttributes implements Data
Modifier and Type | Class and Description |
---|---|
static class |
GpxData.GpxDataChangeEvent
A data change event in any of the gpx data.
|
static interface |
GpxData.GpxDataChangeListener
A listener that listens to GPX data changes.
|
(package private) static class |
GpxData.GpxTrackSegmentSpan |
static class |
GpxData.LinesIterator
Iterates over all track segments and then over all routes.
|
(package private) static class |
GpxData.TimestampConfictException |
Modifier and Type | Field and Description |
---|---|
java.lang.String |
creator
Creator metadata for this file (usually software)
|
java.util.Set<DataSource> |
dataSources
All data sources (bounds of downloaded bounds) of this GpxData.
Not part of GPX standard but rather a JOSM extension, needed by the fact that OSM API does not provide <bounds> element in its GPX reply. |
boolean |
fromServer
A boolean flag indicating if the data was read from the OSM server.
|
private ListenerList<GpxData.GpxDataChangeListener> |
listeners |
private java.util.ArrayList<GpxRoute> |
privateRoutes
GPX routes in this file
|
private java.util.ArrayList<GpxTrack> |
privateTracks
A list of tracks this file consists of
|
private java.util.ArrayList<WayPoint> |
privateWaypoints
Addidionaly waypoints for this file.
|
private GpxTrack.GpxTrackChangeListener |
proxy |
java.util.Collection<GpxRoute> |
routes
Routes.
|
private java.util.List<GpxData.GpxTrackSegmentSpan> |
segSpans |
java.io.File |
storageFile
The disk file this layer is stored in, if it is a local layer.
|
java.util.Collection<GpxTrack> |
tracks
Tracks.
|
java.util.Collection<WayPoint> |
waypoints
Waypoints.
|
attr
FIX_VALUES, GPX_CMT, GPX_DESC, GPX_NAME, GPX_SRC, JOSM_EXTENSIONS_NAMESPACE_URI, META_AUTHOR_EMAIL, META_AUTHOR_LINK, META_AUTHOR_NAME, META_BOUNDS, META_COPYRIGHT_AUTHOR, META_COPYRIGHT_LICENSE, META_COPYRIGHT_YEAR, META_DESC, META_EXTENSIONS, META_KEYWORDS, META_LINKS, META_NAME, META_PREFIX, META_TIME, PT_AGEOFDGPSDATA, PT_DGPSID, PT_ELE, PT_FIX, PT_GEOIDHEIGHT, PT_HDOP, PT_MAGVAR, PT_PDOP, PT_SAT, PT_SYM, PT_TIME, PT_TYPE, PT_VDOP, RTE_TRK_KEYS, WPT_KEYS
Constructor and Description |
---|
GpxData() |
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(GpxData.GpxDataChangeListener listener)
Adds a listener that gets called whenever the data changed.
|
void |
addRoute(GpxRoute route)
Add a new route
|
void |
addTrack(GpxTrack track)
Add a new track
|
void |
addWaypoint(WayPoint waypoint)
Add a new waypoint
|
void |
addWeakChangeListener(GpxData.GpxDataChangeListener listener)
Adds a listener that gets called whenever the data changed.
|
private boolean |
anySegmentOverlapsWith(GpxData.GpxTrackSegmentSpan other) |
private void |
clearTracks()
Clear all tracks, empties the current privateTracks container,
helper method for some gpx manipulations.
|
void |
combineTracksToSegmentedTrack()
Combine tracks into a single, segmented track.
|
private void |
connectTracks(WayPoint prevWp,
GpxData.GpxTrackSegmentSpan span,
java.util.Map<java.lang.String,java.lang.Object> attr) |
private void |
cutOverlapping(GpxTrack trk,
boolean connect) |
static java.lang.String |
ensureUniqueName(java.util.Map<java.lang.String,java.lang.Object> attrs,
java.util.Map<java.lang.String,java.lang.Integer> counts) |
boolean |
equals(java.lang.Object obj) |
private void |
fireInvalidate() |
java.util.Collection<DataSource> |
getDataSources()
Returns the collection of data sources.
|
java.lang.Iterable<Line> |
getLinesIterable(boolean... trackVisibility)
Iterate over all track segments and over all routes.
|
Bounds |
getMetaBounds()
Returns the bounds defining the extend of this data, as read in metadata, if any.
|
java.util.Date[] |
getMinMaxTimeForAllTracks()
Returns minimum and maximum timestamps for all tracks
Warning: there are lot of track with broken timestamps,
so we just ingore points from future and from year before 1970 in this method
works correctly @since 5815
|
static java.util.Date[] |
getMinMaxTimeForTrack(GpxTrack trk)
returns minimum and maximum timestamps in the track
|
java.util.Collection<GpxRoute> |
getRoutes()
Gets the list of all routes defined in this data set.
|
java.util.List<GpxData.GpxTrackSegmentSpan> |
getSegmentSpans()
Get a list of SegmentSpans containing the beginning and end of each segment
|
int |
getTrackCount()
Replies the current number of tracks in this GpxData
|
java.util.stream.Stream<WayPoint> |
getTrackPoints()
Gets a stream of all track points in the segments of the tracks of this data.
|
java.util.Collection<GpxTrack> |
getTracks()
Get all tracks contained in this data set.
|
private java.util.stream.Stream<GpxTrackSegment> |
getTrackSegmentsStream()
Get stream of track segments.
|
int |
getTrackSegsCount()
Replies the accumulated total of all track segments,
the sum of segment counts for each track present.
|
java.util.Collection<WayPoint> |
getWaypoints()
Gets a list of all way points in this data set.
|
int |
hashCode() |
boolean |
hasRoutePoints()
Determines if this GPX data has one or more route points
|
boolean |
hasTrackPoints()
Determines if this GPX data has one or more track points
|
boolean |
isEmpty()
Determines if this GPX data is empty (i.e.
|
double |
length()
calculates the sum of the lengths of all track segments
|
void |
mergeFrom(GpxData other)
Merges data from another object.
|
void |
mergeFrom(GpxData other,
boolean cutOverlapping,
boolean connect)
Merges data from another object.
|
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
|
Bounds |
recalculateBounds()
Calculates the bounding box of available data and returns it.
|
void |
removeChangeListener(GpxData.GpxDataChangeListener listener)
Removes a listener that gets called whenever the data changed.
|
void |
removeRoute(GpxRoute route)
Remove a route
|
void |
removeTrack(GpxTrack track)
Remove a track
|
void |
removeWaypoint(WayPoint waypoint)
Remove a waypoint
|
void |
resetEastNorthCache()
Resets the internal caches of east/north coordinates.
|
void |
splitTrackSegmentsToTracks()
Split tracks so that only single-segment tracks remain.
|
void |
splitTracksToLayers()
Split tracks into layers, the result is one layer for each track.
|
addExtension, get, getCollection, getString, put
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getDataSourceArea, getDataSourceBounds
public java.io.File storageFile
null
.public boolean fromServer
public java.lang.String creator
private final java.util.ArrayList<GpxTrack> privateTracks
private final java.util.ArrayList<GpxRoute> privateRoutes
private final java.util.ArrayList<WayPoint> privateWaypoints
private final GpxTrack.GpxTrackChangeListener proxy
public final java.util.Collection<GpxTrack> tracks
getTracks()
to read.getTracks()
public final java.util.Collection<GpxRoute> routes
getTracks()
to read.getRoutes()
public final java.util.Collection<WayPoint> waypoints
getTracks()
to read.getWaypoints()
public final java.util.Set<DataSource> dataSources
<bounds>
element in its GPX reply.private final ListenerList<GpxData.GpxDataChangeListener> listeners
private java.util.List<GpxData.GpxTrackSegmentSpan> segSpans
public GpxData()
public void mergeFrom(GpxData other)
other
- existing GPX datapublic void mergeFrom(GpxData other, boolean cutOverlapping, boolean connect)
other
- existing GPX datacutOverlapping
- whether overlapping parts of the given track should be removedconnect
- whether the tracks should be connected on cutsprivate void cutOverlapping(GpxTrack trk, boolean connect)
private void connectTracks(WayPoint prevWp, GpxData.GpxTrackSegmentSpan span, java.util.Map<java.lang.String,java.lang.Object> attr)
public java.util.List<GpxData.GpxTrackSegmentSpan> getSegmentSpans()
private boolean anySegmentOverlapsWith(GpxData.GpxTrackSegmentSpan other)
public java.util.Collection<GpxTrack> getTracks()
private java.util.stream.Stream<GpxTrackSegment> getTrackSegmentsStream()
Stream<GPXTrack>
private void clearTracks()
public void addTrack(GpxTrack track)
track
- The new trackpublic void removeTrack(GpxTrack track)
track
- The old trackpublic void combineTracksToSegmentedTrack()
public static java.lang.String ensureUniqueName(java.util.Map<java.lang.String,java.lang.Object> attrs, java.util.Map<java.lang.String,java.lang.Integer> counts)
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.public void splitTrackSegmentsToTracks()
public void splitTracksToLayers()
public int getTrackCount()
public int getTrackSegsCount()
public java.util.Collection<GpxRoute> getRoutes()
public void addRoute(GpxRoute route)
route
- The new routepublic void removeRoute(GpxRoute route)
route
- The old routepublic java.util.Collection<WayPoint> getWaypoints()
public void addWaypoint(WayPoint waypoint)
waypoint
- The new waypointpublic void removeWaypoint(WayPoint waypoint)
waypoint
- The old waypointpublic boolean hasTrackPoints()
true
if this GPX data has track points, false
otherwisepublic java.util.stream.Stream<WayPoint> getTrackPoints()
getTracks()
,
GpxTrack.getSegments()
,
GpxTrackSegment.getWayPoints()
public boolean hasRoutePoints()
true
if this GPX data has route points, false
otherwisepublic boolean isEmpty()
true
if this GPX data is empty, false
otherwisepublic Bounds getMetaBounds()
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
.null
.recalculateBounds()
,
dataSources
public Bounds recalculateBounds()
getMetaBounds()
.dataSources
.getMetaBounds()
,
dataSources
public double length()
public static java.util.Date[] getMinMaxTimeForTrack(GpxTrack trk)
trk
- track to analyzepublic java.util.Date[] getMinMaxTimeForAllTracks()
public WayPoint nearestPointOnTrack(EastNorth p, double tolerance)
p
- : the point to determine the projection fortolerance
- : must be no further than this from the trackpublic java.lang.Iterable<Line> getLinesIterable(boolean... trackVisibility)
trackVisibility
- An array indicating which tracks should be
included in the iteration. Can be null, then all tracks are included.public void resetEastNorthCache()
public java.util.Collection<DataSource> getDataSources()
Data
getDataSources
in interface Data
public int hashCode()
hashCode
in class WithAttributes
public boolean equals(java.lang.Object obj)
equals
in class WithAttributes
public void addChangeListener(GpxData.GpxDataChangeListener listener)
listener
- The listenerpublic void addWeakChangeListener(GpxData.GpxDataChangeListener listener)
listener
- The listenerpublic void removeChangeListener(GpxData.GpxDataChangeListener listener)
listener
- The listenerprivate void fireInvalidate()