Skip to content

Commit 3bdc562

Browse files
committed
feat: images are in sequential order if randomizeOrder is false or none
1 parent 8b37284 commit 3bdc562

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

mapswipe_workers/mapswipe_workers/utils/process_mapillary.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ def get_image_metadata(
262262
):
263263
raise ValueError("No Mapillary Features in the AoI match the filter criteria.")
264264

265-
if sampling_threshold is not None:
266-
downloaded_metadata = spatial_sampling(downloaded_metadata, sampling_threshold)
265+
downloaded_metadata = spatial_sampling(downloaded_metadata, sampling_threshold)
267266

268267
if randomize_order is True:
269268
downloaded_metadata = downloaded_metadata.sample(frac=1).reset_index(drop=True)

mapswipe_workers/mapswipe_workers/utils/spatial_sampling.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,9 @@ def spatial_sampling(df, interval_length):
141141
for sequence in sorted_df["sequence_id"].unique():
142142
sequence_df = sorted_df[sorted_df["sequence_id"] == sequence]
143143

144-
filtered_sorted_sub_df = filter_points(sequence_df, interval_length)
145-
sampled_sequence_df = pd.concat(
146-
[sampled_sequence_df, filtered_sorted_sub_df], axis=0
147-
)
144+
if interval_length:
145+
sequence_df = filter_points(sequence_df, interval_length)
146+
sampled_sequence_df = pd.concat([sampled_sequence_df, sequence_df], axis=0)
148147

149148
# reverse order such that sequence are in direction of travel
150149
sampled_sequence_df = sampled_sequence_df.iloc[::-1]

mapswipe_workers/tests/unittests/test_process_mapillary.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,11 @@ def test_get_image_metadata_empty_response(self, mock_coordinate_download):
343343
def test_get_image_metadata_size_restriction(
344344
self, mock_coordinate_download, mock_filter_results
345345
):
346-
mock_filter_results.return_value = pd.DataFrame({"ID": range(1, 100002)})
346+
mock_df = pd.DataFrame({"ID": range(1, 100002)})
347+
mock_df["geometry"] = self.test_polygon
348+
mock_df["captured_at"] = range(1, 100002)
349+
mock_df["sequence_id"] = 1
350+
mock_filter_results.return_value = mock_df
347351
mock_coordinate_download.return_value = self.fixture_df
348352

349353
with self.assertRaises(ValueError):

0 commit comments

Comments
 (0)