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 java.util.logging.Level;
26 import org.openide.util.NbBundle.Messages;
29 import org.
sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil;
30 import org.
sleuthkit.datamodel.blackboardutils.attributes.BlackboardJsonAttrUtil.InvalidJsonException;
31 import org.
sleuthkit.datamodel.blackboardutils.attributes.GeoTrackPoints;
33
39
42
52 }
53
64
67
68 startTimestamp = points.getStartTime();
69 endTimeStamp = points.getEndTime();
70 }
71
80 }
81
90 }
91
100 private static String
getTrackName(Map<BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute> attributeMap) {
101 BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME);
102
103 return attribute != null ? attribute.getValueString() : "";
104 }
105
114 @Messages({
115 "# {0} - track name",
116 "GEOTrack_point_label_header=Trackpoint for track: {0}"
117 })
119 for (GeoTrackPoints.TrackPoint point : points) {
120 addToPath(
new TrackWaypoint(artifact, Bundle.GEOTrack_point_label_header(
getLabel()), point));
121 }
122 }
123
135 BlackboardAttribute attribute = attributeMap.get(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_TRACKPOINTS);
136 if (attribute == null) {
137 LOGGER.log(Level.SEVERE, "No TSK_GEO_TRACKPOINTS attribute was present on the artifact.");
139 }
140
141 try {
142 return BlackboardJsonAttrUtil.fromAttribute(attribute, GeoTrackPoints.class);
143 } catch (InvalidJsonException ex) {
144 LOGGER.log(Level.SEVERE, "TSK_GEO_TRACKPOINTS could not be properly parsed from TSK_GEO_TRACKPOINTS attribute.");
146 }
147 }
148
152 final class TrackWaypoint
extends Waypoint {
153
155
167 TrackWaypoint(BlackboardArtifact artifact, String pointLabel, GeoTrackPoints.TrackPoint point) throws
GeoLocationDataException {
168 super(artifact, pointLabel,
169 point.getTimeStamp(),
170 point.getLatitude(),
171 point.getLongitude(),
172 point.getAltitude(),
173 null,
174 null,
176
177 propertyList = createPropertyList(point);
178 }
179
186 @Override
188 return Collections.unmodifiableList(propertyList);
189 }
190
198 @Messages({
199 "Track_distanceTraveled_displayName=Distance traveled",
200 "Track_distanceFromHome_displayName=Distance from home point"
201 })
202 private List<Waypoint.Property> createPropertyList(GeoTrackPoints.TrackPoint point) {
203 List<Waypoint.Property> list = new ArrayList<>();
204
205 Long timestamp = point.getTimeStamp();
206 if (timestamp != null) {
207 list.add(new Property(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getDisplayName(), timestamp.toString()));
208 }
209
210 Double value = point.getVelocity();
211 if (value != null) {
212 list.add(new Property(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_VELOCITY.getDisplayName(), value.toString()));
213 }
214
215 value = point.getDistanceTraveled();
216 if (value != null) {
217 list.add(new Property(Bundle.Track_distanceTraveled_displayName(), value.toString()));
218 }
219
220 value = point.getDistanceFromHomePoint();
221 if (value != null) {
222 list.add(new Property(Bundle.Track_distanceFromHome_displayName(), value.toString()));
223 }
224
225 return list;
226 }
227 }
228 }
Track(BlackboardArtifact artifact)
Track(BlackboardArtifact artifact, Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
final BlackboardArtifact artifact
final Long startTimestamp
static final Logger LOGGER
GeoTrackPoints getPointsList(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
static String getTrackName(Map< BlackboardAttribute.ATTRIBUTE_TYPE, BlackboardAttribute > attributeMap)
synchronized static Logger getLogger(String name)
void buildPath(GeoTrackPoints points, BlackboardArtifact artifact)