Autopsy  4.19.1
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  throw new GeoLocationDataException("No TSK_GEO_TRACKPOINTS attribute present in attribute map to parse.");
135  }
136 
137  try {
138  return BlackboardJsonAttrUtil.fromAttribute(attribute, GeoTrackPoints.class);
139  } catch (InvalidJsonException ex) {
140  throw new GeoLocationDataException("Unable to parse track points in TSK_GEO_TRACKPOINTS attribute", ex);
141  }
142  }
143 
147  final class TrackWaypoint extends Waypoint {
148 
149  private final List<Waypoint.Property> propertyList;
150 
162  TrackWaypoint(BlackboardArtifact artifact, String pointLabel, GeoTrackPoints.TrackPoint point) throws GeoLocationDataException {
163  super(artifact, pointLabel,
164  point.getTimeStamp(),
165  point.getLatitude(),
166  point.getLongitude(),
167  point.getAltitude(),
168  null,
169  null,
170  Track.this);
171 
172  propertyList = createPropertyList(point);
173  }
174 
181  @Override
182  public List<Waypoint.Property> getOtherProperties() {
183  return Collections.unmodifiableList(propertyList);
184  }
185 
193  @Messages({
194  "Track_distanceTraveled_displayName=Distance traveled",
195  "Track_distanceFromHome_displayName=Distance from home point"
196  })
197  private List<Waypoint.Property> createPropertyList(GeoTrackPoints.TrackPoint point) {
198  List<Waypoint.Property> list = new ArrayList<>();
199 
200  Double value = point.getVelocity();
201  if (value != null) {
202  list.add(new Property(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_VELOCITY.getDisplayName(), value.toString()));
203  }
204 
205  value = point.getDistanceTraveled();
206  if (value != null) {
207  list.add(new Property(Bundle.Track_distanceTraveled_displayName(), value.toString()));
208  }
209 
210  value = point.getDistanceFromHomePoint();
211  if (value != null) {
212  list.add(new Property(Bundle.Track_distanceFromHome_displayName(), value.toString()));
213  }
214 
215  return list;
216  }
217  }
218 }
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-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.