Skip to content

Commit d99deef

Browse files
committed
change per review
1 parent c92717d commit d99deef

File tree

5 files changed

+27
-28
lines changed

5 files changed

+27
-28
lines changed

src/apps/filters/h3.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,13 @@ SUBCOMMAND(getReservedBits,
319319
SUBCOMMAND(getIndexDigit,
320320
"Extracts the indexing digit (0 - 7) from the H3 cell") {
321321
DEFINE_CELL_ARG(cell, cellArg);
322-
int digit = 0;
323-
Arg digitArg = {.names = {"-d", "--digit"},
322+
int res = 0;
323+
Arg digitArg = {.names = {"-r", "--res"},
324324
.required = true,
325325
.scanFormat = "%d",
326-
.valueName = "digit",
327-
.value = &digit,
328-
.helpText = "Indexing digit (1 - 15)"};
326+
.valueName = "res",
327+
.value = &res,
328+
.helpText = "Indexing resolution (1 - 15)"};
329329
Arg *args[] = {&getIndexDigitArg, &helpArg, &cellArg, &digitArg};
330330
PARSE_SUBCOMMAND(argc, argv, args);
331331
// TODO: Should there be a general `isValidIndex`?
@@ -336,7 +336,7 @@ SUBCOMMAND(getIndexDigit,
336336
return cellErr;
337337
}
338338
int value;
339-
H3Error err = H3_EXPORT(getIndexDigit)(cell, digit, &value);
339+
H3Error err = H3_EXPORT(getIndexDigit)(cell, res, &value);
340340
if (err) {
341341
return err;
342342
}

src/apps/fuzzers/fuzzerCellProperties.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
typedef struct {
2525
H3Index index;
2626
H3Index mask;
27-
int digit;
27+
int res;
2828
} inputArgs;
2929

3030
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
@@ -49,7 +49,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
4949
}
5050

5151
int digitOut;
52-
H3_EXPORT(getIndexDigit)(args->index, args->digit, &digitOut);
52+
H3_EXPORT(getIndexDigit)(args->index, args->res, &digitOut);
5353

5454
return 0;
5555
}

src/h3lib/include/h3api.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ DECLSPEC int H3_EXPORT(getReservedBits)(H3Index h);
533533
/** @brief returns the indexing digit of the provided H3 cell
534534
*
535535
* Indexing digits are 1-indexed beginning with the digit for resolution 1. */
536-
DECLSPEC H3Error H3_EXPORT(getIndexDigit)(H3Index h, int digit, int *out);
536+
DECLSPEC H3Error H3_EXPORT(getIndexDigit)(H3Index h, int res, int *out);
537537
/** @} */
538538

539539
/** @defgroup stringToH3 stringToH3

src/h3lib/lib/h3Index.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,27 +98,26 @@ int H3_EXPORT(getBaseCellNumber)(H3Index h) { return H3_GET_BASE_CELL(h); }
9898
int H3_EXPORT(getReservedBits)(H3Index h) { return H3_GET_RESERVED_BITS(h); }
9999

100100
/**
101-
* Returns the index digits at `digit`, which starts with 1 for resolution
101+
* Returns the index digit at `res`, which starts with 1 for resolution
102102
* 1.
103103
*
104-
* 0 is not a valid value for `digit` because resolution 0 is specified by
104+
* 0 is not a valid value for `res` because resolution 0 is specified by
105105
* the base cell number, not an indexing digit.
106106
*
107-
* `digit` may exceed the actual resolution of the index, in which case
107+
* `res` may exceed the actual resolution of the index, in which case
108108
* the actual digit stored in the index is returned. For valid cell indexes
109109
* this will be 7.
110110
*
111111
* @param h The H3 index (e.g. cell).
112-
* @param digit Which indexing digit to retrieve, starting with 1.
112+
* @param res Which indexing digit to retrieve, starting with 1.
113113
* @param out Receives the value of the indexing digit.
114114
* @return 0 (E_SUCCESS) on success, or another value otherwise.
115115
*/
116-
H3Error H3_EXPORT(getIndexDigit)(H3Index h, int digit, int *out) {
117-
if (digit < 1 || digit > MAX_H3_RES) {
118-
// Not strictly a resolution domain but close enough
116+
H3Error H3_EXPORT(getIndexDigit)(H3Index h, int res, int *out) {
117+
if (res < 1 || res > MAX_H3_RES) {
119118
return E_RES_DOMAIN;
120119
}
121-
*out = H3_GET_INDEX_DIGIT(h, digit);
120+
*out = H3_GET_INDEX_DIGIT(h, res);
122121
return E_SUCCESS;
123122
}
124123

website/docs/api/inspection.mdx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,51 +296,51 @@ Works for cells, edges and vertexes.
296296
<TabItem value="c">
297297

298298
```c
299-
H3Error getIndexDigit(H3Index h, int digit, H3Index *out);
299+
H3Error getIndexDigit(H3Index h, int res, H3Index *out);
300300
```
301301
302302
</TabItem>
303303
<TabItem value="java">
304304
305305
```java
306-
int getIndexDigit(long h3, int digit);
307-
int getIndexDigit(String h3Address, int digit);
306+
int getIndexDigit(long h3, int res);
307+
int getIndexDigit(String h3Address, int res);
308308
```
309309

310310
</TabItem>
311311
<TabItem value="javascript">
312312

313313
```js
314-
h3.getIndexDigit(h, digit)
314+
h3.getIndexDigit(h, res)
315315
```
316316

317317
```js live
318318
function example() {
319319
const h = '85283473fffffff';
320-
const digit = 2;
321-
return h3.getIndexDigit(h, digit);
320+
const res = 2;
321+
return h3.getIndexDigit(h, res);
322322
}
323323
```
324324

325325
</TabItem>
326326
<TabItem value="python">
327327

328328
```py
329-
h3.get_index_digit(h, digit)
329+
h3.get_index_digit(h, res)
330330
```
331331

332332
</TabItem>
333333
<TabItem value="go">
334334

335335
```go
336-
cell.IndexDigit(digit)
336+
cell.IndexDigit(res)
337337
```
338338

339339
</TabItem>
340340
<TabItem value="duckdb">
341341

342342
```sql
343-
h3_get_index_digit(h, digit)
343+
h3_get_index_digit(h, res)
344344
```
345345

346346
</TabItem>
@@ -354,11 +354,11 @@ H3 4.3.0
354354
getIndexDigit Extracts the indexing digit (0 - 7) from the H3 cell
355355
-h, --help Show this help message.
356356
-c, --cell <index> Required. H3 Cell
357-
-d, --digit <digit> Required. Indexing digit (1 - 15)
357+
-r, --res <res> Required. Indexing resolution (1 - 15)
358358
```
359359

360360
```bash
361-
$ h3 getIndexDigit -c 85283473fffffff -d 2
361+
$ h3 getIndexDigit -c 85283473fffffff -r 2
362362
7
363363
```
364364

0 commit comments

Comments
 (0)