Autopsy  4.14.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-2020 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.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.GeoWaypoints;
31 
38 public class Route extends GeoPath {
39 
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
44  private final List<Waypoint.Property> propertiesList;
45 
51  @Messages({
52  // This is the original static hardcoded label from the
53  // original kml-report code
54  "Route_Label=As-the-crow-flies Route"
55  })
56  Route(BlackboardArtifact artifact) throws GeoLocationDataException {
57  super(artifact, Bundle.Route_Label());
58 
59  Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap = Waypoint.getAttributesFromArtifactAsMap(artifact);
60 
61  createRoute(artifact, attributeMap);
62 
63  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME);
64  timestamp = attribute != null ? attribute.getValueLong() : null;
65 
66  propertiesList = Waypoint.createGeolocationProperties(attributeMap);
67  }
68 
74  public List<Waypoint> getRoute() {
75  return getPath();
76  }
77 
85  return Collections.unmodifiableList(propertiesList);
86  }
87 
93  public Long getTimestamp() {
94  return timestamp;
95  }
96 
106  @Messages({
107  "Route_point_label=Waypoints for route"
108  })
109  private void createRoute(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
110  BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_WAYPOINTS);
111 
112  String label = getLabel();
113  if (label == null || label.isEmpty()) {
114  label = Bundle.Route_point_label();
115  } else {
116  label = String.format("%s: %s", Bundle.Route_point_label(), label);
117  }
118 
119  if (attribute != null) {
120  GeoWaypoints waypoints;
121  try {
122  waypoints = BlackboardJsonAttrUtil.fromAttribute(attribute, GeoWaypoints.class);
123  } catch (InvalidJsonException ex) {
124  throw new GeoLocationDataException(String.format("Unable to parse waypoints in TSK_GEO_WAYPOINTS attribute (artifact object ID =%d)", artifact.getId()), ex);
125  }
126  for (GeoWaypoints.Waypoint waypoint : waypoints) {
127  addToPath(new Waypoint(artifact, label, null, waypoint.getLatitude(), waypoint.getLongitude(), waypoint.getAltitude(), null, attributeMap, this));
128  }
129  } else {
130  Waypoint start = getRouteStartPoint(artifact, attributeMap);
131  Waypoint end = getRouteEndPoint(artifact, attributeMap);
132 
133  addToPath(start);
134  addToPath(end);
135  }
136  }
137 
150  @Messages({
151  "Route_Start_Label=Start"
152  })
153 
154  private Waypoint getRouteStartPoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
155  BlackboardAttribute latitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START);
156  BlackboardAttribute longitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_START);
157  BlackboardAttribute altitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE);
158 
159  if (latitude != null && longitude != null) {
160  return new RoutePoint(artifact,
161  Bundle.Route_Start_Label(),
162  latitude.getValueDouble(),
163  longitude.getValueDouble(),
164  altitude != null ? altitude.getValueDouble() : null,
165  attributeMap);
166  } else {
167  throw new GeoLocationDataException("Unable to create route start point, invalid longitude and/or latitude");
168  }
169  }
170 
183  @Messages({
184  "Route_End_Label=End"
185  })
186  private Waypoint getRouteEndPoint(BlackboardArtifact artifact, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
187  BlackboardAttribute latitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_END);
188  BlackboardAttribute longitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LONGITUDE_END);
189  BlackboardAttribute altitude = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_ALTITUDE);
190 
191  if (latitude != null && longitude != null) {
192 
193  return new RoutePoint(artifact,
194  Bundle.Route_End_Label(),
195  latitude.getValueDouble(),
196  longitude.getValueDouble(),
197  altitude != null ? altitude.getValueDouble() : null,
198  attributeMap);
199  } else {
200  throw new GeoLocationDataException("Unable to create route end point, invalid longitude and/or latitude");
201  }
202  }
203 
207  private class RoutePoint extends Waypoint {
208 
221  RoutePoint(BlackboardArtifact artifact, String label, Double latitude, Double longitude, Double altitude, Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) throws GeoLocationDataException {
222  super(artifact,
223  label,
224  null,
225  latitude,
226  longitude,
227  altitude,
228  null,
229  attributeMap,
230  Route.this);
231  }
232 
233  @Override
234  public Long getTimestamp() {
235  return ((Route) getParentGeoPath()).getTimestamp();
236  }
237  }
238 }
Waypoint getRouteEndPoint(BlackboardArtifact artifact, Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Route.java:186
final List< Waypoint.Property > propertiesList
Definition: Route.java:44
List< Waypoint.Property > getOtherProperties()
Definition: Route.java:84
void createRoute(BlackboardArtifact artifact, Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Route.java:109
Waypoint getRouteStartPoint(BlackboardArtifact artifact, Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
Definition: Route.java:154

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.