Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Route.java
Go to the documentation of this file.
1 /*
2  *
3  * Autopsy Forensic Browser
4  *
5  * Copyright 2019 Basis Technology Corp.
6  * contact: carrier <at> sleuthkit <dot> org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 package org.sleuthkit.autopsy.geolocation.datamodel;
21 
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.List;
25 import java.util.Map;
26 import org.openide.util.NbBundle.Messages;
27 import org.sleuthkit.datamodel.BlackboardArtifact;
28 import org.sleuthkit.datamodel.BlackboardAttribute;
29 import org.sleuthkit.datamodel.SleuthkitCase;
30 import org.sleuthkit.datamodel.TskCoreException;
31 
38 public final class Route {
39  private final List<Waypoint> points;
40  private final Long timestamp;
41 
42  // This list is not expected to change after construction so the
43  // constructor will take care of creating an unmodifiable List
45 
56  static public List<Route> getRoutes(SleuthkitCase skCase) throws GeoLocationDataException {
57  List<BlackboardArtifact> artifacts = null;
58  try {
59  artifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE);
60  } catch (TskCoreException ex) {
61  throw new GeoLocationDataException("Unable to get artifacts for type: TSK_GPS_BOOKMARK", ex);
62  }
63 
64  List<Route> routes = new ArrayList<>();
65  for (BlackboardArtifact artifact : artifacts) {
66  Route route = new Route(artifact);
67  routes.add(route);
68  }
69  return routes;
70  }
71 
77  Route(BlackboardArtifact artifact) throws GeoLocationDataException {
78  points = new ArrayList<>();
79 
80  Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap = Waypoint.getAttributesFromArtifactAsMap(artifact);
81  points.add(getRouteStartPoint(artifact, attributeMap));
82  points.add(getRouteEndPoint(artifact, attributeMap));
83 
84  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME);
85  timestamp = attribute != null ? attribute.getValueLong() : null;
86 
87  immutablePropertiesList = Collections.unmodifiableList(Waypoint.createGeolocationProperties(attributeMap));
88  }
89 
95  public List<Waypoint> getRoute() {
96  return Collections.unmodifiableList(points);
97  }
98 
107  }
108 
112  @Messages({
113  // This is the original static hardcoded label from the
114  // original kml-report code
115  "Route_Label=As-the-crow-flies Route"
116  })
117  public String getLabel() {
118  return Bundle.Route_Label();
119  }
120 
121  public Long getTimestamp() {
122  return timestamp;
123  }
124 
137  @Messages({
138  "Route_Start_Label=Start"
139  })
140 
141  private Waypoint getRouteStartPoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
142  BlackboardAttribute latitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START);
143  BlackboardAttribute longitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START);
144  BlackboardAttribute altitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE);
145  BlackboardAttribute pointTimestamp = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME);
146 
147  if (latitude != null && longitude != null) {
148  return new Waypoint(artifact,
149  Bundle.Route_Start_Label(),
150  pointTimestamp != null ? pointTimestamp.getValueLong() : null,
151  latitude.getValueDouble(),
152  longitude.getValueDouble(),
153  altitude != null ? altitude.getValueDouble() : null,
154  null, attributeMap, this);
155  } else {
156  throw new GeoLocationDataException("Unable to create route start point, invalid longitude and/or latitude");
157  }
158  }
159 
171  @Messages({
172  "Route_End_Label=End"
173  })
174  Waypoint getRouteEndPoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
175  BlackboardAttribute latitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END);
176  BlackboardAttribute longitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END);
177  BlackboardAttribute altitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE);
178  BlackboardAttribute pointTimestamp = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME);
179 
180  if (latitude != null && longitude != null) {
181 
182  return new Waypoint(artifact,
183  Bundle.Route_End_Label(),
184  pointTimestamp != null ? pointTimestamp.getValueLong() : null,
185  latitude.getValueDouble(),
186  longitude.getValueDouble(),
187  altitude != null ? altitude.getValueDouble() : null,
188  null, attributeMap, this);
189  } else {
190  throw new GeoLocationDataException("Unable to create route end point, invalid longitude and/or latitude");
191  }
192  }
193 }
static List< Route > getRoutes(SleuthkitCase skCase)
Definition: Route.java:56
final List< Waypoint.Property > immutablePropertiesList
Definition: Route.java:44
static List< Waypoint.Property > createGeolocationProperties(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Waypoint.java:241
List< Waypoint.Property > getOtherProperties()
Definition: Route.java:105
Waypoint getRouteStartPoint(BlackboardArtifact artifact, Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Route.java:141

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.