Skip to content

Commit

Permalink
Remove CONUS/AK Search Constraint (cryocloud dev) (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack-Hayes authored Oct 17, 2024
1 parent f5aee55 commit dad5b63
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
14 changes: 2 additions & 12 deletions src/coincident/search/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

# Used to access formatters
from pystac_client.item_search import ItemSearch as _ItemSearch
from shapely.geometry import box

from coincident.datasets import _alias_to_Dataset
from coincident.datasets.general import Dataset
Expand Down Expand Up @@ -171,7 +170,7 @@ def _validate_spatial_bounds(
intersects: gpd.GeoSeries,
) -> None:
"""
Validate that the specified area of interest (AOI) within CONUS or Alaska.
Validate that the specified area of interest (AOI) is type GeoDataFrame or GeoSeries
Parameters
----------
dataset : _Dataset
Expand All @@ -181,20 +180,11 @@ def _validate_spatial_bounds(
Raises
------
ValueError
If the AOI is not within the bounds of the Continental U.S. or Alaska.
If the AOI is not type GeoDataFrame or GeoSeries
"""
if not isinstance(intersects, gpd.GeoDataFrame | gpd.GeoSeries):
message = f"intersects value must be a GeoDataFrame or GeoSeries, not {type(intersects)}"
raise ValueError(message)
if len(intersects) > 1:
message = "GeoDataFrame contains multiple geometries, search requires a single geometry"
raise ValueError(message)

# NOTE: use geopandas to first convert to projected CRS?
aoi = intersects.to_crs("EPSG:4326").geometry.iloc[0] # shapely geometry
CONUS = box(*(-124.84, 24.39, -66.88, 49.38))
AK = box(*(-179.99, 51.21, -129.63, 71.35))
if not aoi.within(CONUS) and not aoi.within(AK):
message = "Requested search polygon not within Continental U.S. or Alaska"
raise ValueError(message)
# warnings.warn(f'Requested search polygon not within Continental U.S. or Alaska')
19 changes: 0 additions & 19 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,6 @@ def test_polygon_invalid_type():
m.search.search(dataset="3dep", intersects="-120, 40, -121, 41")


# For now raise an error to not complicate things
def test_polygon_out_of_bounds():
feature_coll = {
"type": "FeatureCollection",
"features": [
{
"id": "0",
"properties": {"col1": "name1"},
"type": "Feature",
"geometry": {"type": "Point", "coordinates": (1.0, 2.0)},
}
],
}
aoi = gpd.GeoDataFrame.from_features(feature_coll, crs="EPSG:4326")
# with pytest.warns(UserWarning, match="Requested search polygon not within"):
with pytest.raises(ValueError, match="Requested search polygon not within"):
m.search.search(dataset="3dep", intersects=aoi)


# TODO: add more assertions / tests for this section
@network
@pytest.mark.filterwarnings("ignore:Server does not conform")
Expand Down

0 comments on commit dad5b63

Please sign in to comment.