Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey-Vervoort-KNMI committed Feb 8, 2024
1 parent 0d5d41b commit ee306d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
18 changes: 18 additions & 0 deletions api/custom_geo_json/edr_feature_collection.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 0 additions & 8 deletions api/grpc_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions api/routers/edr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit ee306d5

Please sign in to comment.