Skip to content
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

Accept integers to h3GetResolution #113

Merged
merged 2 commits into from
Apr 29, 2021

Conversation

isaacbrodsky
Copy link
Collaborator

h3GetResolution had an unusual implementation that did not actually work for H3IndexInput type input. Fixed this and allow split integer input.

@coveralls
Copy link

coveralls commented Apr 28, 2021

Pull Request Test Coverage Report for Build 232

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 230: 0.0%
Covered Lines: 400
Relevant Lines: 400

💛 - Coveralls

Copy link
Collaborator

@dfellis dfellis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no problem with this in general, but I do wonder if we should expose the split integer stuff or just use BigInt here? All major browsers support it, now.

test('h3GetResolution - integers', assert => {
// Same as in h3GetResolution above
const indexes = [
[4294967295, 134389759],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required here, but I think we should probably expose h3IndexToSplitLong as a public function and use it here rather than hard-coding the input data. If this test fails, it'll be very hard for a future engineer to determine whether it's the fault of the code or the input.

lib/h3core.js Outdated
) {
const [lower, upper] = h3Index;
return H3.h3GetResolution(lower, upper);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just delegate all paths to the C implementation here? i.e.

const [lower, upper] = h3IndexToSplitLong(h3Index);
return H3.h3GetResolution(lower, upper);

I'm not sure why we implemented it in pure JS at first, but I'm not convinced it's any faster.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's best to use a similar optimization strategy to other bindings rather than relying on puling characters out. Using the library implementation seems more predictable.

Copy link
Collaborator

@nrabinowitz nrabinowitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for adding!

@nrabinowitz nrabinowitz merged commit 9236810 into uber:master Apr 29, 2021
@isaacbrodsky isaacbrodsky deleted the h3getresolution-accept-ints branch April 29, 2021 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants