Autopsy  4.14.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Track.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 Basis Technology Corp.
5  * contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.geolocation.datamodel;
20 
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.Map;
25 import org.openide.util.NbBundle.Messages;
26 import org.sleuthkit.datamodel.BlackboardArtifact;
27 import org.sleuthkit.datamodel.BlackboardAttribute;
28 import org.sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil;
29 import org.sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil.InvalidJsonException;
30 import org.sleuthkit.datamodel.blackboardutils.attributes.GeoTrackPoints;
31 
35 public final class Track extends GeoPath {
36 
37  private final Long startTimestamp;
38  private final Long endTimeStamp;
39 
47  public Track(BlackboardArtifact artifact) throws GeoLocationDataException {
48  this(artifact, Waypoint.getAttributesFromArtifactAsMap(artifact));
49  }
50 
59  private Track(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
60  super(artifact, getTrackName(attributeMap));
61 
62  GeoTrackPoints points = getPointsList(attributeMap);
63  buildPath(points, artifact);
64 
65  startTimestamp = points.getStartTime();
66  endTimeStamp = points.getEndTime();
67  }
68 
75  public Long getStartTime() {
76  return startTimestamp;
77  }
78 
85  public Long getEndTime() {
86  return endTimeStamp;
87  }
88 
97  private static String getTrackName(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) {
98  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
99 
100  return attribute != null ? attribute.getValueString() : "";
101  }
102 
111  @Messages({
112  "# {0} - track name",
113  "GEOTrack_point_label_header=Trackpoint for track: {0}"
114  })
115  private void buildPath(GeoTrackPoints points, BlackboardArtifact artifact) throws GeoLocationDataException {
116  for (GeoTrackPoints.TrackPoint point : points) {
117  addToPath(new TrackWaypoint(artifact, Bundle.GEOTrack_point_label_header(getLabel()), point));
118  }
119  }
120 
131  private GeoTrackPoints getPointsList(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
132  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_TRACKPOINTS);
133  if (attribute != null) {
134  try {
135  return BlackboardJsonAttrUtil.fromAttribute(attribute, GeoTrackPoints.class);
136  } catch (InvalidJsonException ex) {
137  throw new GeoLocationDataException("Unable to parse track points in TSK_GEO_TRACKPOINTS attribute", ex);
138  }
139  }
140  return null;
141  }
142 
146  final class TrackWaypoint extends Waypoint {
147 
148  private final List<Waypoint.Property> propertyList;
149 
161  TrackWaypoint(BlackboardArtifact artifact, String pointLabel, GeoTrackPoints.TrackPoint point) throws GeoLocationDataException {
162  super(artifact, pointLabel,
163  point.getTimeStamp(),
164  point.getLatitude(),
165  point.getLongitude(),
166  point.getAltitude(),
167  null,
168  null,
169  Track.this);
170 
171  propertyList = createPropertyList(point);
172  }
173 
180  @Override
181  public List<Waypoint.Property> getOtherProperties() {
182  return Collections.unmodifiableList(propertyList);
183  }
184 
192  @Messages({
193  "Track_distanceTraveled_displayName=Distance traveled",
194  "Track_distanceFromHome_displayName=Distance from home point"
195  })
196  private List<Waypoint.Property> createPropertyList(GeoTrackPoints.TrackPoint point) {
197  List<Waypoint.Property> list = new ArrayList<>();
198 
199  Long timestamp = point.getTimeStamp();
200  if (timestamp != null) {
201  list.add(new Property(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getDisplayName(), timestamp.toString()));
202  }
203 
204  Double value = point.getVelocity();
205  if (value != null) {
206  list.add(new Property(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_VELOCITY.getDisplayName(), value.toString()));
207  }
208 
209  value = point.getDistanceTraveled();
210  if (value != null) {
211  list.add(new Property(Bundle.Track_distanceTraveled_displayName(), value.toString()));
212  }
213 
214  value = point.getDistanceFromHomePoint();
215  if (value != null) {
216  list.add(new Property(Bundle.Track_distanceFromHome_displayName(), value.toString()));
217  }
218 
219  return list;
220  }
221  }
222 }
Track(BlackboardArtifact artifact)
Definition: Track.java:47
Track(BlackboardArtifact artifact, Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Track.java:59
GeoTrackPoints getPointsList(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Track.java:131
static String getTrackName(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Track.java:97
void buildPath(GeoTrackPoints points, BlackboardArtifact artifact)
Definition: Track.java:115

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.