From ee306d50309c50118d8ded9f5b0d3db9c474ffc8 Mon Sep 17 00:00:00 2001 From: Jeffrey Vervoort Date: Thu, 8 Feb 2024 19:17:03 +0100 Subject: [PATCH] cleanup --- api/custom_geo_json/edr_feature_collection.py | 18 ++++++++++++++++++ api/grpc_getter.py | 8 -------- api/routers/edr.py | 12 ------------ 3 files changed, 18 insertions(+), 20 deletions(-) create mode 100644 api/custom_geo_json/edr_feature_collection.py diff --git a/api/custom_geo_json/edr_feature_collection.py b/api/custom_geo_json/edr_feature_collection.py new file mode 100644 index 00000000..13b9f3b7 --- /dev/null +++ b/api/custom_geo_json/edr_feature_collection.py @@ -0,0 +1,18 @@ +from datetime import datetime +from datetime import timezone +from typing import List + +from edr_pydantic.link import Link +from edr_pydantic.parameter import EdrBaseModel +from edr_pydantic.parameter import Parameters +from geojson_pydantic import FeatureCollection +from pydantic import Field +from pydantic.types import AwareDatetime + + +class EDRFeatureCollection(EdrBaseModel, FeatureCollection): + parameters: Parameters + # links: List[Link] + timeStamp: AwareDatetime = Field(default=datetime.now(timezone.utc)) + # numberMatched: int + # numberReturned: int diff --git a/api/grpc_getter.py b/api/grpc_getter.py index 49c47a59..37343d33 100644 --- a/api/grpc_getter.py +++ b/api/grpc_getter.py @@ -14,11 +14,3 @@ async def getObsRequest(get_obs_request): response = await grpc_stub.GetObservations(get_obs_request) return response - - -async def getTSAttrGroupsRequest(get_attr_groups_request): - channel = grpc.aio.insecure_channel(f"{os.getenv('DSHOST', 'localhost')}:{os.getenv('DSPORT', '50050')}") - grpc_stub = dstore_grpc.DatastoreStub(channel) - response = await grpc_stub.GetTSAttrGroups(get_attr_groups_request) - - return response diff --git a/api/routers/edr.py b/api/routers/edr.py index 76f3d99a..dc94a027 100644 --- a/api/routers/edr.py +++ b/api/routers/edr.py @@ -13,7 +13,6 @@ from geojson_pydantic import Feature from geojson_pydantic import Point from grpc_getter import getObsRequest -from grpc_getter import getTSAttrGroupsRequest from shapely import buffer from shapely import geometry from shapely import wkt @@ -37,14 +36,6 @@ async def get_locations( left, bottom, right, top = map(str.strip, bbox.split(",")) poly = geometry.Polygon([(left, bottom), (right, bottom), (right, top), (left, top)]) - # ts_ag_request = dstore.GetTSAGRequest( - # attrs=["instrument", "platform", "standard_name", "title"], # "geo_point_id"], - # # instrument=dstore.Strings(values=all_parameters), - # # spatial_area=dstore.Polygon( - # # points=[dstore.Point(lat=coord[1], lon=coord[0]) for coord in poly.exterior.coords] - # # ), - # include_instances=False, - # ) ts_request = dstore.GetObsRequest( spatial_area=dstore.Polygon( points=[dstore.Point(lat=coord[1], lon=coord[0]) for coord in poly.exterior.coords] @@ -92,10 +83,7 @@ async def get_locations( } } - # feature_collection = FeatureCollection(features=features, type="FeatureCollection") - # return dict(feature_collection.model_dump(), **{"parameters": parameters}) return EDRFeatureCollection(features=features, type="FeatureCollection", parameters=parameters) - # return @router.get(