Skip to content

Commit a2e4efc

Browse files
authored
Merge pull request #94 from stac-utils/fix_intersection
Fix search request intersection, add test
2 parents 540f3d0 + 1ec0762 commit a2e4efc

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515

1616
### Fixed
1717

18+
- Fixed search intersects query
19+
1820
### Changed
1921

2022
- Elasticsearch index mappings updated to be more thorough.

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ async def post_search(
244244
search = self.database.apply_bbox_filter(search=search, bbox=bbox)
245245

246246
if search_request.intersects:
247-
self.database.apply_intersects_filter(
247+
search = self.database.apply_intersects_filter(
248248
search=search, intersects=search_request.intersects
249249
)
250250

stac_fastapi/elasticsearch/tests/api/test_api.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,21 @@ async def test_search_point_intersects(app_client, ctx):
201201
assert len(resp_json["features"]) == 1
202202

203203

204+
async def test_search_point_does_not_intersect(app_client, ctx):
205+
point = [15.04, -3.14]
206+
intersects = {"type": "Point", "coordinates": point}
207+
208+
params = {
209+
"intersects": intersects,
210+
"collections": [ctx.item["collection"]],
211+
}
212+
resp = await app_client.post("/search", json=params)
213+
214+
assert resp.status_code == 200
215+
resp_json = resp.json()
216+
assert len(resp_json["features"]) == 0
217+
218+
204219
async def test_datetime_non_interval(app_client, ctx):
205220
dt_formats = [
206221
"2020-02-12T12:30:22+00:00",

0 commit comments

Comments
 (0)