-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
improve sanity check for geodesic distance calc #7457
improve sanity check for geodesic distance calc #7457
Conversation
guard Vincenty's inverse computation (surface distance) by the cut locus specific to the ellipsoid (assumed as oblate given min/max radii)
Thanks for the pull request @nmschulte!
Reviewers, don't forget to make sure that:
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
@@ -171,14 +171,18 @@ define([ | |||
ellipsoidGeodesic._uSquared = uSquared; | |||
} | |||
|
|||
//>>includeStart('debug', pragmas.debug); |
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 wonder about these scratch variables:
Why do these scratch variables live outside the only scope they're used?
Why use scratch variables like this?
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.
While debugging (the web worker) I ran into a case where the "subdivide heights" scratch array had a zero-length even though the code that was being debugged had presumably just initialized it... I reproduced it once after a refresh (left the debugger open). I've noticed strange behavior while debugging web workers with Chrome, so it's possible it's an artifact of that and not an issue with the logic (shared scratch) and some kind of race condition (between worker/worker or worker/main -- ... apologies I'm not well versed here).
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.
The scratch variables are at this scope so they can be reused each time the function is called instead of creating new instances each time. This is something we do commonly for performance. See https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/CodingGuide#result-parameters-and-scratch-variables
So you'll need to remove the pragmas here
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.
Same here with adding the pragma block: these scratch variables are only used for the debug check.
Digging a bit more this idea may be misguided, even though Cesium seems to render things fine for my case. I think the tolerance here is due to the nature of the approximation of the integral solution of Vincenty's formula, not necessarily the (maximum) locus length. Please correct me if so. |
var includedAngle = Math.abs(Math.abs(Cartesian3.angleBetween(startCartesian, endCartesian)) - CesiumMath.PI); | ||
// maxLambda is an approximation, assuming an oblate ellipsoid, and zero latitude (equatorial; phi = 0) | ||
var maxLambda = (1 - (ellipsoid.maximumRadius - ellipsoid.minimumRadius) / ellipsoid.maximumRadius) * CesiumMath.PI; | ||
Check.typeOf.number.lessThanOrEquals('value', includedAngle, maxLambda); |
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.
This Check
call should be the only thing inside the debug
pragmas here. Everything between //>>includeStart
and //>>includeEnd
will be removed from the code in the minified release version, so you don't want to have any logic included in that section. It's only for throwing DeveloperError
s
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 moved that logic into the pragma block because it is only used for the check.
@shunter did you want to take a look at this? |
Thanks again for your contribution @nmschulte! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
@shehzan10 could you give this a review? |
I think either @shunter or @fstoner have a better handle on this question than I do. This code looks fine to me. On the default ellipsoid, When I was doing the ellipsoid rhumb line code, I had a similar question about how So the only thing I would request is that this change should be applied to |
Thanks again for your contribution @nmschulte! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
@nmschulte can you merge in master? I think these changes look fine, I'll get them merged in this month after the branch is updated. Thanks! |
Please also add a unit test |
Is it a concern if I rebase these changes instead? I can include refactor/changes to update
I'll try my best ;). I'm still concerned that my logic connecting locus length to the approximation algorithm is incorrect and including this change will cause the formula to diverge (spin-lock/Bad Things™).
|
@nmschulte yes, a rebase would be fine. Thanks for pointing out your concern about locus length. I'm actually not familiar with that at all. @fstoner do you have any insight here? |
Thanks again for your contribution @nmschulte! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
5 similar comments
Thanks again for your contribution @nmschulte! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
Thanks again for your contribution @nmschulte! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
Thanks again for your contribution @nmschulte! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
Thanks again for your contribution @nmschulte! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
Thanks again for your contribution @nmschulte! No one has commented on this pull request in 30 days. Maintainers, can you review, merge or close to keep things tidy? I'm going to re-bump this in 30 days. If you'd like me to stop, just comment with |
Thanks for the PR @nmschulte, but I'm going to close this due to inactivity. This check is probably fine, but it's been difficult to verify and get this merged. |
Congratulations on closing the issue! I found these Cesium forum links in the comments above: https://groups.google.com/forum/#!topic/cesium-dev/uTaQKBSzxCU If this issue affects any of these threads, please post a comment like the following:
|
https://groups.google.com/forum/#!topic/cesium-dev/uTaQKBSzxCU
Based upon the discussion linked above, I think this is a small improvement to the current logic. The commit message has the details and this description has more: https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid#Behavior_of_geodesics
(commit message)
(Wikipedia extract; emphasis mine)