Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
12 changes: 11 additions & 1 deletion mapswipe_workers/mapswipe_workers/utils/process_mapillary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions mapswipe_workers/tests/unittests/test_process_mapillary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading