-
Notifications
You must be signed in to change notification settings - Fork 1
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
Return an error for /watershed API requests that fall on grid boundaries. #162
Comments
That seems somewhat user-unfriendly to me. It's an API not a UI, so we'd want to make sure that UIs don't ever confront the user with this error. Are we the only clients of this API? |
MOTI might be using it in their asset management pilot project, which was the original purpose of the API. @sum1lim is using it for his analysis of RVIC's efficiency. We're not using it in any web service ourselves. |
What's unfriendly about providing clear feedback about what is undefined behaviour (and potentially invalid results)? We can certainly ensure that our UI doesn't do this, but the fact that we hit this edge case indicates that we need some guardrails, and that's exactly what an HTTP 400 is for. |
Put that way, nothing. The "not on a cell boundary" rule seemed arbitrary to me, and partly a product of our own software being inconsistent, but there is no real alternative except to provide inconsistent results. I withdraw the comment. |
Sorry, why is it arbitrary? The watershed API answers questions for "all cells upstream of the input point". If the input point doesn't identify a single cell, how should one even answer that question? It's literally a boundary condition 😄 |
Note to self: Do not comment on issues first thing Monday morning. |
OK, while we're amicably squabbling here, I'd propose the following rule: Points on cell boundaries are resolved as follows: A cell includes its northern and western boundary lines, and excludes its southern and eastern ones. That eliminates the "invalid location" condition in a simple way. |
Currently the way The example that alerted us to this issue involved So what we're trying to avoid ultimately is a user requesting two pieces of information about a watershed from two different PCIC tools and getting contradictory responses. (Though in the case of a request on a cell boundary, is either answer correct?) So we can either:
|
Ah, I had a vague notion that consistency with RVIC was part of the issue, but didn't address it. That does sound important, and the boundary rule (like my proposal) sounds preferable to me if it is feasible. |
You could even make the rule selectable by a query param, so that it could be set for other cases (applications like RVIC to match) if necessary. |
I'd definitely be careful about specifying one-and-only-one boundary behaviour (or at least being clear that that's what you're doing). Part of the reason that geometry engines have such a rich set of topological relationships is because geometric topology is complicated 😄 |
In the case where someone supplies a point to the watershed API that lies exactly on the boundary between cells, such as a whole number latitude or longitude, it's not clear which grid cell to use as the mouth of the watershed, which can make quite a large difference to the result.
@jameshiebert suggests a solution:
The text was updated successfully, but these errors were encountered: