Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comments to config for polygon rules, add more logging #23

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions polytope_mars/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
Expand All @@ -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
Expand Down Expand Up @@ -153,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
Expand Down
4 changes: 4 additions & 0 deletions polytope_mars/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
6 changes: 3 additions & 3 deletions polytope_mars/features/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "wkt"
return "MultiPoint"

def name(self):
return "Wkt"
return "Polygon"
Loading