@@ -35,29 +35,55 @@ def __init__(self, api_url: str):
3535
3636 def get_collection_items (self , collection_id : str ) -> list [dict [str , Any ]]:
3737 """
38- Get all items from a collection.
38+ Get all items from a collection by directly querying the STAC /search endpoint .
3939
4040 Args:
4141 collection_id: ID of the collection
4242
4343 Returns:
44- List of item dictionaries
44+ List of item dictionaries (with at least 'id')
4545 """
46+ import traceback
47+
4648 click .echo (f"Fetching items from collection: { collection_id } " )
4749 items = []
50+ error_count = 0
4851
4952 try :
50- catalog = Client .open (self .api_url )
51- search = catalog .search (collections = [collection_id ], max_items = None )
52-
53- for item in search .items ():
54- items .append (item .to_dict ())
53+ # Use POST /search endpoint directly
54+ url = f"{ self .api_url } /search"
55+ params = {
56+ "collections" : [collection_id ],
57+ "limit" : 10000 , # adjust as needed for your server's max page size
58+ }
59+ response = self .session .post (url , json = params , timeout = 60 )
60+ response .raise_for_status ()
61+ data = response .json ()
62+ features = data .get ("features" , [])
63+
64+ for item in features :
65+ try :
66+ item_info = {
67+ "id" : item .get ("id" ),
68+ "collection" : item .get ("collection" ),
69+ "bbox" : item .get ("bbox" ),
70+ "geometry" : item .get ("geometry" ),
71+ "properties" : item .get ("properties" ),
72+ }
73+ items .append (item_info )
74+ except Exception as e :
75+ click .echo (f"⚠️ Skipping item due to error: { e } " , err = True )
76+ traceback .print_exc ()
77+ error_count += 1
5578
5679 click .echo (f"Found { len (items )} items in collection { collection_id } " )
80+ if error_count > 0 :
81+ click .echo (f"⚠️ Skipped { error_count } items due to errors." , err = True )
5782 return items
5883
5984 except Exception as e :
6085 click .echo (f"❌ Error fetching items: { e } " , err = True )
86+ traceback .print_exc ()
6187 raise
6288
6389 def delete_item (self , collection_id : str , item_id : str ) -> bool :
0 commit comments