void H3_EXPORT()

in src/h3lib/lib/h3UniEdge.c [247:281]


void H3_EXPORT(getH3UnidirectionalEdgeBoundary)(H3Index edge, GeoBoundary* gb) {
    // TODO: More efficient solution :)
    GeoBoundary origin = {0};
    GeoBoundary destination = {0};
    GeoCoord postponedVertex = {0};
    bool hasPostponedVertex = false;

    H3_EXPORT(h3ToGeoBoundary)
    (H3_EXPORT(getOriginH3IndexFromUnidirectionalEdge)(edge), &origin);
    H3_EXPORT(h3ToGeoBoundary)
    (H3_EXPORT(getDestinationH3IndexFromUnidirectionalEdge)(edge),
     &destination);

    int k = 0;
    for (int i = 0; i < origin.numVerts; i++) {
        if (_hasMatchingVertex(&origin.verts[i], &destination)) {
            // If we are on vertex 0, we need to handle the case where it's the
            // end of the edge, not the beginning.
            if (i == 0 &&
                !_hasMatchingVertex(&origin.verts[i + 1], &destination)) {
                postponedVertex = origin.verts[i];
                hasPostponedVertex = true;
            } else {
                gb->verts[k] = origin.verts[i];
                k++;
            }
        }
    }
    // If we postponed adding the last vertex, add it now
    if (hasPostponedVertex) {
        gb->verts[k] = postponedVertex;
        k++;
    }
    gb->numVerts = k;
}