Skip to content

Commit c3b58aa

Browse files
authored
Merge pull request #985 from mapswipe/street-project-creator-id
feat: add filter by creator_id
2 parents 775088f + fb6610e commit c3b58aa

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

mapswipe_workers/mapswipe_workers/project_types/street/project.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(self, project_draft):
4646
# TODO: validate inputs
4747
ImageMetadata = get_image_metadata(
4848
self.geometry,
49+
creator_id=project_draft.get("creatorId", None),
4950
is_pano=project_draft.get("isPano", None),
5051
start_time=project_draft.get("startTimestamp", None),
5152
end_time=project_draft.get("endTimestamp", None),

mapswipe_workers/mapswipe_workers/utils/process_mapillary.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,21 @@ def filter_by_timerange(df: pd.DataFrame, start_time: str, end_time: str = None)
184184

185185
def filter_results(
186186
results_df: pd.DataFrame,
187+
creator_id: int = None,
187188
is_pano: bool = None,
188189
organization_id: str = None,
189190
start_time: str = None,
190191
end_time: str = None,
191192
):
192193
df = results_df.copy()
194+
if creator_id is not None:
195+
if df["creator_id"].isna().all():
196+
logger.exception(
197+
"No Mapillary Feature in the AoI has a 'creator_id' value."
198+
)
199+
return None
200+
df = df[df["creator_id"] == creator_id]
201+
193202
if is_pano is not None:
194203
if df["is_pano"].isna().all():
195204
logger.exception("No Mapillary Feature in the AoI has a 'is_pano' value.")
@@ -220,6 +229,7 @@ def get_image_metadata(
220229
level=14,
221230
attempt_limit=3,
222231
is_pano: bool = None,
232+
creator_id: int = None,
223233
organization_id: str = None,
224234
start_time: str = None,
225235
end_time: str = None,
@@ -234,7 +244,7 @@ def get_image_metadata(
234244
]
235245

236246
downloaded_metadata = filter_results(
237-
downloaded_metadata, is_pano, organization_id, start_time, end_time
247+
downloaded_metadata, creator_id, is_pano, organization_id, start_time, end_time
238248
)
239249
if sampling_threshold is not None:
240250
downloaded_metadata = spatial_sampling(downloaded_metadata, sampling_threshold)

mapswipe_workers/tests/unittests/test_process_mapillary.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ def test_filter_organization_id(self):
263263
filtered_df = filter_results(self.fixture_df, organization_id=1)
264264
self.assertEqual(len(filtered_df), 1)
265265

266+
def test_filter_creator_id(self):
267+
filtered_df = filter_results(self.fixture_df, creator_id=102506575322825)
268+
self.assertEqual(len(filtered_df), 3)
269+
266270
def test_filter_time_range(self):
267271
start_time = "2016-01-20 00:00:00"
268272
end_time = "2022-01-21 23:59:59"

0 commit comments

Comments
 (0)