diff --git a/mapswipe_workers/mapswipe_workers/project_types/street/project.py b/mapswipe_workers/mapswipe_workers/project_types/street/project.py index e15f42c1..cc122c40 100644 --- a/mapswipe_workers/mapswipe_workers/project_types/street/project.py +++ b/mapswipe_workers/mapswipe_workers/project_types/street/project.py @@ -46,6 +46,7 @@ def __init__(self, project_draft): # TODO: validate inputs ImageMetadata = get_image_metadata( self.geometry, + creator_id=project_draft.get("creatorId", None), is_pano=project_draft.get("isPano", None), start_time=project_draft.get("startTimestamp", None), end_time=project_draft.get("endTimestamp", None), diff --git a/mapswipe_workers/mapswipe_workers/utils/process_mapillary.py b/mapswipe_workers/mapswipe_workers/utils/process_mapillary.py index 44357755..03f53670 100644 --- a/mapswipe_workers/mapswipe_workers/utils/process_mapillary.py +++ b/mapswipe_workers/mapswipe_workers/utils/process_mapillary.py @@ -184,12 +184,21 @@ def filter_by_timerange(df: pd.DataFrame, start_time: str, end_time: str = None) def filter_results( results_df: pd.DataFrame, + creator_id: int = None, is_pano: bool = None, organization_id: str = None, start_time: str = None, end_time: str = None, ): df = results_df.copy() + if creator_id is not None: + if df["creator_id"].isna().all(): + logger.exception( + "No Mapillary Feature in the AoI has a 'creator_id' value." + ) + return None + df = df[df["creator_id"] == creator_id] + if is_pano is not None: if df["is_pano"].isna().all(): logger.exception("No Mapillary Feature in the AoI has a 'is_pano' value.") @@ -220,6 +229,7 @@ def get_image_metadata( level=14, attempt_limit=3, is_pano: bool = None, + creator_id: int = None, organization_id: str = None, start_time: str = None, end_time: str = None, @@ -234,7 +244,7 @@ def get_image_metadata( ] downloaded_metadata = filter_results( - downloaded_metadata, is_pano, organization_id, start_time, end_time + downloaded_metadata, creator_id, is_pano, organization_id, start_time, end_time ) if sampling_threshold is not None: downloaded_metadata = spatial_sampling(downloaded_metadata, sampling_threshold) diff --git a/mapswipe_workers/tests/unittests/test_process_mapillary.py b/mapswipe_workers/tests/unittests/test_process_mapillary.py index 1913ccb4..32c1bad4 100644 --- a/mapswipe_workers/tests/unittests/test_process_mapillary.py +++ b/mapswipe_workers/tests/unittests/test_process_mapillary.py @@ -263,6 +263,10 @@ def test_filter_organization_id(self): filtered_df = filter_results(self.fixture_df, organization_id=1) self.assertEqual(len(filtered_df), 1) + def test_filter_creator_id(self): + filtered_df = filter_results(self.fixture_df, creator_id=102506575322825) + self.assertEqual(len(filtered_df), 3) + def test_filter_time_range(self): start_time = "2016-01-20 00:00:00" end_time = "2022-01-21 23:59:59"