def test_sparse_trajectory(self): df = DataFrame([ { "id": 1, "geometry": Point(0, 0), "t": datetime(2018, 1, 1, 12, 0, 0) }, { "id": 1, "geometry": Point(6, 0), "t": datetime(2018, 1, 1, 12, 6, 0) }, { "id": 1, "geometry": Point(6, 6), "t": datetime(2018, 1, 1, 14, 9, 0) }, ]).set_index("t") geo_df = GeoDataFrame(df, crs=CRS_METRIC) traj = Trajectory(geo_df, "id") extractor = _PtsExtractor(traj, 5, 0, min_stop_duration=timedelta(hours=12)) actual = extractor.find_significant_points() expected = [Point(0, 0), Point(6, 0), Point(6, 6)] assert len(actual) == len(expected) for pt in expected: assert pt in actual
def test_sparse_trajectory(self): df = pd.DataFrame([{ 'id': 1, 'geometry': Point(0, 0), 't': datetime(2018, 1, 1, 12, 0, 0) }, { 'id': 1, 'geometry': Point(6, 0), 't': datetime(2018, 1, 1, 12, 6, 0) }, { 'id': 1, 'geometry': Point(6, 6), 't': datetime(2018, 1, 1, 14, 10, 0) }]).set_index('t') geo_df = GeoDataFrame(df, crs=CRS_METRIC) traj = Trajectory(geo_df, 'id') extractor = _PtsExtractor(traj, 5, 0, min_stop_duration=timedelta(hours=12)) actual = extractor.find_significant_points() expected = [Point(0, 0), Point(6, 0), Point(6, 6)] assert len(actual) == len(expected) for pt in expected: assert pt in actual
def test_stops_found(self): df = DataFrame([ { "id": 1, "geometry": Point(0, 0), "t": datetime(2018, 1, 1, 10, 0, 0) }, { "id": 1, "geometry": Point(1, 0), "t": datetime(2018, 1, 1, 10, 1, 0) }, { "id": 1, "geometry": Point(2, 0), "t": datetime(2018, 1, 1, 10, 2, 0) }, { "id": 1, "geometry": Point(3, 0), "t": datetime(2018, 1, 1, 12, 3, 0) }, { "id": 1, "geometry": Point(4, 0), "t": datetime(2018, 1, 1, 12, 4, 0) }, { "id": 1, "geometry": Point(5, 0), "t": datetime(2018, 1, 1, 12, 5, 0) }, { "id": 1, "geometry": Point(6, 0), "t": datetime(2018, 1, 1, 14, 6, 0) }, { "id": 1, "geometry": Point(7, 0), "t": datetime(2018, 1, 1, 14, 7, 0) }, ]).set_index("t") geo_df = GeoDataFrame(df, crs=CRS_METRIC) traj = Trajectory(geo_df, "id") extractor = _PtsExtractor(traj, 10, 2, min_stop_duration=timedelta(hours=1)) actual = extractor.find_significant_points() for pt in actual: print(pt) expected = [Point(0, 0), Point(2, 0), Point(5, 0), Point(7, 0)] assert len(actual) == len(expected) for pt in expected: assert pt in actual