Skip to content

Commit 333c2bc

Browse files
Docstring updates (#921)
* stub for new res1 test * better name * formatting is happening? * clean up test for all res 1 * failing test * Demonstrate pass at `numUncompacted = 40` * retry: Demonstrate pass at `numUncompacted = 40` * should fix the formatting issue * const array sizes to fix windows errors * bah * Demonstrate failure at numUncompacted = 41 * Demonstrate failure at numUncompacted = numRes1 = 842; * Demonstrate pass at numUncompacted = 40 * back to the full failing test demonstrating the problem * proposed fix for compact * test other case * comprehensive test * NEVER for parent error * convert compactCells to use int64_t * docs changes * fix typo --------- Co-authored-by: AJ Friend <[email protected]>
1 parent 0e515cf commit 333c2bc

File tree

7 files changed

+64
-29
lines changed

7 files changed

+64
-29
lines changed

dev-docs/Doxyfile.in

+4-4
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ WARN_LOGFILE =
401401
# directories like "/usr/src/myproject". Separate the files or directories
402402
# with spaces.
403403

404-
INPUT = ../src
404+
INPUT = ../src/h3lib "@PROJECT_BINARY_DIR@/src/h3lib/include/h3api.h"
405405

406406
# If the value of the INPUT tag contains directories, you can use the
407407
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
@@ -495,12 +495,12 @@ FILTER_SOURCE_FILES = NO
495495
# Note: To get rid of all source code in the generated output, make sure also
496496
# VERBATIM_HEADERS is set to NO.
497497

498-
SOURCE_BROWSER = NO
498+
SOURCE_BROWSER = YES
499499

500500
# Setting the INLINE_SOURCES tag to YES will include the body
501501
# of functions and classes directly in the documentation.
502502

503-
INLINE_SOURCES = NO
503+
INLINE_SOURCES = YES
504504

505505
# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
506506
# doxygen to hide any special comment blocks from generated source code
@@ -648,7 +648,7 @@ ENUM_VALUES_PER_LINE = 4
648648
# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
649649
# probably better off using the HTML help feature.
650650

651-
GENERATE_TREEVIEW = NO
651+
GENERATE_TREEVIEW = YES
652652

653653
# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
654654
# used to set the initial width (in pixels) of the frame in which the tree

src/h3lib/lib/directedEdge.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ H3Error H3_EXPORT(areNeighborCells)(H3Index origin, H3Index destination,
127127
* destination
128128
* @param origin The origin H3 hexagon index
129129
* @param destination The destination H3 hexagon index
130-
* @return The directed edge H3Index, or H3_NULL on failure.
130+
* @param out Output: The directed edge H3Index.
131131
*/
132132
H3Error H3_EXPORT(cellsToDirectedEdge)(H3Index origin, H3Index destination,
133133
H3Index *out) {
@@ -151,7 +151,7 @@ H3Error H3_EXPORT(cellsToDirectedEdge)(H3Index origin, H3Index destination,
151151
/**
152152
* Returns the origin hexagon from the directed edge H3Index
153153
* @param edge The edge H3 index
154-
* @return The origin H3 hexagon index, or H3_NULL on failure
154+
* @param out Output: The origin H3 hexagon index
155155
*/
156156
H3Error H3_EXPORT(getDirectedEdgeOrigin)(H3Index edge, H3Index *out) {
157157
if (H3_GET_MODE(edge) != H3_DIRECTEDEDGE_MODE) {
@@ -167,7 +167,7 @@ H3Error H3_EXPORT(getDirectedEdgeOrigin)(H3Index edge, H3Index *out) {
167167
/**
168168
* Returns the destination hexagon from the directed edge H3Index
169169
* @param edge The edge H3 index
170-
* @return The destination H3 hexagon index, or H3_NULL on failure
170+
* @param out Output: The destination H3 hexagon index
171171
*/
172172
H3Error H3_EXPORT(getDirectedEdgeDestination)(H3Index edge, H3Index *out) {
173173
Direction direction = H3_GET_RESERVED_BITS(edge);

src/h3lib/lib/h3Index.c

+17-11
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ int H3_EXPORT(getBaseCellNumber)(H3Index h) { return H3_GET_BASE_CELL(h); }
8989
/**
9090
* Converts a string representation of an H3 index into an H3 index.
9191
* @param str The string representation of an H3 index.
92-
* @return The H3 index corresponding to the string argument, or H3_NULL if
93-
* invalid.
92+
* @param out Output: The H3 index corresponding to the string argument
9493
*/
9594
H3Error H3_EXPORT(stringToH3)(const char *str, H3Index *out) {
9695
H3Index h = H3_NULL;
@@ -187,8 +186,7 @@ void setH3Index(H3Index *hp, int res, int baseCell, Direction initDigit) {
187186
*
188187
* @param h H3Index to find parent of
189188
* @param parentRes The resolution to switch to (parent, grandparent, etc)
190-
*
191-
* @return H3Index of the parent, or H3_NULL if you actually asked for a child
189+
* @param out Output: H3Index of the parent
192190
*/
193191
H3Error H3_EXPORT(cellToParent)(H3Index h, int parentRes, H3Index *out) {
194192
int childRes = H3_GET_RESOLUTION(h);
@@ -231,9 +229,8 @@ static bool _hasChildAtRes(H3Index h, int childRes) {
231229
*
232230
* @param h H3Index to find the number of children of
233231
* @param childRes The child resolution you're interested in
234-
*
235-
* @return int Exact number of children (handles hexagons and pentagons
236-
* correctly)
232+
* @param out Output: exact number of children (handles hexagons and
233+
* pentagons correctly)
237234
*/
238235
H3Error H3_EXPORT(cellToChildrenSize)(H3Index h, int childRes, int64_t *out) {
239236
if (!_hasChildAtRes(h, childRes)) return E_RES_DOMAIN;
@@ -547,8 +544,8 @@ H3Error H3_EXPORT(compactCells)(const H3Index *h3Set, H3Index *compactedSet,
547544
*
548545
* Skips elements that are H3_NULL (i.e., 0).
549546
*
550-
* @param compactSet Set of compacted cells
551-
* @param numCompact The number of cells in the input compacted set
547+
* @param compactedSet Set of compacted cells
548+
* @param numCompacted The number of cells in the input compacted set
552549
* @param outSet Output array for decompressed cells (preallocated)
553550
* @param numOut The size of the output array to bound check against
554551
* @param res The H3 resolution to decompress to
@@ -577,7 +574,7 @@ H3Error H3_EXPORT(uncompactCells)(const H3Index *compactedSet,
577574
* the exact size of the uncompacted set of hexagons.
578575
*
579576
* @param compactedSet Set of hexagons
580-
* @param numHexes The number of hexes in the input set
577+
* @param numCompacted The number of hexes in the input set
581578
* @param res The hexagon resolution to decompress to
582579
* @param out The number of hexagons to allocate memory for
583580
* @returns E_SUCCESS on success, or another value on error
@@ -1114,6 +1111,10 @@ static H3Error validateChildPos(int64_t childPos, H3Index parent,
11141111
/**
11151112
* Returns the position of the cell within an ordered list of all children of
11161113
* the cell's parent at the specified resolution
1114+
* @param child Child cell index
1115+
* @param parentRes Resolution of the parent cell to find the position within
1116+
* @param out Output: The position of the child cell within its parents cell
1117+
* list of children
11171118
*/
11181119
H3Error H3_EXPORT(cellToChildPos)(H3Index child, int parentRes, int64_t *out) {
11191120
int childRes = H3_GET_RESOLUTION(child);
@@ -1189,7 +1190,12 @@ H3Error H3_EXPORT(cellToChildPos)(H3Index child, int parentRes, int64_t *out) {
11891190

11901191
/**
11911192
* Returns the child cell at a given position within an ordered list of all
1192-
* children at the specified resolution */
1193+
* children at the specified resolution
1194+
* @param childPos Position within the ordered list
1195+
* @param parent Parent cell of the cell index to find
1196+
* @param childRes Resolution of the child cell index
1197+
* @param child Output: child cell index
1198+
*/
11931199
H3Error H3_EXPORT(childPosToCell)(int64_t childPos, H3Index parent,
11941200
int childRes, H3Index *child) {
11951201
// Validate resolution

src/h3lib/lib/latLng.c

+28-2
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,23 @@ double H3_EXPORT(greatCircleDistanceRads)(const LatLng *a, const LatLng *b) {
179179

180180
/**
181181
* The great circle distance in kilometers between two spherical coordinates.
182+
*
183+
* @param a the first lat/lng pair (in radians)
184+
* @param b the second lat/lng pair (in radians)
185+
*
186+
* @return the great circle distance in kilometers between a and b
182187
*/
183188
double H3_EXPORT(greatCircleDistanceKm)(const LatLng *a, const LatLng *b) {
184189
return H3_EXPORT(greatCircleDistanceRads)(a, b) * EARTH_RADIUS_KM;
185190
}
186191

187192
/**
188193
* The great circle distance in meters between two spherical coordinates.
194+
*
195+
* @param a the first lat/lng pair (in radians)
196+
* @param b the second lat/lng pair (in radians)
197+
*
198+
* @return the great circle distance in meters between a and b
189199
*/
190200
double H3_EXPORT(greatCircleDistanceM)(const LatLng *a, const LatLng *b) {
191201
return H3_EXPORT(greatCircleDistanceKm)(a, b) * 1000;
@@ -419,6 +429,10 @@ H3Error H3_EXPORT(cellAreaRads2)(H3Index cell, double *out) {
419429

420430
/**
421431
* Area of H3 cell in kilometers^2.
432+
*
433+
* @param cell H3 cell
434+
* @param out cell area in kilometers^2
435+
* @return E_SUCCESS on success, or an error code otherwise
422436
*/
423437
H3Error H3_EXPORT(cellAreaKm2)(H3Index cell, double *out) {
424438
H3Error err = H3_EXPORT(cellAreaRads2)(cell, out);
@@ -430,6 +444,10 @@ H3Error H3_EXPORT(cellAreaKm2)(H3Index cell, double *out) {
430444

431445
/**
432446
* Area of H3 cell in meters^2.
447+
*
448+
* @param cell H3 cell
449+
* @param out cell area in meters^2
450+
* @return E_SUCCESS on success, or an error code otherwise
433451
*/
434452
H3Error H3_EXPORT(cellAreaM2)(H3Index cell, double *out) {
435453
H3Error err = H3_EXPORT(cellAreaKm2)(cell, out);
@@ -443,8 +461,8 @@ H3Error H3_EXPORT(cellAreaM2)(H3Index cell, double *out) {
443461
* Length of a directed edge in radians.
444462
*
445463
* @param edge H3 directed edge
446-
*
447-
* @return length in radians
464+
* @param length length in radians
465+
* @return E_SUCCESS on success, or an error code otherwise
448466
*/
449467
H3Error H3_EXPORT(edgeLengthRads)(H3Index edge, double *length) {
450468
CellBoundary cb;
@@ -465,6 +483,10 @@ H3Error H3_EXPORT(edgeLengthRads)(H3Index edge, double *length) {
465483

466484
/**
467485
* Length of a directed edge in kilometers.
486+
*
487+
* @param edge H3 directed edge
488+
* @param length length in kilometers
489+
* @return E_SUCCESS on success, or an error code otherwise
468490
*/
469491
H3Error H3_EXPORT(edgeLengthKm)(H3Index edge, double *length) {
470492
H3Error err = H3_EXPORT(edgeLengthRads)(edge, length);
@@ -474,6 +496,10 @@ H3Error H3_EXPORT(edgeLengthKm)(H3Index edge, double *length) {
474496

475497
/**
476498
* Length of a directed edge in meters.
499+
*
500+
* @param edge H3 directed edge
501+
* @param length length in meters
502+
* @return E_SUCCESS on success, or an error code otherwise
477503
*/
478504
H3Error H3_EXPORT(edgeLengthM)(H3Index edge, double *length) {
479505
H3Error err = H3_EXPORT(edgeLengthKm)(edge, length);

src/h3lib/lib/localij.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -525,13 +525,13 @@ H3Error localIjkToCell(H3Index origin, const CoordIJK *ijk, H3Index *out) {
525525
* @param out ij coordinates of the index will be placed here on success
526526
* @return 0 on success, or another value on failure.
527527
*/
528-
H3Error H3_EXPORT(cellToLocalIj)(H3Index origin, H3Index h3, uint32_t mode,
528+
H3Error H3_EXPORT(cellToLocalIj)(H3Index origin, H3Index index, uint32_t mode,
529529
CoordIJ *out) {
530530
if (mode != 0) {
531531
return E_OPTION_INVALID;
532532
}
533533
CoordIJK ijk;
534-
H3Error failed = cellToLocalIjk(origin, h3, &ijk);
534+
H3Error failed = cellToLocalIjk(origin, index, &ijk);
535535
if (failed) {
536536
return failed;
537537
}
@@ -554,9 +554,9 @@ H3Error H3_EXPORT(cellToLocalIj)(H3Index origin, H3Index h3, uint32_t mode,
554554
* to be compatible across different versions of H3.
555555
*
556556
* @param origin An anchoring index for the ij coordinate system.
557-
* @param out ij coordinates to index.
557+
* @param ij ij coordinates to index.
558558
* @param mode Mode, must be 0
559-
* @param index Index will be placed here on success.
559+
* @param out Index will be placed here on success.
560560
* @return 0 on success, or another value on failure.
561561
*/
562562
H3Error H3_EXPORT(localIjToCell)(H3Index origin, const CoordIJ *ij,
@@ -582,16 +582,17 @@ H3Error H3_EXPORT(localIjToCell)(H3Index origin, const CoordIJ *ij,
582582
*
583583
* @param origin Index to find the distance from.
584584
* @param index Index to find the distance to.
585-
* @return The distance, or a negative number if the library could not
586-
* compute the distance.
585+
* @param out The distance in cells
586+
* @returns E_SUCCESS on success, or another value if the library cannot compute
587+
* the distance.
587588
*/
588-
H3Error H3_EXPORT(gridDistance)(H3Index origin, H3Index h3, int64_t *out) {
589+
H3Error H3_EXPORT(gridDistance)(H3Index origin, H3Index index, int64_t *out) {
589590
CoordIJK originIjk, h3Ijk;
590591
H3Error originError = cellToLocalIjk(origin, origin, &originIjk);
591592
if (originError) {
592593
return originError;
593594
}
594-
H3Error destError = cellToLocalIjk(origin, h3, &h3Ijk);
595+
H3Error destError = cellToLocalIjk(origin, index, &h3Ijk);
595596
if (destError) {
596597
return destError;
597598
}

src/h3lib/lib/polyfill.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,9 @@ static double getAverageCellArea(int res) {
723723
/**
724724
* maxPolygonToCellsSize returns the number of cells to allocate space for
725725
* when performing a polygonToCells on the given GeoJSON-like data structure.
726-
* @param geoPolygon A GeoJSON-like data structure indicating the poly to fill
726+
* @param polygon A GeoJSON-like data structure indicating the poly to fill
727727
* @param res Hexagon resolution (0-15)
728+
* @param flags Bit mask of option flags
728729
* @param out number of cells to allocate for
729730
* @return 0 (E_SUCCESS) on success.
730731
*/

src/h3lib/lib/vertex.c

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static const int revNeighborDirectionsHex[NUM_DIGITS] = {
205205
* H3_NULL if the vertex is invalid
206206
* @param cell Cell to get the vertex for
207207
* @param vertexNum Number (index) of the vertex to calculate
208+
* @param out Output: The vertex index
208209
*/
209210
H3Error H3_EXPORT(cellToVertex)(H3Index cell, int vertexNum, H3Index *out) {
210211
int cellIsPentagon = H3_EXPORT(isPentagon)(cell);

0 commit comments

Comments
 (0)