Skip to content

Commit 916d4f7

Browse files
committed
feat: drop duplicated images at exact same location
1 parent 4d7790b commit 916d4f7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

mapswipe_workers/mapswipe_workers/utils/process_mapillary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def get_image_metadata(
227227
raise ValueError(
228228
"No Mapillary Features in the AoI or no Features match the filter criteria."
229229
)
230-
230+
downloaded_metadata = downloaded_metadata.drop_duplicates(subset=["geometry"])
231231
if sampling_threshold is not None:
232232
downloaded_metadata = spatial_sampling(downloaded_metadata, sampling_threshold)
233233

mapswipe_workers/tests/unittests/test_process_mapillary.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,28 @@ def test_get_image_metadata_empty_response(self, mock_coordinate_download):
314314

315315
@patch("mapswipe_workers.utils.process_mapillary.coordinate_download")
316316
def test_get_image_metadata_size_restriction(self, mock_coordinate_download):
317-
mock_coordinate_download.return_value = pd.DataFrame({"ID": range(1, 100002)})
317+
mock_coordinate_download.return_value = pd.DataFrame(
318+
{"geometry": range(1, 100002)}
319+
)
318320

319321
with self.assertRaises(ValueError):
320322
get_image_metadata(self.fixture_data)
321323

324+
@patch("mapswipe_workers.utils.process_mapillary.coordinate_download")
325+
def test_get_image_metadata_drop_duplicates(self, mock_coordinate_download):
326+
test_df = pd.DataFrame(
327+
{
328+
"id": [1, 2, 2, 3, 4, 4, 5],
329+
"geometry": ["a", "b", "b", "c", "d", "d", "e"],
330+
}
331+
)
332+
mock_coordinate_download.return_value = test_df
333+
return_dict = get_image_metadata(self.fixture_data)
334+
335+
return_df = pd.DataFrame(return_dict)
336+
337+
self.assertNotEqual(len(return_df), len(test_df))
338+
322339

323340
if __name__ == "__main__":
324341
unittest.main()

0 commit comments

Comments
 (0)