Skip to content

Commit 5d71684

Browse files
authored
Merge pull request #160 from stac-utils/get-intersection
Enable GET /search intersection
2 parents 23dca8a + 5652fe8 commit 5d71684

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
### Added
1111

1212
- Collection-level Assets to the CollectionSerializer [#148](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/148)
13-
14-
### Added
15-
1613
- Examples folder with example docker setup for running sfes from pip [#147](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/147)
14+
- Added support for GET /search intersection queries [#158](https://github.com/stac-utils/stac-fastapi-elasticsearch/issues/158)
1715

1816
### Changed
1917

18+
- Updated core stac-fastapi libraries to 2.4.8 from 2.4.3 [#151](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/151)
2019
- Use aliases on Elasticsearch indices, add number suffix in index name. [#152](https://github.com/stac-utils/stac-fastapi-elasticsearch/pull/152)
2120

2221
### Fixed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from datetime import datetime as datetime_type
55
from datetime import timezone
66
from typing import Any, Dict, List, Optional, Set, Type, Union
7-
from urllib.parse import urljoin
7+
from urllib.parse import unquote_plus, urljoin
88

99
import attr
1010
import stac_pydantic
@@ -325,7 +325,7 @@ async def get_search(
325325
base_args["datetime"] = datetime
326326

327327
if intersects:
328-
base_args["intersects"] = intersects
328+
base_args["intersects"] = json.loads(unquote_plus(intersects))
329329

330330
if sortby:
331331
# https://github.com/radiantearth/stac-spec/tree/master/api-spec/extensions/sort#http-get-or-post-form

stac_fastapi/elasticsearch/tests/api/test_api.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import uuid
33
from datetime import datetime, timedelta
44

5+
import pytest
6+
57
from ..conftest import create_collection, create_item
68

79
ROUTES = {
@@ -233,7 +235,29 @@ async def test_search_invalid_date(app_client, ctx):
233235
assert resp.status_code == 400
234236

235237

236-
async def test_search_point_intersects(app_client, ctx):
238+
@pytest.mark.asyncio
239+
async def test_search_point_intersects_get(app_client, ctx):
240+
resp = await app_client.get(
241+
'/search?intersects={"type":"Point","coordinates":[150.04,-33.14]}'
242+
)
243+
244+
assert resp.status_code == 200
245+
resp_json = resp.json()
246+
assert len(resp_json["features"]) == 1
247+
248+
249+
@pytest.mark.asyncio
250+
async def test_search_polygon_intersects_get(app_client, ctx):
251+
resp = await app_client.get(
252+
'/search?intersects={"type":"Polygon","coordinates":[[[149.04, -34.14],[149.04, -32.14],[151.04, -32.14],[151.04, -34.14],[149.04, -34.14]]]}'
253+
)
254+
255+
assert resp.status_code == 200
256+
resp_json = resp.json()
257+
assert len(resp_json["features"]) == 1
258+
259+
260+
async def test_search_point_intersects_post(app_client, ctx):
237261
point = [150.04, -33.14]
238262
intersects = {"type": "Point", "coordinates": point}
239263

0 commit comments

Comments
 (0)