diff --git a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/GeoArtifactsHelper.java b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/GeoArtifactsHelper.java index a589c764fda05543d314291be0138f3bb883e608..28a74d3e53b4b3ab627392168ce99f98add4d742 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/GeoArtifactsHelper.java +++ b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/GeoArtifactsHelper.java @@ -52,8 +52,8 @@ public final class GeoArtifactsHelper extends ArtifactHelperBase { * null. If a program name is supplied, it will be added * to each artifact that is created as a TSK_PROG_NAME * attribute. - * @param srcContent The source content for the artifacts, i.e., a file - * within a data source or a data source. + * @param srcContent The source content for the artifacts, i.e., either a + * file within a data source or a data source. */ public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String programName, Content srcContent) { super(caseDb, moduleName, srcContent); @@ -66,9 +66,8 @@ public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String progra * Adds a TSK_GPS_TRACK artifact to the case database. A Global Positioning * System (GPS) track artifact records the track, or path, of a GPS-enabled * device as a connected series of track points. A track point is a location - * in a geographic coordinate system (see - * https://en.wikipedia.org/wiki/Geographic_coordinate_system) where the - * coordinates are latitude, longitude and altitude (elevation). + * in a geographic coordinate system with latitude, longitude and altitude + * (elevation) axes. * * @param trackName The name of the GPS track, may be null. * @param trackPoints The track points that make up the track. @@ -82,7 +81,6 @@ public GeoArtifactsHelper(SleuthkitCase caseDb, String moduleName, String progra * the blackboard. */ public BlackboardArtifact addTrack(String trackName, GeoTrackPointList trackPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException { - if (trackPoints == null) { throw new IllegalArgumentException(String.format("addTrack was passed a null list of track points")); } @@ -114,10 +112,9 @@ public BlackboardArtifact addTrack(String trackName, GeoTrackPointList trackPoin /** * Adds a TSK_GPS_ROUTE artifact to the case database. A Global Positioning * System (GPS) route artifact records one or more waypoints entered into a - * GPS-enabled navigation device as a route by a user. A waypoint is a - * location in a geographic coordinate system (see - * https://en.wikipedia.org/wiki/Geographic_coordinate_system) where the - * coordinates are latitude, longitude and altitude (elevation). + * GPS-enabled device as a route as a route to be navigated from waypoint to + * waypoint. A waypoint is a location in a geographic coordinate system with + * latitude, longitude and altitude (elevation) axes. * * @param routeName The name of the GPS route, may be null. * @param creationTime The time at which the route was created as @@ -134,7 +131,6 @@ public BlackboardArtifact addTrack(String trackName, GeoTrackPointList trackPoin * the blackboard. */ public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypointList wayPoints, List<BlackboardAttribute> moreAttributes) throws TskCoreException, BlackboardException { - if (wayPoints == null) { throw new IllegalArgumentException(String.format("addRoute was passed a null list of waypoints")); } @@ -166,5 +162,4 @@ public BlackboardArtifact addRoute(String routeName, Long creationTime, GeoWaypo return artifact; } - } diff --git a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoTrackpointsUtil.java b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoTrackpointsUtil.java index 8616703759b07eb45c8b72a0d09ea0c047f21939..4ef1879a46cae3392e5f406a93de13c24d453611 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoTrackpointsUtil.java +++ b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoTrackpointsUtil.java @@ -28,22 +28,19 @@ import org.sleuthkit.datamodel.blackboardutils.attributes.TskGeoTrackpointsUtil.GeoTrackPointList.GeoTrackPoint; /** - * A utility class for converting between a JSON-valued TSK_GEO_TRACKPOINTS - * attribute and a GeoTrackPointList object. A GeoTrackPointList is a collection - * of GeoTrackPoint objects. A GeoTrackPoint object represents a track point, - * which is a location in a geographic coordinate system (see - * https://en.wikipedia.org/wiki/Geographic_coordinate_system) where the - * coordinates are latitude, longitude and altitude (elevation). + * A utility class for converting between a TSK_GEO_TRACKPOINTS attribute and a + * GeoTrackPointList. A GeoTrackPointList is a collection of GeoTrackPoints. A + * GeoTrackPoint represents a track point, which is a location in a geographic + * coordinate system with latitude, longitude and altitude (elevation) axes. * - * A TSK_GEO_TRACKPOINTS atrribute is typically attached to a TSK_GPS_TRACK - * artifact. A TSK_GPS_TRACK artifact records a track, or path, of a GPS-enabled - * device as a connected series of track points. + * A TSK_GPS_TRACK artifact uses a TSK_GEO_TRACKPOINTS attribute to record a + * track, or path, of a GPS-enabled device as a connected series of track points + * . */ public final class TskGeoTrackpointsUtil implements BlackboardAttributeUtil<TskGeoTrackpointsUtil.GeoTrackPointList> { @Override public BlackboardAttribute toAttribute(String moduleName, GeoTrackPointList value) { - if (value == null) { throw new IllegalArgumentException("toAttribute was passed a null list"); } @@ -69,27 +66,26 @@ public GeoTrackPointList fromAttribute(BlackboardAttribute attribute) { } /** - * Constructs a GeoTrackPointList object from a GeoTrackPointList serailized - * as JSON. + * Constructs a GeoTrackPointList object from its JSON representation. * - * @param trackPointsJson A JSON representation of a GeoTrackPointList. + * @param json A JSON representation of a GeoTrackPointList. * * @return The GeoTrackPointList object. */ - private static GeoTrackPointList fromJSON(String trackPointsJson) { - if (trackPointsJson == null || trackPointsJson.isEmpty()) { + private static GeoTrackPointList fromJSON(String json) { + if (json == null || json.isEmpty()) { throw new IllegalArgumentException("fromJSON was passed a empty or null JSON string"); } - return (new Gson()).fromJson(trackPointsJson, GeoTrackPointList.class); + return (new Gson()).fromJson(json, GeoTrackPointList.class); } /** - * Serializes a GeoTrackPointList object as JSON. + * Creates a JSON representation of a GeoTrackPointList object. * * @param trackPoints A GeoTrackPointList object. * - * @return The JSON serialization of the GeoTrackPointList. + * @return The JSON representation of the GeoTrackPointList object. */ private static String toJSON(GeoTrackPointList trackPoints) { if (trackPoints == null) { @@ -101,10 +97,9 @@ private static String toJSON(GeoTrackPointList trackPoints) { } /** - * A collection of GeoTrackPoint objects. A GeoTrackPoint object represents - * a track point, which is a location in a geographic coordinate system (see - * https://en.wikipedia.org/wiki/Geographic_coordinate_system) where the - * coordinates are latitude, longitude and altitude (elevation). + * A list of GeoTrackPoints. A GeoTrackPoint represents a track point, which + * is a location in a geographic coordinate system with latitude, longitude + * and altitude (elevation) axes. */ public static class GeoTrackPointList implements Iterable<GeoTrackPointList.GeoTrackPoint> { @@ -117,22 +112,6 @@ public GeoTrackPointList() { pointList = new ArrayList<>(); } - /** - * Constructs a GeoTrackPointList from a list of GeoTrackPoint objects. - * - * @param trackPoints A list of GeoTrackPoint objects. - */ - public GeoTrackPointList(List<GeoTrackPoint> trackPoints) { - if (trackPoints == null) { - throw new IllegalArgumentException("Constructor was passed a null list"); - } - - pointList = new ArrayList<>(); - for (GeoTrackPoint point : trackPoints) { - pointList.add(new GeoTrackPoint(point)); - } - } - /** * Adds a track point to this list of track points. * @@ -146,50 +125,6 @@ public void addPoint(GeoTrackPoint trackPoint) { pointList.add(trackPoint); } -// /** -// * Adds a track point to this list of track points. -// * -// * @param latitude The latitude of the track point. -// * @param longitude The longitude of the trac kpoint. -// * @param altitude The altitude of the track point, may be -// * null. -// * @param name The name of the track point, may be -// * null. -// * @param velocity The velocity of the device at the track -// * point in meters/sec, may be null. -// * @param distanceFromHomePoint The distance of the track point from an -// * established home point, may be null. -// * @param distanceTraveled The distance the device has traveled in -// * meters at the time this track point was -// * created, may be null -// * @param timestamp The creation time of the track point as -// * milliseconds from the Java epoch of -// * 1970-01-01T00:00:00Z, may be null. -// */ -// public void addPoint(Double latitude, -// Double longitude, -// Double altitude, -// String name, -// Double velocity, -// Double distanceFromHomePoint, -// Double distanceTraveled, -// Long timestamp) { -// pointList.add(new GeoTrackPoint( -// latitude, -// longitude, -// altitude, -// name, -// velocity, -// distanceFromHomePoint, -// distanceTraveled, -// timestamp)); -// } - - /** - * Gets an iterator for the track points in this list of track points. - * - * @return The iterator. - */ @Override public Iterator<GeoTrackPoint> iterator() { return pointList.iterator(); @@ -205,11 +140,11 @@ public boolean isEmpty() { } /** - * Get the nominal start time for the track represented by this list of - * track points, if available. + * Gets the earliest track point timestamp in this list of track points, + * if timestamps are present. * - * @return The earliest timestamp of a track point in this list of track - * points, may be null. + * @return The timestamp in milliseconds from the Java epoch of + * 1970-01-01T00:00:00Z, may be null or zero. */ public Long getStartTime() { List<GeoTrackPoint> orderedPoints = getTimeOrderedPoints(); @@ -224,11 +159,11 @@ public Long getStartTime() { } /** - * Get the nominal end time for the track represented by this list of - * track points, if available. + * Gets the latest track point timestamp in this list of track points, + * if timestamps are present. * - * @return The latest timestamp of a track point in this list of track - * points, may be null. + * @return The timestamp in milliseconds from the Java epoch of + * 1970-01-01T00:00:00Z, may be null or zero. */ public Long getEndTime() { List<GeoTrackPoint> orderedPoints = getTimeOrderedPoints(); @@ -244,8 +179,8 @@ public Long getEndTime() { } /** - * Gets the list of track points in this object as a list ordered by - * tarck point timestamp. + * Gets this list of track points as a list ordered by track point + * timestamp. * * @return The ordered list of track points. */ @@ -255,9 +190,8 @@ private List<GeoTrackPoint> getTimeOrderedPoints() { /** * A representation of a track point, which is a location in a - * geographic coordinate system (see - * https://en.wikipedia.org/wiki/Geographic_coordinate_system) where the - * coordinates are latitude, longitude and altitude (elevation). + * geographic coordinate system with latitude, longitude and altitude + * (elevation) axes. */ public final static class GeoTrackPoint extends TskGeoWaypointsUtil.GeoWaypointList.GeoWaypoint implements Comparable<GeoTrackPoint> { @@ -268,29 +202,27 @@ public final static class GeoTrackPoint extends TskGeoWaypointsUtil.GeoWaypointL /** * Constructs a representation of a track point, which is a location - * in a geographic coordinate system (see - * https://en.wikipedia.org/wiki/Geographic_coordinate_system) where - * the coordinates are latitude, longitude and altitude (elevation). + * in a geographic coordinate system with latitude, longitude and + * altitude (elevation) axes. * * @param latitude The latitude of the track point. - * @param longitude The longitude of the trac kpoint. + * @param longitude The longitude of the track point. * @param altitude The altitude of the track point, may * be null. * @param name The name of the track point, may be * null. * @param velocity The velocity of the device at the - * track point in meters/sec, may be - * null. + * track point in meters per second, + * may be null. * @param distanceFromHomePoint The distance of the track point in * meters from an established home * point, may be null. * @param distanceTraveled The distance the device has traveled * in meters at the time this track * point was created, may be null. - * @param timestamp The creation time of the track point - * as milliseconds from the Java epoch - * of 1970-01-01T00:00:00Z, may be - * null. + * @param timestamp The timestamp of the track point as + * milliseconds from the Java epoch of + * 1970-01-01T00:00:00Z, may be null. */ public GeoTrackPoint(Double latitude, Double longitude, @@ -308,26 +240,10 @@ public GeoTrackPoint(Double latitude, } /** - * Constructs a copy of a representation of a track point, which is - * a location in a geographic coordinate system (see - * https://en.wikipedia.org/wiki/Geographic_coordinate_system) where - * the coordinates are latitude, longitude and altitude (elevation). + * Gets the velocity of the device at this track point in meters per + * second, if known. * - * @param other A GeoTrackPoint to be copied. - */ - private GeoTrackPoint(GeoTrackPoint other) { - super(other.getLatitude(), other.getLongitude(), other.getAltitude(), other.getName()); - this.velocity = other.getVelocity(); - this.distanceFromHomePoint = other.getDistanceFromHomePoint(); - this.distanceTraveled = other.getDistanceTraveled(); - this.timestamp = other.getTimeStamp(); - } - - /** - * Gets the velocity of the device at this track point in - * meters/sec, if known. - * - * @return The velocity in meters/sec, may be null. + * @return The velocity in meters/sec, may be null or zero. */ public Double getVelocity() { return velocity; @@ -337,7 +253,7 @@ public Double getVelocity() { * Gets the distance of this track point from an established home * point, if known. * - * @return The distance in meters, may be null. + * @return The distance in meters, may be null or zero. */ public Double getDistanceFromHomePoint() { return distanceFromHomePoint; @@ -348,17 +264,17 @@ public Double getDistanceFromHomePoint() { * this track point was created, if known. * * - * @return The distance traveled in meters, may be null. + * @return The distance traveled in meters, may be null or zero. */ public Double getDistanceTraveled() { return distanceTraveled; } /** - * Gets the creation time of this track point as milliseconds from - * the Java epoch of 1970-01-01T00:00:00Z, if known. + * Gets the timestamp of this track point as milliseconds from the + * Java epoch of 1970-01-01T00:00:00Z, if known. * - * @return The creation timestamp, may be null. + * @return The timestamp, may be null or zero. */ public Long getTimeStamp() { return timestamp; @@ -377,7 +293,5 @@ public int compareTo(GeoTrackPoint otherTP) { } } } - } - } diff --git a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoWaypointsUtil.java b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoWaypointsUtil.java index 08d5a1c6bd6a77ab67bf0992c5a73a2d4e58ebe5..d4689050d0dfa44cf0c324d73e0695d2c847ea1f 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoWaypointsUtil.java +++ b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/attributes/TskGeoWaypointsUtil.java @@ -27,14 +27,19 @@ import org.sleuthkit.datamodel.blackboardutils.attributes.TskGeoWaypointsUtil.GeoWaypointList.GeoWaypoint; /** - * Utility class for Translating TSK_GEO_WAYPOINTS attribute values to - * GeoWaypointList objects and GeoWaypointList to BlackboardAttributes. + * A utility class for converting between a TSK_GEO_WAYPOINTS attribute and a + * GeoWaypointList. A GeoWaypointList is a collection of GeoWaypoints. A + * GeoWaypoint represents a waypoint, which is a location in a geographic + * coordinate system with latitude, longitude and altitude (elevation) axes. + * + * A TSK_GPS_ROUTE artifact uses a TSK_GEO_WAYPOINTS attribute to record one or + * more waypoints entered into a GPS-enabled device as a route to be navigated + * from waypoint to waypoint. */ public final class TskGeoWaypointsUtil implements BlackboardAttributeUtil<GeoWaypointList> { @Override public BlackboardAttribute toAttribute(String moduleName, GeoWaypointList value) { - if (value == null) { throw new IllegalArgumentException("toAttribute was pass a null list"); } @@ -60,61 +65,76 @@ public GeoWaypointList fromAttribute(BlackboardAttribute attribute) { } /** - * Deserialize the given list of GeoTrackPoints. + * Constructs a GeoWaypointList object from its JSON representation. * - * @param jsonString JSon string of track points. + * @param json A JSON representation of a GeoWaypointList. * - * @return Timestamp ordered list of GeoTrackPoints, empty list will be - * returned if jsonString is null or empty. + * @return The GeoWaypointList object. */ - private static GeoWaypointList fromJSON(String jsonString) { - if (jsonString == null || jsonString.isEmpty()) { + private static GeoWaypointList fromJSON(String json) { + if (json == null || json.isEmpty()) { return null; } - return (new Gson()).fromJson(jsonString, GeoWaypointList.class); + return (new Gson()).fromJson(json, GeoWaypointList.class); } /** - * Returns a JSON string can than be used as the TSK_GEO_TRACKPOINTS - * attribute of the TSK_GPS_TRACK artifact. + * Creates a JSON representation of a GeoWaypointList object. + * + * @param waypoints A GeoWaypointList object. * - * @return JSON string + * @return The JSON representation of the GeoWaypointList object. */ - private static String toJSON(GeoWaypointList pointList) { + private static String toJSON(GeoWaypointList waypoints) { Gson gson = new Gson(); - return gson.toJson(pointList); + return gson.toJson(waypoints); } /** - * Helper class to make it easier to serialize and deserialize the list of - * waypoints points with json. - * + * A list of GeoWaypoints. A GeoWaypoint represents a waypoint, which is a + * location in a geographic coordinate system with latitude, longitude and + * altitude (elevation) axes. */ public static final class GeoWaypointList implements Iterable<GeoWaypointList.GeoWaypoint> { private final List<GeoWaypoint> points; + /** + * Constructs an empty GeoWaypointList. + */ public GeoWaypointList() { points = new ArrayList<>(); } +// /** +// * Adds a point to the list of waypoints. +// * +// * @param latitude The latitude, required +// * @param longitude The longitude, required +// * @param altitude The altitude, can be null +// * @param name A name for the point, can be null +// */ +// public void addPoint(Double latitude, Double longitude, Double altitude, String name) { +// points.add(new GeoWaypoint(latitude, longitude, altitude, name)); +// } /** - * Adds a point to the list of waypoints. + * Adds a waypoint to this list of waypoints. * - * @param latitude The latitude, required - * @param longitude The longitude, required - * @param altitude The altitude, can be null - * @param name A name for the point, can be null + * @param wayPoint A waypoint. */ - public void addPoint(Double latitude, Double longitude, Double altitude, String name) { - points.add(new GeoWaypoint(latitude, longitude, altitude, name)); + public void addPoint(GeoWaypoint wayPoint) { + if (wayPoint == null) { + throw new IllegalArgumentException("addPoint was passed a null waypoint"); + } + + points.add(wayPoint); } /** - * Returns true if this list contains no points. + * Returns whether or not this list of waypoints is empty. * - * @return True if this list contains no points. + * @return True or false. */ public boolean isEmpty() { return points.isEmpty(); @@ -126,8 +146,9 @@ public Iterator<GeoWaypointList.GeoWaypoint> iterator() { } /** - * Class that represents a single waypoint made up of longitude, - * latitude, and altitude. + * A representation of a waypoint, which is a location in a geographic + * coordinate system with latitude, longitude and altitude (elevation) + * axes. */ public static class GeoWaypoint { @@ -137,16 +158,22 @@ public static class GeoWaypoint { private final String name; /** - * Creates a GeoWaypoint instance. + * Constructs a representation of a track point, which is a location + * in a geographic coordinate system with latitude, longitude and + * altitude (elevation) axes. * - * @param latitude The latitude, required - * @param longitude The longitude, required - * @param altitude The altitude, can be null - * @param name A name for the waypoint, optional + * @param latitude The latitude of the waypoint. + * @param longitude The longitude of the waypoint. + * @param altitude The altitude of the waypoint, may be null. + * @param name The name of the waypoint, may be null. */ public GeoWaypoint(Double latitude, Double longitude, Double altitude, String name) { - if (latitude == null || longitude == null) { - throw new IllegalArgumentException("Constructor was passed null coordinate"); + if (latitude == null) { + throw new IllegalArgumentException("Constructor was passed null latitude"); + } + + if (longitude == null) { + throw new IllegalArgumentException("Constructor was passed null longitude"); } this.latitude = latitude; @@ -156,38 +183,36 @@ public GeoWaypoint(Double latitude, Double longitude, Double altitude, String na } /** - * Returns latitude of the waypoint. + * Gets the latitude of this waypoint. * - * @return Double latitude value + * @return The latitude. */ public Double getLatitude() { return latitude; } /** - * Returns longitude of the waypoint. + * Gets the longitude of this waypoint. * - * @return Double longitude value + * @return The longitude. */ public Double getLongitude() { return longitude; } /** - * Get the altitude if available for this waypoint. + * Get the altitude of this waypoint, if available. * - * @return Double altitude value, may be null if not available or - * applicable + * @return The altitude, may be null or zero. */ public Double getAltitude() { return altitude; } /** - * Returns the name for this waypoint. + * Get the name of this waypoint, if available. * - * @return Returns waypoint name, may be null if not available or - * applicable. + * @return The name, may be null or empty. */ public String getName() { return name;