oc_check_query for NAs in placename or latitude/longitude #98
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As of recently, OpenCage throws a HTTP 400 ‘bad query’ error when the query is empty, so we cannot be as sneaky as in #89 anymore.
I.e. now we need to make sure that we do not send empty queries (empty placename
or latitude/longitude) to the API, but alert the user beforehand. This is what happens with this PR.
An empty request throws an HTTP 400 error (shown with
oc_process()
here, but the same happens withoc_forward()
andoc_reverse()
without this fix):Instead,
oc_check_query()
now throws an error before moving tooc_process()
/calling the API:I was a bit reluctant to let the whole call error out ‘just’ because a user provides an empty/NA placename/coordinates, but this is a) what the API effectively demands now and b) essentially the same as providing incorrect coordinates, e.g. outside the (-)90/(-)180 bounds: