Skip to content

Commit

Permalink
Deleted StacApi (#162)
Browse files Browse the repository at this point in the history
* deleted stacapi_io.py, stacapi.py, test_stacapi.py and references in data.py

* deleted test_init_stac_url

* some minor adjustments

* removed all stac_api references

* removed all stac_api references (formated)

* minor adjustments

Co-authored-by: Maxi Lehner <github@maxliehner.de>
  • Loading branch information
Zajquor and Maxi Lehner authored Jan 12, 2022
1 parent 93eda05 commit 88ffe16
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 225 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
Changelog
=========
[] ()
---------------------
Deleted
^^^^^
- removed own stac api client (pystac-client should be used from now on)
- deleted the StacApi reference in data.py

[1.3.4] (2022-01-11)
---------------------
Added
Expand Down
6 changes: 1 addition & 5 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,9 @@ def test_init_stac_catalog(self):
with Source(datahub=Datahub.STAC_local, catalog=catalog_path) as src:
self.assertTrue(isinstance(src.api, pystac.catalog.Catalog))

def test_init_stac_url(self):
with Source(datahub=Datahub.STAC_API, url=r"https://earth-search.aws.element84.com/v0/") as src:
self.assertEqual(src.api.url, r"https://earth-search.aws.element84.com/v0/")

def test_init_exception_other_hub(self):
with self.assertRaises(
NotImplementedError, msg=f"Hub is not supported [STAC_local, STAC_API, EarthExplorer, " f"Scihub]."
NotImplementedError, msg=f"Hub is not supported [STAC_local, EarthExplorer, " f"Scihub]."
):
Source(datahub="Hub")

Expand Down
69 changes: 0 additions & 69 deletions tests/test_stacapi.py

This file was deleted.

33 changes: 6 additions & 27 deletions ukis_pysat/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dateutil.parser import parse

from ukis_pysat._landsat import Product
from ukis_pysat.stacapi import StacApi


try:
import numpy as np
Expand Down Expand Up @@ -39,17 +39,14 @@ class Source:
Remote APIs and local data directories that hold metadata files are supported.
"""

def __init__(self, datahub, catalog=None, url=None):
def __init__(self, datahub, catalog=None):
"""
:param datahub: Data source (<enum 'Datahub'>).
:param catalog: Only applicable if datahub is 'STAC_local'. Can be one of the following types:
Path to STAC Catalog file catalog.json (String, Path).
Pystac Catalog or Collection object (pystac.catalog.Catalog, pystac.collection.Collection).
None initializes an empty catalog.
(default: None)
:param url: Only applicable if datahub is 'STAC_API'. STAC Server endpoint, reads from STAC_API_URL environment
variable by default
(default: None)
"""
self.src = datahub

Expand All @@ -68,12 +65,6 @@ def __init__(self, datahub, catalog=None, url=None):
f"pystac.collection.Collection, None] "
)

elif self.src == Datahub.STAC_API:
if url:
self.api = StacApi(url=url)
else:
self.api = StacApi()

elif self.src == Datahub.EarthExplorer:
import landsatxplore.api

Expand All @@ -94,7 +85,7 @@ def __init__(self, datahub, catalog=None, url=None):
)

else:
raise NotImplementedError(f"{datahub} is not supported [STAC_local, STAC_API, EarthExplorer, Scihub]")
raise NotImplementedError(f"{datahub} is not supported [STAC_local, EarthExplorer, Scihub]")

def __enter__(self):
return self
Expand Down Expand Up @@ -154,9 +145,6 @@ def query_metadata(self, platform, date, aoi, cloud_cover=None, kwargs=None):
):
yield item

elif self.src == Datahub.STAC_API:
raise NotImplementedError(f"Do this directly with the pystac-client functionalities.")

elif self.src == Datahub.EarthExplorer:
# query EarthExplorer for metadata
bbox = self._prep_aoi(aoi).bounds
Expand Down Expand Up @@ -201,9 +189,6 @@ def query_metadata_srcid(self, platform, srcid):
if item.id == srcid:
yield item

elif self.src == Datahub.STAC_API:
raise NotImplementedError(f"Do this directly with the pystac-client functionalities.")

elif self.src == Datahub.EarthExplorer:
from landsatxplore.util import guess_dataset

Expand All @@ -222,7 +207,7 @@ def construct_metadata(self, meta, platform):
:param platform: Image platform (<enum 'Platform'>).
:returns: PySTAC item
"""
if self.src == Datahub.STAC_local or self.src == Datahub.STAC_API:
if self.src == Datahub.STAC_local:
raise NotImplementedError(f"construct_metadata not supported for {self.src}.")

elif self.src == Datahub.EarthExplorer:
Expand Down Expand Up @@ -327,7 +312,7 @@ def download_image(self, product_uuid, target_dir):
if isinstance(target_dir, str):
target_dir = Path(target_dir)

if self.src == Datahub.STAC_local or self.src == Datahub.STAC_API:
if self.src == Datahub.STAC_local:
raise NotImplementedError(
f"download_image not supported for {self.src}. It is much easier to get the asset yourself now."
)
Expand Down Expand Up @@ -360,13 +345,7 @@ def download_quicklook(self, product_uuid, target_dir):
if isinstance(target_dir, str):
target_dir = Path(target_dir)

if self.src == Datahub.STAC_local or self.src == Datahub.STAC_API:
raise NotImplementedError(
f"download_quicklook not supported for {self.src}. It is much easier to get the asset yourself now, "
f"when it is a COG you can read in an overview."
)

elif self.src == Datahub.EarthExplorer:
if self.src == Datahub.EarthExplorer:
product_srcid, meta_src = self._get_srcid_from_product_uuid_ee(product_uuid)
url = meta_src[0]["browseUrl"]
bounds = geometry.shape(meta_src[0]["spatialFootprint"]).bounds
Expand Down
1 change: 0 additions & 1 deletion ukis_pysat/members.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Datahub(Enum):
STAC_local = "STAC Catalog/Collection"
EarthExplorer = "EarthExplorer"
Scihub = "Scihub"
STAC_API = "STAC API"


class Bands(BaseModel):
Expand Down
103 changes: 0 additions & 103 deletions ukis_pysat/stacapi.py

This file was deleted.

20 changes: 0 additions & 20 deletions ukis_pysat/stacapi_io.py

This file was deleted.

0 comments on commit 88ffe16

Please sign in to comment.