Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@justinhwang
Copy link
Contributor

This commit introduces a new public API function, gridRing, to
retrieve H3 cells located at an exact grid distance k from an origin
cell, forming a "hollow" ring.

The implementation mirrors implementation of gridDiskDistances
wherein we first attempt to use the unsafe version. If the unsafe
version fails, we fallback to _gridRingInternal.

_gridRingInternal utilizes _gridDiskDistancesInternal to get all
cells up to distance k, then filters the output to only include those
at exactly k.

@justinhwang
Copy link
Contributor Author

Not quite sure why were getting these errors

/home/runner/work/h3/h3/src/apps/testapps/testGridRing.c:32:35: error: call to undeclared function 'gridRing'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   32 |         t_assertSuccess(H3_EXPORT(gridRing)(sfHex, 0, k0));
      |    

when the test file has:

#include "h3api.h"

also my first time writing in C so any help is appreciated!

@isaacbrodsky
Copy link
Collaborator

Not quite sure why were getting these errors

/home/runner/work/h3/h3/src/apps/testapps/testGridRing.c:32:35: error: call to undeclared function 'gridRing'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   32 |         t_assertSuccess(H3_EXPORT(gridRing)(sfHex, 0, k0));
      |    

when the test file has:

#include "h3api.h"

also my first time writing in C so any help is appreciated!

The issue is because the declaration needs to be added to h3api.h.in (which gets processed into h3api.h), otherwise the compiler isn't sure what that function looks like.

@isaacbrodsky
Copy link
Collaborator

Thanks for this contribution! I will take a look in more detail.

If you're comfortable, could you also add this function to fuzzerGridDisk so we get the full fuzzer coverage? (We can also add that in a follow up)

@justinhwang
Copy link
Contributor Author

The issue is because the declaration needs to be added to h3api.h.in (which gets processed into h3api.h), otherwise the compiler isn't sure what that function looks like.

Ah I didn't notice that src/h3lib/include/h3api.h was local and in .gitignore, thanks!

Thanks for this contribution! I will take a look in more detail.

If you're comfortable, could you also add this function to fuzzerGridDisk so we get the full fuzzer coverage? (We can also add that in a follow up)

Would prefer if someone could help me do that in a followup, thank you :)

@coveralls
Copy link

coveralls commented Jun 4, 2025

Coverage Status

coverage: 98.804% (+0.02%) from 98.786%
when pulling 12fd76a on justinhwang:justinhwang/gridring
into b70bd72 on uber:master.

@shresss shresss mentioned this pull request Jun 4, 2025
@isaacbrodsky isaacbrodsky merged commit 6be0899 into uber:master Jun 5, 2025
45 checks passed
shresss added a commit to shresss/h3 that referenced this pull request Jun 5, 2025
Adds gridRing testing to fuzzerGridDisk.c to improve test coverage
as requested in uber#1011 and as I tried but ran into merge issues with in uber#1012.
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.

4 participants