Skip to content

Commit

Permalink
Feat: return all available data from an area or position if parameter…
Browse files Browse the repository at this point in the history
… name is not given
  • Loading branch information
fjugipe committed Jan 26, 2024
1 parent d3135ef commit 79012eb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions api/routers/edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ async def get_locations(bbox: str = Query(..., example="5.0,52.0,6.0,52.1")) ->
)
async def get_data_location_id(
location_id: str = Path(..., example="06260"),
# TODO: Update examples when naming convention has been decided
parameter_name: str = Query(None, alias="parameter-name", example="dd,ff,rh,pp,tn"),
datetime: str = Query(None, example="2024-01-31T00:00Z/2024-02-01T00:00Z"),
datetime: str = Query(None, example="2022-12-31T00:00Z/2023-01-01T00:00Z"),
f: str = Query(default="covjson", alias="f", description="Specify return format."),
):
# TODO: There is no error handling of any kind at the moment!
Expand All @@ -86,8 +87,8 @@ async def get_data_location_id(
)
async def get_data_position(
coords: str = Query(..., example="POINT(5.179705 52.0988218)"),
parameter_name: str = Query(..., alias="parameter-name", example="dd,ff,rh,pp,tn"),
datetime: str = Query(None, example="2024-01-31T00:00Z/2024-02-01T00:00Z"),
parameter_name: str = Query(None, alias="parameter-name", example="dd,ff,rh,pp,tn"),
datetime: str = Query(None, example="2022-12-31T00:00Z/2023-01-01T00:00Z"),
f: str = Query(default="covjson", alias="f", description="Specify return format."),
):
point = wkt.loads(coords)
Expand All @@ -104,15 +105,15 @@ async def get_data_position(
)
async def get_data_area(
coords: str = Query(..., example="POLYGON((5.0 52.0, 6.0 52.0,6.0 52.1,5.0 52.1, 5.0 52.0))"),
parameter_name: str = Query(..., alias="parameter-name", example="dd,ff,rh,pp,tn"),
datetime: str | None = None,
parameter_name: str = Query(None, alias="parameter-name", example="dd,ff,rh,pp,tn"),
datetime: str = Query(None, example="2022-12-31T00:00Z/2023-01-01T00:00Z"),
f: str = Query(default="covjson", alias="f", description="Specify return format."),
):
poly = wkt.loads(coords)
assert poly.geom_type == "Polygon"
range = get_datetime_range(datetime)
get_obs_request = dstore.GetObsRequest(
standard_names=list(map(str.strip, parameter_name.split(","))),
standard_names=list(map(str.strip, parameter_name.split(","))) if parameter_name else "*",
inside=dstore.Polygon(points=[dstore.Point(lat=coord[1], lon=coord[0]) for coord in poly.exterior.coords]),
interval=dstore.TimeInterval(start=range[0], end=range[1]) if range else None,
)
Expand Down

0 comments on commit 79012eb

Please sign in to comment.