Sleuth Kit Java Bindings (JNI)  4.12.1
Java bindings for using The Sleuth Kit
GeoTrackPoints.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
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.datamodel.blackboardutils.attributes;
20 
21 import com.google.gson.annotations.SerializedName;
22 import java.util.ArrayList;
23 import java.util.Iterator;
24 import java.util.List;
25 import java.util.stream.Collectors;
26 
38 public class GeoTrackPoints implements Iterable<GeoTrackPoints.TrackPoint> {
39 
40  private final List<TrackPoint> pointList;
41 
45  public GeoTrackPoints() {
46  pointList = new ArrayList<>();
47  }
48 
54  public void addPoint(TrackPoint trackPoint) {
55  if (trackPoint == null) {
56  throw new IllegalArgumentException("addPoint was passed a null track point");
57  }
58 
59  pointList.add(trackPoint);
60  }
61 
62  @Override
63  public Iterator<TrackPoint> iterator() {
64  return pointList.iterator();
65  }
66 
72  public boolean isEmpty() {
73  return pointList.isEmpty();
74  }
75 
83  public Long getStartTime() {
84  List<TrackPoint> orderedPoints = getTimeOrderedPoints();
85  if (orderedPoints != null) {
86  for (TrackPoint point : orderedPoints) {
87  if (point.getTimeStamp() != null) {
88  return point.getTimeStamp();
89  }
90  }
91  }
92  return null;
93  }
94 
102  public Long getEndTime() {
103  List<TrackPoint> orderedPoints = getTimeOrderedPoints();
104  if (orderedPoints != null) {
105  for (int index = orderedPoints.size() - 1; index >= 0; index--) {
106  TrackPoint point = orderedPoints.get(index);
107  if (point.getTimeStamp() != null) {
108  return point.getTimeStamp();
109  }
110  }
111  }
112  return null;
113  }
114 
121  private List<TrackPoint> getTimeOrderedPoints() {
122  return pointList.stream().sorted().collect(Collectors.toCollection(ArrayList::new));
123  }
124 
129  public final static class TrackPoint extends GeoWaypoints.Waypoint implements Comparable<TrackPoint> {
130 
131  @SerializedName("TSK_GEO_VELOCITY")
132  private final Double velocity;
133  @SerializedName("TSK_DISTANCE_FROM_HOMEPOINT")
134  private final Double distanceFromHomePoint;
135  @SerializedName("TSK_DISTANCE_TRAVELED")
136  private final Double distanceTraveled;
137  @SerializedName("TSK_DATETIME")
138  private final Long timestamp;
139 
163  public TrackPoint(Double latitude,
164  Double longitude,
165  Double altitude,
166  String name,
167  Double velocity,
168  Double distanceFromHomePoint,
169  Double distanceTraveled,
170  Long timestamp) {
171  super(latitude, longitude, altitude, name);
172  this.velocity = velocity;
173  this.distanceFromHomePoint = distanceFromHomePoint;
174  this.distanceTraveled = distanceTraveled;
175  this.timestamp = timestamp;
176  }
177 
184  public Double getVelocity() {
185  return velocity;
186  }
187 
194  public Double getDistanceFromHomePoint() {
195  return distanceFromHomePoint;
196  }
197 
204  public Double getDistanceTraveled() {
205  return distanceTraveled;
206  }
207 
214  public Long getTimeStamp() {
215  return timestamp;
216  }
217 
218  @Override
219  public int compareTo(TrackPoint otherTP) {
220  Long otherTimeStamp = otherTP.getTimeStamp();
221 
222  if (timestamp == null) {
223  if (otherTimeStamp != null) {
224  return -1;
225  } else {
226  return 0;
227  }
228  } else if (timestamp != null && otherTimeStamp == null) {
229  return 1;
230  } else {
231  return timestamp.compareTo(otherTP.getTimeStamp());
232  }
233  }
234  }
235 
236 }
TrackPoint(Double latitude, Double longitude, Double altitude, String name, Double velocity, Double distanceFromHomePoint, Double distanceTraveled, Long timestamp)

Copyright © 2011-2021 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.