Skip to content

Commit 775088f

Browse files
authored
Merge pull request #984 from mapswipe/feature/clip-street
feat: clip image locations to aoi
2 parents 6bc241a + 5ad603e commit 775088f

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

mapswipe_workers/mapswipe_workers/utils/process_mapillary.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,17 +134,15 @@ def coordinate_download(
134134
for col in target_columns:
135135
if col not in downloaded_metadata.columns:
136136
downloaded_metadata[col] = None
137-
138137
if (
139138
downloaded_metadata.isna().all().all() is False
140-
or downloaded_metadata.empty is True
139+
or downloaded_metadata.empty is False
141140
):
142141
downloaded_metadata = downloaded_metadata[
143142
downloaded_metadata["geometry"].apply(
144143
lambda point: point.within(polygon)
145144
)
146145
]
147-
148146
return downloaded_metadata
149147

150148

mapswipe_workers/tests/unittests/test_process_mapillary.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pandas as pd
77
from shapely import wkt
8-
from shapely.geometry import GeometryCollection, MultiPolygon, Polygon
8+
from shapely.geometry import GeometryCollection, MultiPolygon, Point, Polygon
99

1010
from mapswipe_workers.utils.process_mapillary import (
1111
coordinate_download,
@@ -191,10 +191,30 @@ def test_download_and_process_tile_failure(self, mock_get):
191191

192192
@patch("mapswipe_workers.utils.process_mapillary.download_and_process_tile")
193193
def test_coordinate_download(self, mock_download_and_process_tile):
194-
mock_download_and_process_tile.return_value = pd.DataFrame([{"geometry": None}])
194+
inside_points = [
195+
(0.2, 0.2),
196+
(0.5, 0.5),
197+
]
198+
outside_points = [
199+
(1.5, 0.5),
200+
(0.5, 1.5),
201+
(-0.5, 0.5),
202+
]
203+
points = inside_points + outside_points
204+
data = [
205+
{
206+
"geometry": Point(x, y),
207+
}
208+
for x, y in points
209+
]
210+
211+
mock_download_and_process_tile.return_value = pd.DataFrame(data)
195212

196213
metadata = coordinate_download(self.test_polygon, self.level)
197214

215+
metadata = metadata.drop_duplicates()
216+
self.assertEqual(len(metadata), len(inside_points))
217+
198218
self.assertIsInstance(metadata, pd.DataFrame)
199219

200220
@patch("mapswipe_workers.utils.process_mapillary.download_and_process_tile")

0 commit comments

Comments
 (0)