Skip to content

Commit

Permalink
fix: use clip of image locations to aoi
Browse files Browse the repository at this point in the history
  • Loading branch information
Gigaszi committed Dec 16, 2024
1 parent 994f398 commit 5ad603e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
4 changes: 1 addition & 3 deletions mapswipe_workers/mapswipe_workers/utils/process_mapillary.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,15 @@ def coordinate_download(
for col in target_columns:
if col not in downloaded_metadata.columns:
downloaded_metadata[col] = None

if (
downloaded_metadata.isna().all().all() is False
or downloaded_metadata.empty is True
or downloaded_metadata.empty is False
):
downloaded_metadata = downloaded_metadata[
downloaded_metadata["geometry"].apply(
lambda point: point.within(polygon)
)
]

return downloaded_metadata


Expand Down
24 changes: 22 additions & 2 deletions mapswipe_workers/tests/unittests/test_process_mapillary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pandas as pd
from shapely import wkt
from shapely.geometry import GeometryCollection, MultiPolygon, Polygon
from shapely.geometry import GeometryCollection, MultiPolygon, Point, Polygon

from mapswipe_workers.utils.process_mapillary import (
coordinate_download,
Expand Down Expand Up @@ -191,10 +191,30 @@ def test_download_and_process_tile_failure(self, mock_get):

@patch("mapswipe_workers.utils.process_mapillary.download_and_process_tile")
def test_coordinate_download(self, mock_download_and_process_tile):
mock_download_and_process_tile.return_value = pd.DataFrame([{"geometry": None}])
inside_points = [
(0.2, 0.2),
(0.5, 0.5),
]
outside_points = [
(1.5, 0.5),
(0.5, 1.5),
(-0.5, 0.5),
]
points = inside_points + outside_points
data = [
{
"geometry": Point(x, y),
}
for x, y in points
]

mock_download_and_process_tile.return_value = pd.DataFrame(data)

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

metadata = metadata.drop_duplicates()
self.assertEqual(len(metadata), len(inside_points))

self.assertIsInstance(metadata, pd.DataFrame)

@patch("mapswipe_workers.utils.process_mapillary.download_and_process_tile")
Expand Down

0 comments on commit 5ad603e

Please sign in to comment.