-
Notifications
You must be signed in to change notification settings - Fork 189
Eliminating redefined constant, restructuring "earth" package and distributing methods #239
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
base: master
Are you sure you want to change the base?
Conversation
jmr
left a comment
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.
Why not replace all uses of earthRadiusKm with earth.Radius.Kilometers()?
It seems like kmToAngle should also have an earth-based replacement.
I went ahead and tried to clean that up, but realized "earth" imported "s2" and "s1" which from my first impression does not make sense because then it's unusable from "s2" while still requiring it underneath. I dug into the discussion and ironically this had already been raised as an issue: #191 (comment) If folks disagree, please feel free to close the PR and keep the duplicate implementation/constant, but I've proposed keeping the constants in "earth" where they're independent and moving the methods/tests that require the types to their respective packages with prefixing. |
|
This is going to break all users in its current form, so we don't want to do that. |
I think you should maybe reconsider, or at least discuss further to make sure our options here are exhausted. That code has only been merged since July and the evidence of the problem here is in the codebase itself: the S2 tests contain reimplemented versions of How much of the In terms of breaking other uses, this code is months old… not years. The cost of fixing now seems minimal compared to accumulating technical debt which is evident in the tests here and could reappear in future tests. The functionality is still there for importers, but the method calls would need to be adjusted from |
|
I think it's cleaner to have earth be a separate package. s1/s2 is about spherical geometry on a unit sphere. Earth is an up-scaled approximation of that. We are stuck with Go's rules on imports. We could reduce some parts of the duplication. For kmToAngle, we only seem to use specifically 10km in tests. Maybe a simpler clean up would be to have one test constant that is precomputed for 10km with a note on where / how its computed and replace all the kmToAngle calls with that contains_point_query_test.go: maxLoopRadius := kmToAngle(10) The other tests that rely on the constant could be similarly re-written to not need it. s2/predicates_test.go: m := math.Tan(spacing / earthRadiusKm) s2/point_test.go: if dist := math.Acos(OriginPoint().Z) * earthRadiusKm; dist <= 50 { s2/polygon_test.go: RegularLoop(origin, 1000/earthRadiusKm, 100), |
|
I think where we're running into problems is that if S2 does not have
Also, I again just want to emphasize that it seems a bit weird for If we're going to lean hard into the
… But, I'm not sure if that makes sense because then @rsned Are you comfortable with S2's tests being generalized away from Earth to enforce the separation, and do you think this is a good direction for the library to take given how S2 is structured in other languages?
In the diff there are some meters/kilometers seemingly… This was cleaned up to use the clearer units throughout: |
I don't understand the question. The functions are available. What are you asking?
It's easier for the people writing the tests, since they're familiar with the Earth. |
Right, the question is, if "earth" is being split out from S2 here, is that the goal for the libraries across other languages in general? (to separate S2 from being Earth-bound and therefore be purely sphere-focused, splitting off the
In this case, I would say that further justifies the PR in its current format given that
However, the current structure (that is being debated) blocks those constants from being used due to the dependency, and highlights that other elements of |
It's not a comparable situation, since the other languages don't have "s1" and "s2" packages.
The amount of code in s1/s2 tests compared to the rest of the world is small. Doesn't seem like a big deal. |
Aside from the fact the code was already deployed… is that the justification for Again, it seems weird that |
I noticed this. Seeing as there's a central definition for
S2Earthhere(as just "earth/") it's a one-liner.see #239 (comment)