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

Add quadbinToBoundary utility #16

Merged
merged 8 commits into from
Oct 7, 2024
Merged

Conversation

jmgaya
Copy link
Contributor

@jmgaya jmgaya commented Sep 25, 2024

The main goal of this Pull-Request is to add support for an utility we require here

I also did some refinements, adding a CONTRIBUTING.md file, along with some fixes in the package.json that will prevent different builds if npx resolves some dependencies differently 👍

src/index.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Show resolved Hide resolved
test/index.spec.js Outdated Show resolved Hide resolved
CONTRIBUTING.md Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
test/index.spec.js Show resolved Hide resolved
test/index.spec.js Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@jmgaya jmgaya requested a review from felixpalmer October 1, 2024 08:54
src/index.ts Outdated
@@ -13,6 +15,29 @@ const S = [0n, 1n, 2n, 4n, 8n, 16n];
type Quadbin = bigint;
type Tile = {x: number; y: number; z: number};

const TILE_SIZE = 512;

function quadbinToOffset(quadbin: bigint): [number, number, number] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you rename these 3 functions to be cellTo... and export them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you missed this comment

Copy link
Contributor Author

@jmgaya jmgaya Oct 2, 2024

Choose a reason for hiding this comment

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

I kept them as they are because they have this name in deck.gl, and not only that, but they receive a parameter quadbin, so I think we should re-think it a bit before renaming?

Regarding your export suggestion, done!

Copy link
Collaborator

@felixpalmer felixpalmer Oct 2, 2024

Choose a reason for hiding this comment

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

I think if we are going to add functions to the package we shouldn't change the names later. So best to include them as cellToOffset(cell: bigint) etc, i.e. renaming also the parameter. It's not an issue for deck that the name changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I'm afraid of is that we are proposing some changes that may require a major version, and I'm not sure if we should go for them in this PR, just it 🤷

What's your proposal then? Mine is:

  • Stick to Quadbin type everywhere
  • Use Quadbin instead of cell in all the function names
  • Release a major

Copy link
Collaborator

Choose a reason for hiding this comment

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

As stated originally, I want the API to be aligned with quadbin-py. Which it currently is.

  • Any new functions which are in quadbin-py should have the same name
  • Any additional functions, like cellToOffset should follow the conventions already used

I see no value in renaming the existing function names, that would be a breaking change and require a major version and diverge from quadbin-py.

For the new functions we should stick with the conventions, so using cell in function names and quadbin: Quadbin in the parameters. It doesn't matter to the calling code what the name of the parameter is

Copy link
Collaborator

Choose a reason for hiding this comment

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

The API is modeled on https://github.com/uber/h3-js, which means that it is simpler to port code between the spatial indices, which is not the case if the functions are things like quadbinToBoundary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the new functions we should stick with the conventions, so using cell in function names and quadbin: Quadbin in the parameters. It doesn't matter to the calling code what the name of the parameter is

Sounds like a plan, let's go for it 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll say now, every function:

  • Receives a quadbin: Quadbin
  • Uses cell in its name

Could you please re-re-re-review it 😆 ?

src/index.ts Outdated Show resolved Hide resolved
@jmgaya jmgaya requested a review from felixpalmer October 1, 2024 09:51
@jmgaya jmgaya merged commit 42abad1 into master Oct 7, 2024
4 checks passed
@felixpalmer felixpalmer deleted the feature/442543/quadbin-to-boundary branch October 8, 2024 07:40
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.

3 participants