From deb1d9b48409989c40d5b3307e3595b1f5626b56 Mon Sep 17 00:00:00 2001 From: awarde96 Date: Thu, 26 Sep 2024 13:45:01 +0000 Subject: [PATCH 1/2] Add comments to config for polygon rules, add more logging --- polytope_mars/api.py | 9 ++++++++- polytope_mars/config.py | 4 ++++ polytope_mars/features/polygon.py | 4 ++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/polytope_mars/api.py b/polytope_mars/api.py index 02e5670..55b07fe 100644 --- a/polytope_mars/api.py +++ b/polytope_mars/api.py @@ -56,6 +56,8 @@ def __init__(self, config=None, log_context=None): def extract(self, request): # request expected in JSON or dict + start = time.time() + logging.debug(f"{self.id}: Gribjump/setup time start: {start}") # noqa: E501 if not isinstance(request, dict): try: request = json.loads(request) @@ -106,6 +108,11 @@ def extract(self, request): options=self.conf.options.model_dump(), ) + end = time.time() + delta = end - start + logging.debug(f"{self.id}: Gribjump/setup time start: {end}") # noqa: E501 + logging.debug(f"{self.id}: Gribjump/setup time start: {delta}") # noqa: E501 + logging.debug( f"{self.id}: The request we give polytope from polytope-mars is: {preq}" # noqa: E501 ) @@ -123,7 +130,7 @@ def extract(self, request): logging.debug(f"{self.id}: Polytope time end: {end}") # noqa: E501 logging.debug(f"{self.id}: Polytope time taken: {delta}") # noqa: E501 start = time.time() - logging.debug(f"{self.id}: Polytope time start: {start}") # noqa: E501 + logging.debug(f"{self.id}: Covjson time start: {start}") # noqa: E501 encoder = Covjsonkit(self.conf.coverageconfig.model_dump()).encode( "CoverageCollection", feature_type ) # noqa: E501 diff --git a/polytope_mars/config.py b/polytope_mars/config.py index 1cf6982..dd8ae97 100644 --- a/polytope_mars/config.py +++ b/polytope_mars/config.py @@ -14,7 +14,11 @@ class CovjsonKitConfig(ConfigModel): class PolygonRulesConfig(ConfigModel): + # Max points is the max number of points in all polygons requested allowed max_points: int = 1000 + # Max area is the max area of all polygons requested that is allowed. + # Area is in abstract units as a projection would otherwise be required + # to calculate the area max_area: float = 1000.0 diff --git a/polytope_mars/features/polygon.py b/polytope_mars/features/polygon.py index 920a1b9..5e5f018 100644 --- a/polytope_mars/features/polygon.py +++ b/polytope_mars/features/polygon.py @@ -61,7 +61,7 @@ def incompatible_keys(self): return ["levellist"] def coverage_type(self): - return "wkt" + return "polygon" def name(self): - return "Wkt" + return "Polygon" From ada903a7a63af9c7b1586ad1872696dd25c1e5da Mon Sep 17 00:00:00 2001 From: awarde96 Date: Thu, 26 Sep 2024 13:50:56 +0000 Subject: [PATCH 2/2] Change polygon coverage type to Multipoint --- polytope_mars/api.py | 4 ---- polytope_mars/features/polygon.py | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/polytope_mars/api.py b/polytope_mars/api.py index 55b07fe..1eef36c 100644 --- a/polytope_mars/api.py +++ b/polytope_mars/api.py @@ -160,10 +160,6 @@ def _create_base_shapes(self, request: dict) -> List[shapes.Shape]: raise NotImplementedError( "Currently only one time is supported" ) # noqa: E501 - # if str(time).split("/") != 1: - # time = str(time).split("/") - # else: - # time = [time] # TODO: not restricting certain keywords: # * AREA, GRID diff --git a/polytope_mars/features/polygon.py b/polytope_mars/features/polygon.py index 5e5f018..18a3f1c 100644 --- a/polytope_mars/features/polygon.py +++ b/polytope_mars/features/polygon.py @@ -58,10 +58,10 @@ def get_shapes(self): return [shapes.Union(["latitude", "longitude"], *polygons)] def incompatible_keys(self): - return ["levellist"] + return [] def coverage_type(self): - return "polygon" + return "MultiPoint" def name(self): return "Polygon"