-
Notifications
You must be signed in to change notification settings - Fork 7
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
Bpoly feature #69
Bpoly feature #69
Conversation
3adef2e
to
21c6150
Compare
21c6150
to
99bd795
Compare
99bd795
to
787f4c5
Compare
787f4c5
to
850519a
Compare
def int_or_str_param_type(value: str) -> Union[int, str]: | ||
"""Parse parameter as Interger otherwise parse as String""" | ||
try: | ||
return int(value) | ||
except (ValueError, TypeError): | ||
if isinstance(value, str): | ||
return value | ||
else: | ||
raise ValueError("Given parameter is not a valid integer or string") |
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.
Do you have an example where this could be required? As far as I see, this is only used for the feature_id
. The feature id given by a GET/POST request should always be given as a string, afaik. If you want to prevent the parameter from being optional, I would check/set this with fastAPI.
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.
Yes you are right. The else statement is never reached. Except maybe when None is passed as argument. But before calling this function it is checked whether feature id is none or not.
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.
I meant in general, why do you want a variable which is either int
or str
? In the database you can only handle one of them, right? So you can handle all identifier in OQT as string, or did I miss a problem with that? I think it would be much easier to focus on one type for identifier 😉
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.
Ah, now I see what you mean.
Since #37 feature_id
can be str or int depending on what feature_id_field
is.
E.g.
# int in the database
oqt create-indicator --fid-field ogc_fid --feature-id 1
# str in the database
oqt create-indicator --fid-field name --feature-id heidelberg
What do you think about this behavior?
c6aa948
to
66317a1
Compare
def int_or_str_param_type(value: str) -> Union[int, str]: | ||
"""Parse parameter as Interger otherwise parse as String""" | ||
try: | ||
return int(value) | ||
except (ValueError, TypeError): | ||
if isinstance(value, str): | ||
return value | ||
else: | ||
raise ValueError("Given parameter is not a valid integer or string") |
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.
I meant in general, why do you want a variable which is either int
or str
? In the database you can only handle one of them, right? So you can handle all identifier in OQT as string, or did I miss a problem with that? I think it would be much easier to focus on one type for identifier 😉
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.
Thanks for the PR and the additional tests 👍 I made some additional comments, but in general, the PR looks good.
workers/ohsome_quality_analyst/indicators/ghs_pop_comparison_buildings/indicator.py
Outdated
Show resolved
Hide resolved
workers/ohsome_quality_analyst/indicators/ghs_pop_comparison_roads/indicator.py
Outdated
Show resolved
Hide resolved
@joker234 Thanks for your attentive feedback! I addressed most of your feedback directly in the code. Some discussions are still open. |
66317a1
to
d78d228
Compare
7986c85
to
94d0737
Compare
Parse and extract Geometry from input GeoJSON Input to the API is a valid GeoJSON. The function load_bpolys() will extract the geometry of this GeoJSON and validate it. Rename fixture file Add missing type hint Make bpolys attribute madatory for indicator class Add changes to CHANGELOG Update fixtures
after load_bpolys() has been called.
94d0737
to
c8c70a0
Compare
Description
Corresponding issue
Closes #9
Checklist
FeatureCollection
with only oneFeature
(again)main
(e.g. throughgit rebase main
)