19 package org.sleuthkit.autopsy.datasourcesummary.datamodel;
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.Collections;
25 import java.util.HashMap;
26 import java.util.List;
29 import java.util.concurrent.ArrayBlockingQueue;
30 import java.util.concurrent.BlockingQueue;
31 import java.util.stream.Collectors;
32 import java.util.stream.Stream;
33 import org.apache.commons.lang3.tuple.Pair;
43 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
139 private final List<CityRecordCount>
counts;
151 this.counts = Collections.unmodifiableList(
new ArrayList<>(counts));
173 @SuppressWarnings(
"deprecation")
175 BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_BOOKMARK,
176 BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_LAST_KNOWN_LOCATION,
177 BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE,
178 BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_SEARCH,
179 BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACK,
180 BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT,
181 BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF
186 .map(artifactType -> artifactType.getTypeID())
187 .collect(Collectors.toSet());
252 if (minTime != null && time != null && time >= minTime) {
259 private static final Pair<Integer, Integer>
EMPTY_COUNT = Pair.of(0, 0);
271 private Pair<Integer, Integer>
getCounts(List<MapWaypoint> points, Long minTime) {
273 if (points == null) {
277 return points.stream().reduce(
279 (total, w) -> Pair.of(total.getLeft() + 1, total.getRight() + (
greaterThanOrEqual(minTime, w.getTimestamp()) ? 1 : 0)),
280 (pair1, pair2) -> Pair.of(pair1.getLeft() + pair2.getLeft(), pair1.getRight() + pair2.getRight()));
303 ClosestCityMapper closestCityMapper = ClosestCityMapper.getInstance();
305 List<MapWaypoint> dataSourcePoints =
getPoints(dataSource);
307 Map<CityRecord, List<MapWaypoint>> allCityPoints =
new HashMap<>();
308 List<MapWaypoint> others =
new ArrayList<>();
309 Long mostRecent = null;
312 CityRecord city = closestCityMapper.findClosest(
new CityRecord(null, null, null, pt.getX(), pt.getY()));
313 Long curTime = pt.getTimestamp();
314 if (curTime != null && (mostRecent == null || curTime > mostRecent)) {
315 mostRecent = curTime;
321 List<MapWaypoint> cityPoints = allCityPoints.get(city);
322 if (cityPoints == null) {
323 cityPoints =
new ArrayList<>();
324 allCityPoints.put(city, cityPoints);
331 final Long mostRecentMinTime = (mostRecent == null) ? null : mostRecent - daysCount * DAY_SECS;
334 Map<CityRecord, Pair<Integer, Integer>> allCityCounts = allCityPoints.entrySet().stream()
335 .collect(Collectors.toMap((e) -> e.getKey(), (e) ->
getCounts(e.getValue(), mostRecentMinTime)));
337 List<CityRecordCount> mostCommonCounts = allCityCounts.entrySet().stream()
339 .sorted((a, b) -> -Integer.compare(a.getCount(), b.getCount()))
341 .collect(Collectors.toList());
343 List<CityRecordCount> mostRecentCounts = allCityCounts.entrySet().stream()
345 .sorted((a, b) -> -Integer.compare(a.getCount(), b.getCount()))
347 .collect(Collectors.toList());
349 Pair<Integer, Integer> otherCounts =
getCounts(others, mostRecentMinTime);
350 int otherMostCommonCount = otherCounts.getLeft();
351 int otherMostRecentCount = otherCounts.getRight();
380 public void handleFilteredWaypointSet(Set<MapWaypoint> mapWaypoints, List<Set<MapWaypoint>> tracks, List<Set<MapWaypoint>> areas,
boolean wasEntirelySuccessful) {
381 Stream<List<Set<MapWaypoint>>> stream = Stream.of(
382 Arrays.asList(mapWaypoints),
383 tracks == null ? Collections.emptyList() : tracks,
384 areas == null ? Collections.emptyList() : areas);
386 List<MapWaypoint> wayPoints = stream
387 .flatMap((List<Set<MapWaypoint>> list) -> list.stream())
388 .flatMap((Set<MapWaypoint> set) -> set.stream())
389 .collect(Collectors.toList());
393 asyncResult.put(wayPoints);
394 }
catch (InterruptedException ignored) {
409 private List<MapWaypoint>
getPoints(DataSource dataSource)
throws SleuthkitCaseProviderException, GeoLocationDataException, InterruptedException {
412 final BlockingQueue<List<MapWaypoint>> asyncResult =
new ArrayBlockingQueue<>(1);
417 Arrays.asList(dataSource),
424 return asyncResult.take();
List< MapWaypoint > getPoints(DataSource dataSource)
SleuthkitCaseProvider DEFAULT
CityCountsList getMostRecent()
static final Set< Integer > GPS_ARTIFACT_TYPE_IDS
final java.util.logging.Logger logger
final BlockingQueue< List< MapWaypoint > > asyncResult
static final long DAY_SECS
Set< Integer > getArtifactTypeIdsForRefresh()
final CityCountsList mostRecent
CityData getCityCounts(DataSource dataSource, int daysCount, int maxCount)
static final Pair< Integer, Integer > EMPTY_COUNT
final CityCountsList mostCommon
boolean greaterThanOrEqual(Long minTime, Long time)
final CityRecord cityRecord
static List< Waypoint > getAllWaypoints(SleuthkitCase skCase)
List< ARTIFACT_TYPE > getGeoTypes()
final List< CityRecordCount > counts
static final List< ARTIFACT_TYPE > GPS_ARTIFACT_TYPES
final SupplierWithException< ClosestCityMapper, IOException > cityMapper
final SleuthkitCaseProvider provider
synchronized static Logger getLogger(String name)
final Long mostRecentSeen
PointFetcher(BlockingQueue< List< MapWaypoint >> asyncResult, GeoFilter filters)
Pair< Integer, Integer > getCounts(List< MapWaypoint > points, Long minTime)
CityRecord getCityRecord()
List< CityRecordCount > getCounts()
CityCountsList getMostCommon()
GeolocationSummary(SupplierWithException< ClosestCityMapper, IOException > cityMapper, SleuthkitCaseProvider provider, java.util.logging.Logger logger)
void handleFilteredWaypointSet(Set< MapWaypoint > mapWaypoints, List< Set< MapWaypoint >> tracks, List< Set< MapWaypoint >> areas, boolean wasEntirelySuccessful)