19 package org.sleuthkit.autopsy.geolocation;
21 import java.util.ArrayList;
22 import java.util.List;
24 import java.util.logging.Level;
31 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
36 abstract class AbstractWaypointFetcher
implements WaypointBuilder.WaypointFilterQueryCallBack {
40 private final GeoFilterPanel.GeoFilter filters;
47 AbstractWaypointFetcher(GeoFilterPanel.GeoFilter filters) {
48 this.filters = filters;
63 filters.getDataSources(),
64 filters.getArtifactTypes(),
65 filters.showAllWaypoints(),
66 filters.getMostRecentNumDays(),
67 filters.showWaypointsWithoutTimeStamp(),
78 abstract void handleFilteredWaypointSet(Set<MapWaypoint> mapWaypoints);
81 public void process(List<Waypoint> waypoints) {
82 List<Track> tracks = null;
83 if (filters.getArtifactTypes().contains(ARTIFACT_TYPE.TSK_GPS_TRACK)) {
87 logger.log(Level.WARNING,
"Exception thrown while retrieving list of Tracks", ex);
91 List<Waypoint> completeList = createWaypointList(waypoints, tracks);
92 final Set<MapWaypoint> pointSet = MapWaypoint.getWaypoints(completeList);
94 handleFilteredWaypointSet(pointSet);
107 private List<Waypoint> createWaypointList(List<Waypoint> waypoints, List<Track> tracks) {
108 final List<Waypoint> completeList =
new ArrayList<>();
110 if (tracks != null) {
113 if (!filters.showAllWaypoints()) {
116 timeRangeEnd = getMostRecent(waypoints, tracks);
117 timeRangeStart = timeRangeEnd - (86400 * filters.getMostRecentNumDays());
119 completeList.addAll(getWaypointsInRange(timeRangeStart, timeRangeEnd, waypoints));
120 completeList.addAll(getTracksInRange(timeRangeStart, timeRangeEnd, tracks));
123 completeList.addAll(waypoints);
124 for (
Track track : tracks) {
125 completeList.addAll(track.getPath());
129 completeList.addAll(waypoints);
144 private List<Waypoint> getWaypointsInRange(Long timeRangeStart, Long timeRangeEnd, List<Waypoint> waypoints) {
145 List<Waypoint> completeList =
new ArrayList<>();
147 if (waypoints != null) {
149 Long time = point.getTimestamp();
150 if ((time == null && filters.showWaypointsWithoutTimeStamp())
151 || (time != null && (time >= timeRangeStart && time <= timeRangeEnd))) {
153 completeList.add(point);
172 private List<Waypoint> getTracksInRange(Long timeRangeStart, Long timeRangeEnd, List<Track> tracks) {
173 List<Waypoint> completeList =
new ArrayList<>();
174 if (tracks != null) {
175 for (
Track track : tracks) {
176 Long trackTime = track.getStartTime();
178 if ((trackTime == null && filters.showWaypointsWithoutTimeStamp())
179 || (trackTime != null && (trackTime >= timeRangeStart && trackTime <= timeRangeEnd))) {
181 completeList.addAll(track.getPath());
195 private Long findMostRecentTimestamp(List<Waypoint> points) {
197 Long mostRecent = null;
200 if (mostRecent == null) {
201 mostRecent = point.getTimestamp();
203 mostRecent = Math.max(mostRecent, point.getTimestamp());
217 private Long findMostRecentTracks(List<Track> tracks) {
218 Long mostRecent = null;
220 for (
Track track : tracks) {
221 if (mostRecent == null) {
222 mostRecent = track.getStartTime();
223 }
else if (track.getStartTime() != null) {
224 mostRecent = Math.max(mostRecent, track.getStartTime());
240 private Long getMostRecent(List<Waypoint> points, List<Track> tracks) {
241 Long waypointMostRecent = findMostRecentTimestamp(points);
242 Long trackMostRecent = findMostRecentTracks(tracks);
244 if (waypointMostRecent != null && trackMostRecent != null) {
245 return Math.max(waypointMostRecent, trackMostRecent);
246 }
else if (waypointMostRecent == null && trackMostRecent != null) {
247 return trackMostRecent;
248 }
else if (waypointMostRecent != null && trackMostRecent == null) {
249 return waypointMostRecent;
static List< 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)