diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java index 3900dab3b6..3cecae45ab 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java @@ -38,7 +38,6 @@ import javax.swing.JOptionPane; import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import org.openide.filesystems.FileUtil; -import org.openide.util.Exceptions; import org.openide.util.NbBundle.Messages; import org.openide.windows.RetainLocation; import org.openide.windows.TopComponent; @@ -458,7 +457,7 @@ public final class GeolocationTopComponent extends TopComponent { } catch (GeoLocationDataException ex) { logger.log(Level.WARNING, "Exception thrown while retrieving list of Tracks", ex); } - + final List completeList = createWaypointList(waypoints, tracks); // Make sure that the waypoints are added to the map panel in @@ -487,14 +486,14 @@ public final class GeolocationTopComponent extends TopComponent { } /** - * Returns a complete list of waypoints including the tracks. Takes into + * Returns a complete list of waypoints including the tracks. Takes into * account the current filters and includes waypoints as approprate. - * + * * @param waypoints List of waypoints - * @param tracks List of tracks - * - * @return A list of waypoints including the tracks based on the current - * filters. + * @param tracks List of tracks + * + * @return A list of waypoints including the tracks based on the current + * filters. */ private List createWaypointList(List waypoints, List tracks) { final List completeList = new ArrayList<>(); @@ -508,31 +507,11 @@ public final class GeolocationTopComponent extends TopComponent { timeRangeEnd = getMostRecent(waypoints, tracks); timeRangeStart = timeRangeEnd - (86400 * filters.getMostRecentNumDays()); - // Add all of the waypoints that fix into the time range. - for (Waypoint point : waypoints) { - Long time = point.getTimestamp(); - if ((time == null && filters.showWaypointsWithoutTimeStamp()) - || (time != null && (time >= timeRangeStart && time <= timeRangeEnd))) { + completeList.addAll(getWaypointsInRange(timeRangeStart, timeRangeEnd, waypoints)); + completeList.addAll(getTracksInRange(timeRangeStart, timeRangeEnd, tracks)); - completeList.add(point); - } - } - - // Add all of the tracks, using only the start timestamp - // of the track to determine if the track fixes into the - // range. - for (Track track : tracks) { - Long trackTime = track.getStartTime(); - - if ((trackTime == null && filters.showWaypointsWithoutTimeStamp()) - || (trackTime != null && (trackTime >= timeRangeStart && trackTime <= timeRangeEnd))) { - - completeList.addAll(track.getPath()); - } - } } else { completeList.addAll(waypoints); - for (Track track : tracks) { completeList.addAll(track.getPath()); } @@ -543,12 +522,69 @@ public final class GeolocationTopComponent extends TopComponent { return completeList; } - + + /** + * Return a list of waypoints that fall into the given time range. + * + * @param timeRangeStart start timestamp of range (seconds from java + * epoch) + * @param timeRangeEnd start timestamp of range (seconds from java + * epoch) + * @param waypoints List of waypoints to filter. + * + * @return A list of waypoints that fall into the time range. + */ + private List getWaypointsInRange(Long timeRangeStart, Long timeRangeEnd, List waypoints) { + List completeList = new ArrayList<>(); + // Add all of the waypoints that fix into the time range. + if (waypoints != null) { + for (Waypoint point : waypoints) { + Long time = point.getTimestamp(); + if ((time == null && filters.showWaypointsWithoutTimeStamp()) + || (time != null && (time >= timeRangeStart && time <= timeRangeEnd))) { + + completeList.add(point); + } + } + } + return completeList; + } + + /** + * Return a list of waypoints from the given tracks that fall into for + * tracks that fall into the given time range. The track start time will + * used for determining if the whole track falls into the range. + * + * @param timeRangeStart start timestamp of range (seconds from java + * epoch) + * @param timeRangeEnd start timestamp of range (seconds from java + * epoch) + * @param tracks Track list. + * + * @return A list of waypoints that that belong to tracks that fall into + * the time range. + */ + private List getTracksInRange(Long timeRangeStart, Long timeRangeEnd, List tracks) { + List completeList = new ArrayList<>(); + if (tracks != null) { + for (Track track : tracks) { + Long trackTime = track.getStartTime(); + + if ((trackTime == null && filters.showWaypointsWithoutTimeStamp()) + || (trackTime != null && (trackTime >= timeRangeStart && trackTime <= timeRangeEnd))) { + + completeList.addAll(track.getPath()); + } + } + } + return completeList; + } + /** * Find the latest time stamp in the given list of waypoints. - * + * * @param points List of Waypoints, required. - * + * * @return The latest time stamp (seconds from java epoch) */ private Long findMostRecentTimestamp(List points) { @@ -568,9 +604,9 @@ public final class GeolocationTopComponent extends TopComponent { /** * Find the latest time stamp in the given list of tracks. - * + * * @param tracks List of Waypoints, required. - * + * * @return The latest time stamp (seconds from java epoch) */ private Long findMostRecentTracks(List tracks) { @@ -588,12 +624,12 @@ public final class GeolocationTopComponent extends TopComponent { } /** - * Returns the "most recent" timestamp amount the list of waypoints - * and track points. - * + * Returns the "most recent" timestamp amount the list of waypoints and + * track points. + * * @param points List of Waypoints * @param tracks List of Tracks - * + * * @return Latest time stamp (seconds from java epoch) */ private Long getMostRecent(List points, List tracks) { diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/MapWaypoint.java b/Core/src/org/sleuthkit/autopsy/geolocation/MapWaypoint.java index c8f6773f19..2c0b17b69a 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/MapWaypoint.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/MapWaypoint.java @@ -45,12 +45,7 @@ import org.sleuthkit.autopsy.directorytree.ExternalViewerAction; import org.sleuthkit.autopsy.directorytree.ExternalViewerShortcutAction; import org.sleuthkit.autopsy.directorytree.ExtractAction; import org.sleuthkit.autopsy.directorytree.actionhelpers.ExtractActionHelper; -import org.sleuthkit.autopsy.geolocation.datamodel.GeoLocationDataException; -import org.sleuthkit.autopsy.geolocation.datamodel.Route; -import org.sleuthkit.autopsy.geolocation.datamodel.Track; -import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.autopsy.geolocation.datamodel.Waypoint; -import org.sleuthkit.autopsy.geolocation.datamodel.WaypointBuilder; import org.sleuthkit.autopsy.timeline.actions.ViewArtifactInTimelineAction; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/Path.java b/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/Path.java index 4281e8fca3..ed007b2bba 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/Path.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/Path.java @@ -31,8 +31,8 @@ import org.sleuthkit.datamodel.TskCoreException; * Class representing a series of waypoints that form a path. */ public class Path { - - private final List path; + + private final List waypointList; private final String pathName; private final BlackboardArtifact artifact; @@ -65,9 +65,9 @@ public class Path { /** * Gets the list of Routes from the TSK_GPS_TRACK artifacts. * - * @param skCase Currently open SleuthkitCase - * @param sourceList List of source to return tracks from, maybe null to - * return tracks from all sources + * @param skCase Currently open SleuthkitCase + * @param sourceList List of source to return tracks from, maybe null to + * return tracks from all sources * * @return List of Route objects, empty list will be returned if no Routes * were found @@ -76,63 +76,63 @@ public class Path { */ static public List getTracks(SleuthkitCase skCase, List sourceList) throws GeoLocationDataException { List artifacts = null; - List tracks = new ArrayList<>(); + List tracks = new ArrayList<>(); try { artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACK); - for (BlackboardArtifact artifact : artifacts) { - if(sourceList == null || sourceList.contains(artifact.getDataSource())){ - Track route = new Track(artifact); - tracks.add(route); + for (BlackboardArtifact artifact : artifacts) { + if (sourceList == null || sourceList.contains(artifact.getDataSource())) { + Track route = new Track(artifact); + tracks.add(route); + } } - } } catch (TskCoreException ex) { throw new GeoLocationDataException("Unable to get artifacts for type: TSK_GPS_BOOKMARK", ex); } return tracks; } - + /** * Path constructor. - * + * * @param artifact BlackboardARtifact that this path represents, required * @param pathName Name for this path, maybe null or empty string. */ Path(BlackboardArtifact artifact, String pathName) { - this.path = new ArrayList<>(); + this.waypointList = new ArrayList<>(); this.pathName = pathName; this.artifact = artifact; } - + /** * Adds a Waypoint to the path. - * - * @param point + * + * @param point */ final void addToPath(Waypoint point) { - path.add(point); + waypointList.add(point); } - + /** * Get the list of way points for this route; * * @return List an unmodifiableList of ArtifactWaypoints for this route */ final public List getPath() { - return Collections.unmodifiableList(path); + return Collections.unmodifiableList(waypointList); } - + /** * Returns the BlackboardARtifact that this path represents. - * - * @return + * + * @return */ final BlackboardArtifact getArtifact() { return artifact; } - + /** * Returns the label\display name for this path. - * + * * @return Path label, empty string */ public String getLabel() { diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/WaypointBuilder.java b/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/WaypointBuilder.java index 20bf94f892..66d37c6913 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/WaypointBuilder.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/WaypointBuilder.java @@ -133,7 +133,7 @@ public final class WaypointBuilder { List routeList = new ArrayList<>(); for (Waypoint point : waypoints) { Path path = point.getPath(); - if (path != null && path instanceof Route) { + if (path instanceof Route) { Route route = (Route) path; if (!routeList.contains(route)) { routeList.add(route); @@ -143,7 +143,7 @@ public final class WaypointBuilder { return routeList; } - + /** * Returns a list of tracks from the given list of waypoints. * @@ -155,7 +155,7 @@ public final class WaypointBuilder { List trackList = new ArrayList<>(); for (Waypoint point : waypoints) { Path path = point.getPath(); - if (path != null && path instanceof Track) { + if (path instanceof Track) { Track route = (Track) path; if (!trackList.contains(route)) { trackList.add(route); @@ -495,18 +495,16 @@ public final class WaypointBuilder { * @return SQL SELECT statement */ static private String buildQueryForWaypointsWOTimeStamps(List dataSources) { - + // SELECT_WO_TIMESTAMP // SELECT DISTINCT artifact_id, artifact_type_id // FROM blackboard_attributes // WHERE artifact_id NOT IN (%s) // AND artifact_id IN (%s) - // GEO_ARTIFACT_QUERY_ID_ONLY // SELECT artifact_id // FROM blackboard_attributes // WHERE attribute_type_id IN (%d, %d) - return String.format(SELECT_WO_TIMESTAMP, String.format(GEO_ARTIFACT_QUERY_ID_ONLY, BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), @@ -548,12 +546,12 @@ public final class WaypointBuilder { // IN ( %s ) // mostRecentQuery = String.format("AND value_int64 > (%s)", //NON-NLS - String.format(MOST_RECENT_TIME, - cntDaysFromRecent, - BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), - BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(), - getWaypointListQuery(dataSources) - )); + String.format(MOST_RECENT_TIME, + cntDaysFromRecent, + BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), + BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID(), + getWaypointListQuery(dataSources) + )); } // GEO_ARTIFACT_QUERY @@ -647,8 +645,12 @@ public final class WaypointBuilder { case TSK_GPS_LAST_KNOWN_LOCATION: waypoints.add(new LastKnownWaypoint(artifact)); break; + case TSK_GPS_TRACK: + Track track = new Track(artifact); + waypoints.addAll(track.getPath()); + break; default: - waypoints.add(new CustomArtifactWaypoint(artifact)); + waypoints.add(new CustomArtifactWaypoint(artifact)); } return waypoints; diff --git a/Core/src/org/sleuthkit/autopsy/report/modules/kml/KMLReport.java b/Core/src/org/sleuthkit/autopsy/report/modules/kml/KMLReport.java index a8538d4d8f..c13f385ba3 100644 --- a/Core/src/org/sleuthkit/autopsy/report/modules/kml/KMLReport.java +++ b/Core/src/org/sleuthkit/autopsy/report/modules/kml/KMLReport.java @@ -424,7 +424,7 @@ public final class KMLReport implements GeneralReportModule { /** * Add the given route to the KML report. - * + * * @param route */ private void addRouteToReport(Route route) { @@ -495,7 +495,7 @@ public final class KMLReport implements GeneralReportModule { /** * Add a track to the KML report. - * + * * @param track */ private void addTrackToReport(Track track) {