Skip to content

Commit

Permalink
feat(core)!: search optional count and return only SearchResult (#1200)
Browse files Browse the repository at this point in the history
Co-authored-by: Sylvain Brunato <[email protected]>
  • Loading branch information
dalpasso and sbrunato authored Jun 20, 2024
1 parent e577b27 commit 9c0d7e7
Show file tree
Hide file tree
Showing 42 changed files with 933 additions and 781 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Example usage for interacting with the api in your Python code:
dag = EODataAccessGateway()
search_results, total_count = dag.search(
search_results = dag.search(
productType='S2_MSI_L1C',
geom={'lonmin': 1, 'latmin': 43.5, 'lonmax': 2, 'latmax': 44}, # accepts WKT polygons, shapely.geometry, ...
start='2021-01-01',
Expand Down
4 changes: 2 additions & 2 deletions docs/_static/product_types_information.csv

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"image_light": "_static/eodag_logo_160.png",
"image_dark": "_static/eodag_logo_160r.png",
},
"show_toc_level": 2,
}

html_logo = "_static/eodag_logo_160.png"
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started_guide/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ This file can be used to download products with the API:
from eodag import EODataAccessGateway
dag = EODataAccessGateway()
products, total_count = dag.search(
products = dag.search(
productType="S2_MSI_L1C",
start="2018-01-01",
end="2018-01-31",
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ downloading *Sentinel 2 Level-1C* products from any provider's catalog is as sim
dag = EODataAccessGateway()
search_results, total_count = dag.search(
search_results = dag.search(
productType="S2_MSI_L1C",
start="2021-03-01",
end="2021-03-31",
Expand Down
26 changes: 16 additions & 10 deletions docs/notebooks/api_user_guide/1_overview.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,7 @@
"source": [
"The [EODataAccessGateway](../../api_reference/core.rst#eodag.api.core.EODataAccessGateway) class provides three search methods which have a similar signature but behave in different ways:\n",
"\n",
"[search()](../../api_reference/core.rst#eodag.api.core.EODataAccessGateway.search) returns a tuple with:\n",
"\n",
"* a [SearchResult](../../api_reference/searchresult.rst#eodag.api.search_result.SearchResult) that stores the products obtained from a given **page** (default: `page=1`) and a given maximum **number of items per page** (default: `items_per_page=20`)\n",
"* an integer that is the **estimated** total number of products matching the search criteria\n",
"[search()](../../api_reference/core.rst#eodag.api.core.EODataAccessGateway.search) returns a [SearchResult](../../api_reference/searchresult.rst#eodag.api.search_result.SearchResult) that stores the products obtained from a given **page** (default: `page=1`) and a given maximum **number of items per page** (default: `items_per_page=20`). The attribute [SearchResult.number_matched](../../api_reference/searchresult.rst#eodag.api.search_result.SearchResult) optionally stores the **estimated** total number of products matching the search criteria.\n",
"\n",
"<div class=\"alert alert-info\">\n",
"\n",
Expand All @@ -248,7 +245,7 @@
"\n",
"Warning\n",
"\n",
"The second element returned by [search()](../../api_reference/core.rst#eodag.api.core.EODataAccessGateway.search) is the **estimated** total number of products matching the search criteria, since, unfortunately, all the providers do not return the **exact** total number.\n",
"The [SearchResult.number_matched](../../api_reference/searchresult.rst#eodag.api.search_result.SearchResult) property is the **estimated** total number of products matching the search criteria, since, unfortunately, all the providers do not return the **exact** total number.\n",
"\n",
"</div>"
]
Expand Down Expand Up @@ -279,7 +276,8 @@
" \"productType\": \"S2_MSI_L1C\",\n",
" \"start\": \"2021-03-01\",\n",
" \"end\": \"2021-03-31\",\n",
" \"geom\": {\"lonmin\": 1, \"latmin\": 43, \"lonmax\": 2, \"latmax\": 44}\n",
" \"geom\": {\"lonmin\": 1, \"latmin\": 43, \"lonmax\": 2, \"latmax\": 44},\n",
" \"count\": True\n",
"}"
]
},
Expand All @@ -291,7 +289,8 @@
"\n",
"* `productType`: `eodag`'s product type\n",
"* `start` and `end`: the start and end sensing datetimes (UTC)\n",
"* `geom`: the region of interest, which can be defined in different ways (`list`, `dict`, WKT string, `shapely.geometry`)."
"* `geom`: the region of interest, which can be defined in different ways (`list`, `dict`, WKT string, `shapely.geometry`).\n",
"* `count`: whether to retrieve the estimated total number of results or not (default is `False`)"
]
},
{
Expand All @@ -310,7 +309,14 @@
}
],
"source": [
"products_first_page, estimated_total_number = dag.search(**search_criteria)"
"products_first_page = dag.search(**search_criteria)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The estimated total number of products matching the search criteria is stored in the `number_matched` attribute (set to `None` if `count` is disabled or not available)."
]
},
{
Expand All @@ -327,14 +333,14 @@
}
],
"source": [
"print(f\"Got {len(products_first_page)} products and an estimated total number of {estimated_total_number} products.\")"
"print(f\"Got {len(products_first_page)} products and an estimated total number of {products_first_page.number_matched} products.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A [SearchResult](../../api_reference/searchresult.rst#eodag.api.search_result.SearchResult) contains a number of [EOProduct](../../api_reference/eoproduct.rst#eodag.api.product._product.EOProduct). Each one of them has a `properties` attribute that is a dictionnary storing the product's metadata."
"A [SearchResult](../../api_reference/searchresult.rst#eodag.api.search_result.SearchResult) contains a number of [EOProduct](../../api_reference/eoproduct.rst#eodag.api.product._product.EOProduct). Each one of them has a `properties` attribute that is a dictionary storing the product's metadata."
]
},
{
Expand Down
Loading

0 comments on commit 9c0d7e7

Please sign in to comment.