in src/apps/testapps/testPolyfill.c [62:109]
static void fillIndex_assertions(H3Index h) {
if (isTransmeridianCell(h)) {
// TODO: these do not work correctly
return;
}
int currentRes = H3_EXPORT(h3GetResolution)(h);
// TODO: Not testing more than one depth because the assertions fail.
for (int nextRes = currentRes; nextRes <= currentRes + 1; nextRes++) {
GeoBoundary bndry;
H3_EXPORT(h3ToGeoBoundary)(h, &bndry);
GeoPolygon polygon = {
.geofence = {.numVerts = bndry.numVerts, .verts = bndry.verts},
.numHoles = 0,
.holes = 0};
int polyfillSize = H3_EXPORT(maxPolyfillSize)(&polygon, nextRes);
H3Index* polyfillOut = calloc(polyfillSize, sizeof(H3Index));
H3_EXPORT(polyfill)(&polygon, nextRes, polyfillOut);
int polyfillCount = countActualHexagons(polyfillOut, polyfillSize);
int childrenSize = H3_EXPORT(maxH3ToChildrenSize)(h, nextRes);
H3Index* children = calloc(childrenSize, sizeof(H3Index));
H3_EXPORT(h3ToChildren)(h, nextRes, children);
int h3ToChildrenCount = countActualHexagons(children, childrenSize);
t_assert(polyfillCount == h3ToChildrenCount,
"Polyfill count matches h3ToChildren count");
for (int i = 0; i < childrenSize; i++) {
bool found = false;
if (children[i] == H3_NULL) continue;
for (int j = 0; j < polyfillSize; j++) {
if (polyfillOut[j] == children[i]) {
found = true;
break;
}
}
t_assert(found,
"All indexes match between polyfill and h3ToChildren");
}
free(polyfillOut);
free(children);
}
}