19 package org.sleuthkit.autopsy.geolocation;
21 import java.util.ArrayList;
22 import java.util.List;
24 import java.util.logging.Level;
25 import javafx.util.Pair;
33 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
38 abstract class AbstractWaypointFetcher
implements WaypointBuilder.WaypointFilterQueryCallBack {
42 private final GeoFilterPanel.GeoFilter filters;
49 AbstractWaypointFetcher(GeoFilterPanel.GeoFilter filters) {
50 this.filters = filters;
65 filters.getDataSources(),
66 filters.getArtifactTypes(),
67 filters.showAllWaypoints(),
68 filters.getMostRecentNumDays(),
69 filters.showWaypointsWithoutTimeStamp(),
83 abstract void handleFilteredWaypointSet(Set<MapWaypoint> mapWaypoints, List<Set<MapWaypoint>> tracks,
84 boolean wasEntirelySuccessful);
89 if (filters.getArtifactTypes().contains(ARTIFACT_TYPE.TSK_GPS_TRACK)) {
93 logger.log(Level.WARNING,
"Exception thrown while retrieving list of Tracks", ex);
97 Pair<List<Waypoint>, List<List<Waypoint>>> waypointsAndTracks = createWaypointList(
99 (trackResults == null) ?
new ArrayList<Track>() : trackResults.
getItems());
102 final Set<MapWaypoint> pointSet = MapWaypoint.getWaypoints(waypointsAndTracks.getKey());
103 final List<Set<MapWaypoint>> trackSets =
new ArrayList<>();
104 for (List<Waypoint> t : waypointsAndTracks.getValue()) {
105 trackSets.add(MapWaypoint.getWaypoints(t));
108 handleFilteredWaypointSet(
123 private Pair<List<Waypoint>, List<List<Waypoint>>> createWaypointList(List<Waypoint> waypoints, List<Track> tracks) {
124 final List<Waypoint> completeList =
new ArrayList<>();
125 List<List<Waypoint>> filteredTracks =
new ArrayList<>();
127 if (tracks != null) {
130 if (!filters.showAllWaypoints()) {
133 timeRangeEnd = getMostRecent(waypoints, tracks);
134 timeRangeStart = timeRangeEnd - (86400 * filters.getMostRecentNumDays());
136 completeList.addAll(getWaypointsInRange(timeRangeStart, timeRangeEnd, waypoints));
138 filteredTracks = getTracksInRange(timeRangeStart, timeRangeEnd, tracks);
139 for (List<Waypoint> filteredTrack : filteredTracks) {
140 completeList.addAll(filteredTrack);
143 completeList.addAll(waypoints);
144 for (
Track track : tracks) {
145 completeList.addAll(track.getPath());
146 filteredTracks.add(track.getPath());
150 completeList.addAll(waypoints);
152 return new Pair<>(completeList, filteredTracks);
164 private List<Waypoint> getWaypointsInRange(Long timeRangeStart, Long timeRangeEnd, List<Waypoint> waypoints) {
165 List<Waypoint> completeList =
new ArrayList<>();
167 if (waypoints != null) {
169 Long time = point.getTimestamp();
170 if ((time == null && filters.showWaypointsWithoutTimeStamp())
171 || (time != null && (time >= timeRangeStart && time <= timeRangeEnd))) {
173 completeList.add(point);
192 private List<List<Waypoint>> getTracksInRange(Long timeRangeStart, Long timeRangeEnd, List<Track> tracks) {
193 List<List<Waypoint>> ret =
new ArrayList<>();
194 if (tracks != null) {
195 for (
Track track : tracks) {
196 Long trackTime = track.getStartTime();
198 if ((trackTime == null && filters.showWaypointsWithoutTimeStamp())
199 || (trackTime != null && (trackTime >= timeRangeStart && trackTime <= timeRangeEnd))) {
200 ret.add(track.getPath());
214 private Long findMostRecentTimestamp(List<Waypoint> points) {
216 Long mostRecent = null;
219 if (mostRecent == null) {
220 mostRecent = point.getTimestamp();
222 mostRecent = Math.max(mostRecent, point.getTimestamp());
236 private Long findMostRecentTracks(List<Track> tracks) {
237 Long mostRecent = null;
239 for (
Track track : tracks) {
240 if (mostRecent == null) {
241 mostRecent = track.getStartTime();
242 }
else if (track.getStartTime() != null) {
243 mostRecent = Math.max(mostRecent, track.getStartTime());
259 private Long getMostRecent(List<Waypoint> points, List<Track> tracks) {
260 Long waypointMostRecent = findMostRecentTimestamp(points);
261 Long trackMostRecent = findMostRecentTracks(tracks);
263 if (waypointMostRecent != null && trackMostRecent != null) {
264 return Math.max(waypointMostRecent, trackMostRecent);
265 }
else if (waypointMostRecent == null && trackMostRecent != null) {
266 return trackMostRecent;
267 }
else if (waypointMostRecent != null && trackMostRecent == null) {
268 return waypointMostRecent;
static GeoLocationParseResult< Track > getTracks(SleuthkitCase skCase, List<?extends Content > sourceList)
static List< Waypoint > getAllWaypoints(SleuthkitCase skCase)
SleuthkitCase getSleuthkitCase()
static Case getCurrentCase()
synchronized static Logger getLogger(String name)
boolean isSuccessfullyParsed()