-
Notifications
You must be signed in to change notification settings - Fork 0
Implement horizontal_spatial_domain factory #51
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ArchiveAndDistributionInformation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CollectionReference, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| DataGranule, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Geometry, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HorizontalSpatialDomain, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Identifier, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Instrument, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -58,6 +59,32 @@ def data_granule( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return obj | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def horizontal_spatial_domain( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| zone_identifier: Optional[str] = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| geometry: Optional[Geometry] = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # TODO(reweeden): Implement typing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| orbit: Optional[dict[str, Any]] = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # TODO(reweeden): Implement typing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| track: Optional[dict[str, Any]] = None, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) -> HorizontalSpatialDomain: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| obj: HorizontalSpatialDomain = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if zone_identifier is not None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| obj["ZoneIdentifier"] = zone_identifier | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if geometry is not None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| obj["Geometry"] = geometry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if orbit is not None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| obj["Orbit"] = orbit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if track is not None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| obj["Track"] = track | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if orbit is None and track is None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| raise ValueError( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "one of 'orbit' or 'track' is required", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return obj | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+62
to
+85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also keep the params in the order they are defined in the schema and build the resulting dict in that order when possible, and in this case it is! And I'd keep the formatting consistent with the implementations (empty line before the return statement). All said and done if I was doing this PR I would commit this:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def identifier( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| identifier: str, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to hold off on adding the orbit and track params and adding the oneOf validation? As it stands now this factory function can produce an empty dict which is invalid as far as the jsonschema goes. I would say if you're not going to add orbit then at least I'd make geometry required / raise a ValueError if geometry is not provided. But I think it would be just cleaner to implement the whole thing, it should be an additional like 10 lines of code.