From 04f3cac3b789596d024372ea47376c3edb655c55 Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Thu, 27 Jan 2022 19:15:27 -0800 Subject: [PATCH] Rename h3SetToLinkedGeo to cellsToLinkedMultiPolygon --- CMakeLists.txt | 10 +-- CMakeTests.cmake | 2 +- .../names_for_concepts_types_functions.md | 16 +++-- ...c => benchmarkCellsToLinkedMultiPolygon.c} | 19 ++--- ...eo.c => fuzzerCellsToLinkedMultiPolygon.c} | 6 +- ...dGeo.c => testCellsToLinkedMultiPolygon.c} | 70 +++++++++++-------- src/apps/testapps/testLinkedGeo.c | 2 +- src/apps/testapps/testPolygon.c | 18 ++--- src/h3lib/include/h3api.h.in | 12 ++-- src/h3lib/lib/algos.c | 16 +++-- src/h3lib/lib/linkedGeo.c | 4 +- .../docs/library/migration-3.x/functions.md | 16 +++-- 12 files changed, 105 insertions(+), 86 deletions(-) rename src/apps/benchmarks/{benchmarkH3SetToLinkedGeo.c => benchmarkCellsToLinkedMultiPolygon.c} (77%) rename src/apps/fuzzers/{fuzzerH3SetToLinkedGeo.c => fuzzerCellsToLinkedMultiPolygon.c} (83%) rename src/apps/testapps/{testH3SetToLinkedGeo.c => testCellsToLinkedMultiPolygon.c} (82%) diff --git a/CMakeLists.txt b/CMakeLists.txt index df9daf7cd..63b6b5322 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,7 +205,7 @@ set(OTHER_SOURCE_FILES src/apps/testapps/testLinkedGeo.c src/apps/testapps/mkRandGeo.c src/apps/testapps/testH3Api.c - src/apps/testapps/testH3SetToLinkedGeo.c + src/apps/testapps/testCellsToLinkedMultiPolygon.c src/apps/testapps/testH3ToLocalIj.c src/apps/testapps/testH3ToLocalIjExhaustive.c src/apps/testapps/testGridDistance.c @@ -227,7 +227,7 @@ set(OTHER_SOURCE_FILES src/apps/fuzzers/fuzzerLatLngToCell.c src/apps/fuzzers/fuzzerCellToLatLng.c src/apps/fuzzers/fuzzerGridDisk.c - src/apps/fuzzers/fuzzerH3SetToLinkedGeo.c + src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c src/apps/fuzzers/fuzzerDistances.c src/apps/fuzzers/fuzzerCellArea.c src/apps/fuzzers/fuzzerExactEdgeLength.c @@ -243,7 +243,7 @@ set(OTHER_SOURCE_FILES src/apps/fuzzers/fuzzerPolygonToCellsNoHoles.c src/apps/benchmarks/benchmarkPolygonToCells.c src/apps/benchmarks/benchmarkPolygon.c - src/apps/benchmarks/benchmarkH3SetToLinkedGeo.c + src/apps/benchmarks/benchmarkCellsToLinkedMultiPolygon.c src/apps/benchmarks/benchmarkGridDiskCells.c src/apps/benchmarks/benchmarkGridPathCells.c src/apps/benchmarks/benchmarkDirectedEdge.c @@ -469,7 +469,7 @@ if(BUILD_FUZZERS) add_h3_fuzzer(fuzzerLatLngToCell src/apps/fuzzers/fuzzerLatLngToCell.c) add_h3_fuzzer(fuzzerCellToLatLng src/apps/fuzzers/fuzzerCellToLatLng.c) add_h3_fuzzer(fuzzerGridDisk src/apps/fuzzers/fuzzerGridDisk.c) - add_h3_fuzzer(fuzzerH3SetToLinkedGeo src/apps/fuzzers/fuzzerH3SetToLinkedGeo.c) + add_h3_fuzzer(fuzzerCellsToLinkedMultiPolygon src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c) add_h3_fuzzer(fuzzerDistances src/apps/fuzzers/fuzzerDistances.c) add_h3_fuzzer(fuzzerCellArea src/apps/fuzzers/fuzzerCellArea.c) add_h3_fuzzer(fuzzerExactEdgeLength src/apps/fuzzers/fuzzerExactEdgeLength.c) @@ -501,7 +501,7 @@ if(BUILD_BENCHMARKS) add_h3_benchmark(benchmarkDirectedEdge src/apps/benchmarks/benchmarkDirectedEdge.c) add_h3_benchmark(benchmarkVertex src/apps/benchmarks/benchmarkVertex.c) add_h3_benchmark(benchmarkIsValidCell src/apps/benchmarks/benchmarkIsValidCell.c) - add_h3_benchmark(benchmarkH3SetToLinkedGeo src/apps/benchmarks/benchmarkH3SetToLinkedGeo.c) + add_h3_benchmark(benchmarkCellsToLinkedMultiPolygon src/apps/benchmarks/benchmarkCellsToLinkedMultiPolygon.c) add_h3_benchmark(benchmarkPolygonToCells src/apps/benchmarks/benchmarkPolygonToCells.c) if(ENABLE_REQUIRES_ALL_SYMBOLS) add_h3_benchmark(benchmarkPolygon src/apps/benchmarks/benchmarkPolygon.c) diff --git a/CMakeTests.cmake b/CMakeTests.cmake index ab0132418..5df6a6f33 100644 --- a/CMakeTests.cmake +++ b/CMakeTests.cmake @@ -179,7 +179,7 @@ if(H3_IS_ROOT_PROJECT AND BUILD_TESTING) add_h3_test(testCellToChildrenSize src/apps/testapps/testCellToChildrenSize.c) add_h3_test(testH3Index src/apps/testapps/testH3Index.c) add_h3_test(testH3Api src/apps/testapps/testH3Api.c) - add_h3_test(testH3SetToLinkedGeo src/apps/testapps/testH3SetToLinkedGeo.c) + add_h3_test(testCellsToLinkedMultiPolygon src/apps/testapps/testCellsToLinkedMultiPolygon.c) add_h3_test(testH3SetToVertexGraph src/apps/testapps/testH3SetToVertexGraph.c) add_h3_test(testLinkedGeo src/apps/testapps/testLinkedGeo.c) add_h3_test(testPolygonToCells src/apps/testapps/testPolygonToCells.c) diff --git a/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md b/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md index e6832fc7c..5784739a3 100644 --- a/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md +++ b/dev-docs/RFCs/v4.0.0/names_for_concepts_types_functions.md @@ -271,10 +271,12 @@ discussion requiring benchmarking, so we will defer that to a ### Functions -| Current name | Proposed name | Notes | -|-----------------------------------|--------------------------|------------------------| -| `h3ToGeoBoundary` | `cellToBoundary` | returns `CellBoundary` | -| *DNE* | `cellToLoop` | returns `GeoLoop` | -| *DNE* | `loopToBoundary` | | -| *DNE* | `boundaryToLoop` | | -| `getH3UnidirectionalEdgeBoundary` | `directedEdgeToBoundary` | returns `CellBoundary` | +| 3.x name | Proposed name | Notes | +|-----------------------------------|-----------------------------|----------------------------| +| `h3ToGeoBoundary` | `cellToBoundary` | returns `CellBoundary` | +| *DNE* | `cellToLoop` | returns `GeoLoop` | +| *DNE* | `loopToBoundary` | | +| *DNE* | `boundaryToLoop` | | +| `getH3UnidirectionalEdgeBoundary` | `directedEdgeToBoundary` | returns `CellBoundary` | +| `h3SetToLinkedGeo` | `cellsToLinkedMultiPolygon` | returns `LinkedGeoPolygon` | +| `h3SetToToMultiPolygon` | `cellsToMultiPolygon` | bindings only | \ No newline at end of file diff --git a/src/apps/benchmarks/benchmarkH3SetToLinkedGeo.c b/src/apps/benchmarks/benchmarkCellsToLinkedMultiPolygon.c similarity index 77% rename from src/apps/benchmarks/benchmarkH3SetToLinkedGeo.c rename to src/apps/benchmarks/benchmarkCellsToLinkedMultiPolygon.c index 300d08118..cb8f9ca1d 100644 --- a/src/apps/benchmarks/benchmarkH3SetToLinkedGeo.c +++ b/src/apps/benchmarks/benchmarkCellsToLinkedMultiPolygon.c @@ -43,19 +43,20 @@ int nestedDonutsCount = 24; BEGIN_BENCHMARKS(); LinkedGeoPolygon polygon; -BENCHMARK(h3SetToLinkedGeoRing2, 10000, { - H3_EXPORT(h3SetToLinkedGeo)(ring2, ring2Count, &polygon); - H3_EXPORT(destroyLinkedPolygon)(&polygon); +BENCHMARK(cellsToLinkedMultiPolygonRing2, 10000, { + H3_EXPORT(cellsToLinkedMultiPolygon)(ring2, ring2Count, &polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); }); -BENCHMARK(h3SetToLinkedGeoDonut, 10000, { - H3_EXPORT(h3SetToLinkedGeo)(donut, donutCount, &polygon); - H3_EXPORT(destroyLinkedPolygon)(&polygon); +BENCHMARK(cellsToLinkedMultiPolygonDonut, 10000, { + H3_EXPORT(cellsToLinkedMultiPolygon)(donut, donutCount, &polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); }); -BENCHMARK(h3SetToLinkedGeoNestedDonuts, 10000, { - H3_EXPORT(h3SetToLinkedGeo)(nestedDonuts, nestedDonutsCount, &polygon); - H3_EXPORT(destroyLinkedPolygon)(&polygon); +BENCHMARK(cellsToLinkedMultiPolygonNestedDonuts, 10000, { + H3_EXPORT(cellsToLinkedMultiPolygon) + (nestedDonuts, nestedDonutsCount, &polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); }); END_BENCHMARKS(); diff --git a/src/apps/fuzzers/fuzzerH3SetToLinkedGeo.c b/src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c similarity index 83% rename from src/apps/fuzzers/fuzzerH3SetToLinkedGeo.c rename to src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c index 9a8ec4d84..689a88f79 100644 --- a/src/apps/fuzzers/fuzzerH3SetToLinkedGeo.c +++ b/src/apps/fuzzers/fuzzerCellsToLinkedMultiPolygon.c @@ -14,7 +14,7 @@ * limitations under the License. */ /** @file - * @brief Fuzzer program for h3SetToLinkedGeo + * @brief Fuzzer program for cellsToLinkedMultiPolygon */ #include "aflHarness.h" @@ -26,10 +26,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int sz = size / sizeof(H3Index); LinkedGeoPolygon polygon; - H3Error err = H3_EXPORT(h3SetToLinkedGeo)(h3Set, sz, &polygon); + H3Error err = H3_EXPORT(cellsToLinkedMultiPolygon)(h3Set, sz, &polygon); if (!err) { - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } return 0; } diff --git a/src/apps/testapps/testH3SetToLinkedGeo.c b/src/apps/testapps/testCellsToLinkedMultiPolygon.c similarity index 82% rename from src/apps/testapps/testH3SetToLinkedGeo.c rename to src/apps/testapps/testCellsToLinkedMultiPolygon.c index e1b7184af..65bbdbc04 100644 --- a/src/apps/testapps/testH3SetToLinkedGeo.c +++ b/src/apps/testapps/testCellsToLinkedMultiPolygon.c @@ -20,15 +20,16 @@ #include "test.h" #include "utility.h" -SUITE(h3SetToLinkedGeo) { +SUITE(cellsToLinkedMultiPolygon) { TEST(empty) { LinkedGeoPolygon polygon; - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(NULL, 0, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(NULL, 0, &polygon)); t_assert(countLinkedLoops(&polygon) == 0, "No loops added to polygon"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(singleHex) { @@ -36,13 +37,14 @@ SUITE(h3SetToLinkedGeo) { H3Index set[] = {0x890dab6220bffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedLoops(&polygon) == 1, "1 loop added to polygon"); t_assert(countLinkedCoords(polygon.first) == 6, "6 coords added to loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(invalid) { @@ -50,8 +52,8 @@ SUITE(h3SetToLinkedGeo) { H3Index set[] = {0xfffffffffffffff}; int numHexes = ARRAY_SIZE(set); - t_assert(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon) == - E_CELL_INVALID, + t_assert(H3_EXPORT(cellsToLinkedMultiPolygon)( + set, numHexes, &polygon) == E_CELL_INVALID, "Invalid set fails"); } @@ -60,13 +62,14 @@ SUITE(h3SetToLinkedGeo) { H3Index set[] = {0x8928308291bffff, 0x89283082957ffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedLoops(&polygon) == 1, "1 loop added to polygon"); t_assert(countLinkedCoords(polygon.first) == 10, "All coords added to loop except 2 shared"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } // TODO: This test asserts incorrect behavior - we should be creating @@ -77,7 +80,8 @@ SUITE(h3SetToLinkedGeo) { H3Index set[] = {0x8928308291bffff, 0x89283082943ffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedPolygons(&polygon) == 2, "2 polygons added"); t_assert(countLinkedLoops(&polygon) == 1, @@ -89,7 +93,7 @@ SUITE(h3SetToLinkedGeo) { t_assert(countLinkedCoords(polygon.next->first) == 6, "All coords for one hex added to second polygon"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(contiguous3) { @@ -98,13 +102,14 @@ SUITE(h3SetToLinkedGeo) { 0x8928308289bffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedLoops(&polygon) == 1, "1 loop added to polygon"); t_assert(countLinkedCoords(polygon.first) == 12, "All coords added to loop except 6 shared"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(hole) { @@ -114,7 +119,7 @@ SUITE(h3SetToLinkedGeo) { 0x8928308288fffff, 0x89283082883ffff}; int numHexes = ARRAY_SIZE(set); - H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon); + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon); t_assert(countLinkedLoops(&polygon) == 2, "2 loops added to polygon"); t_assert(countLinkedCoords(polygon.first) == 6 * 3, @@ -122,7 +127,7 @@ SUITE(h3SetToLinkedGeo) { t_assert(countLinkedCoords(polygon.first->next) == 6, "All inner coords added to second loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(pentagon) { @@ -130,13 +135,14 @@ SUITE(h3SetToLinkedGeo) { H3Index set[] = {0x851c0003fffffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedLoops(&polygon) == 1, "1 loop added to polygon"); t_assert(countLinkedCoords(polygon.first) == 10, "10 coords (distorted pentagon) added to loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(twoRing) { @@ -152,13 +158,14 @@ SUITE(h3SetToLinkedGeo) { 0x89300628303ffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedLoops(&polygon) == 1, "1 loop added to polygon"); t_assert(countLinkedCoords(polygon.first) == (6 * (2 * 2 + 1)), "Expected number of coords added to loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(twoRingUnordered) { @@ -174,13 +181,14 @@ SUITE(h3SetToLinkedGeo) { 0x893006283c7ffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedLoops(&polygon) == 1, "1 loop added to polygon"); t_assert(countLinkedCoords(polygon.first) == (6 * (2 * 2 + 1)), "Expected number of coords added to loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(nestedDonut) { @@ -197,7 +205,8 @@ SUITE(h3SetToLinkedGeo) { 0x892830828b3ffff, 0x89283082887ffff, 0x89283082883ffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); // Note that the polygon order here is arbitrary, making this test // somewhat brittle, but it's difficult to assert correctness otherwise @@ -215,7 +224,7 @@ SUITE(h3SetToLinkedGeo) { t_assert(countLinkedCoords(polygon.next->first->next) == 6, "Got expected inner loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(nestedDonutTransmeridian) { @@ -232,7 +241,8 @@ SUITE(h3SetToLinkedGeo) { 0x897eb572287ffff, 0x897eb572283ffff, 0x897eb57229bffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); // Note that the polygon order here is arbitrary, making this test // somewhat brittle, but it's difficult to assert correctness otherwise @@ -250,7 +260,7 @@ SUITE(h3SetToLinkedGeo) { t_assert(countLinkedCoords(polygon.next->first->next) == 30, "Got expected big inner loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(contiguous2distorted) { @@ -258,20 +268,22 @@ SUITE(h3SetToLinkedGeo) { H3Index set[] = {0x894cc5365afffff, 0x894cc536537ffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedLoops(&polygon) == 1, "1 loop added to polygon"); t_assert(countLinkedCoords(polygon.first) == 12, "All coords added to loop except 2 shared"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(negativeHashedCoordinates) { LinkedGeoPolygon polygon; H3Index set[] = {0x88ad36c547fffff, 0x88ad36c467fffff}; int numHexes = ARRAY_SIZE(set); - t_assertSuccess(H3_EXPORT(h3SetToLinkedGeo)(set, numHexes, &polygon)); + t_assertSuccess( + H3_EXPORT(cellsToLinkedMultiPolygon)(set, numHexes, &polygon)); t_assert(countLinkedPolygons(&polygon) == 2, "2 polygons added"); t_assert(countLinkedLoops(&polygon) == 1, @@ -283,6 +295,6 @@ SUITE(h3SetToLinkedGeo) { t_assert(countLinkedCoords(polygon.next->first) == 6, "All coords for one hex added to second polygon"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } } diff --git a/src/apps/testapps/testLinkedGeo.c b/src/apps/testapps/testLinkedGeo.c index 880943974..d83765624 100644 --- a/src/apps/testapps/testLinkedGeo.c +++ b/src/apps/testapps/testLinkedGeo.c @@ -67,7 +67,7 @@ SUITE(linkedGeo) { t_assert(countLinkedPolygons(polygon) == 2, "Polygon count correct"); - H3_EXPORT(destroyLinkedPolygon)(polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(polygon); free(polygon); } } diff --git a/src/apps/testapps/testPolygon.c b/src/apps/testapps/testPolygon.c index d6ec5a93d..9f3015d90 100644 --- a/src/apps/testapps/testPolygon.c +++ b/src/apps/testapps/testPolygon.c @@ -295,7 +295,7 @@ SUITE(polygon) { t_assert(countLinkedLoops(&polygon) == 1, "Loop count correct"); t_assert(polygon.first == outer, "Got expected loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(normalizeMultiPolygonTwoOuterLoops) { @@ -325,7 +325,7 @@ SUITE(polygon) { t_assert(countLinkedLoops(polygon.next) == 1, "Loop count on second polygon correct"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(normalizeMultiPolygonOneHole) { @@ -355,7 +355,7 @@ SUITE(polygon) { t_assert(polygon.first == outer, "Got expected outer loop"); t_assert(polygon.first->next == inner, "Got expected inner loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(normalizeMultiPolygonTwoHoles) { @@ -392,7 +392,7 @@ SUITE(polygon) { t_assert(countLinkedLoops(&polygon) == 3, "Loop count on first polygon correct"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(normalizeMultiPolygonTwoDonuts) { @@ -440,7 +440,7 @@ SUITE(polygon) { t_assert(countLinkedCoords(polygon.next->first->next) == 3, "Got expected inner loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(normalizeMultiPolygonNestedDonuts) { @@ -484,7 +484,7 @@ SUITE(polygon) { t_assert(polygon.next->first == outer, "Got expected outer loop"); t_assert(polygon.next->first->next == inner, "Got expected inner loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(normalizeMultiPolygonNoOuterLoops) { @@ -513,7 +513,7 @@ SUITE(polygon) { t_assert(countLinkedLoops(&polygon) == 0, "Loop count as expected with invalid input"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(normalizeMultiPolygonAlreadyNormalized) { @@ -548,7 +548,7 @@ SUITE(polygon) { "Loop count on second polygon correct"); t_assert(polygon.next->first == outer2, "Got expected outer loop"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } TEST(normalizeMultiPolygon_unassignedHole) { @@ -573,6 +573,6 @@ SUITE(polygon) { t_assert(result == NORMALIZATION_ERR_UNASSIGNED_HOLES, "Expected error code returned"); - H3_EXPORT(destroyLinkedPolygon)(&polygon); + H3_EXPORT(destroyLinkedMultiPolygon)(&polygon); } } diff --git a/src/h3lib/include/h3api.h.in b/src/h3lib/include/h3api.h.in index 64df1e978..a89d8dc31 100644 --- a/src/h3lib/include/h3api.h.in +++ b/src/h3lib/include/h3api.h.in @@ -282,17 +282,17 @@ DECLSPEC H3Error H3_EXPORT(polygonToCells)(const GeoPolygon *geoPolygon, int res, H3Index *out); /** @} */ -/** @defgroup h3SetToMultiPolygon h3SetToMultiPolygon - * Functions for h3SetToMultiPolygon (currently a binding-only concept) +/** @defgroup cellsToMultiPolygon cellsToMultiPolygon + * Functions for cellsToMultiPolygon (currently a binding-only concept) * @{ */ /** @brief Create a LinkedGeoPolygon from a set of contiguous hexagons */ -DECLSPEC H3Error H3_EXPORT(h3SetToLinkedGeo)(const H3Index *h3Set, - const int numHexes, - LinkedGeoPolygon *out); +DECLSPEC H3Error H3_EXPORT(cellsToLinkedMultiPolygon)(const H3Index *h3Set, + const int numHexes, + LinkedGeoPolygon *out); /** @brief Free all memory created for a LinkedGeoPolygon */ -DECLSPEC void H3_EXPORT(destroyLinkedPolygon)(LinkedGeoPolygon *polygon); +DECLSPEC void H3_EXPORT(destroyLinkedMultiPolygon)(LinkedGeoPolygon *polygon); /** @} */ /** @defgroup degsToRads degsToRads diff --git a/src/h3lib/lib/algos.c b/src/h3lib/lib/algos.c index 58dd931ae..888526751 100644 --- a/src/h3lib/lib/algos.c +++ b/src/h3lib/lib/algos.c @@ -1082,8 +1082,9 @@ H3Error h3SetToVertexGraph(const H3Index *h3Set, const int numHexes, /** * Internal: Create a LinkedGeoPolygon from a vertex graph. It is the - * responsibility of the caller to call destroyLinkedPolygon on the populated - * linked geo structure, or the memory for that structure will not be freed. + * responsibility of the caller to call destroyLinkedMultiPolygon on the + * populated linked geo structure, or the memory for that structure will not be + * freed. * @private * @param graph Input graph * @param out Output polygon @@ -1112,9 +1113,9 @@ void _vertexGraphToLinkedGeo(VertexGraph *graph, LinkedGeoPolygon *out) { * Polygon outlines will follow GeoJSON MultiPolygon order: Each polygon will * have one outer loop, which is first in the list, followed by any holes. * - * It is the responsibility of the caller to call destroyLinkedPolygon on the - * populated linked geo structure, or the memory for that structure will - * not be freed. + * It is the responsibility of the caller to call destroyLinkedMultiPolygon on + * the populated linked geo structure, or the memory for that structure will not + * be freed. * * It is expected that all hexagons in the set have the same resolution and * that the set contains no duplicates. Behavior is undefined if duplicates @@ -1125,8 +1126,9 @@ void _vertexGraphToLinkedGeo(VertexGraph *graph, LinkedGeoPolygon *out) { * @param numHexes Number of hexagons in set * @param out Output polygon */ -H3Error H3_EXPORT(h3SetToLinkedGeo)(const H3Index *h3Set, const int numHexes, - LinkedGeoPolygon *out) { +H3Error H3_EXPORT(cellsToLinkedMultiPolygon)(const H3Index *h3Set, + const int numHexes, + LinkedGeoPolygon *out) { VertexGraph graph; H3Error err = h3SetToVertexGraph(h3Set, numHexes, &graph); if (err) { diff --git a/src/h3lib/lib/linkedGeo.c b/src/h3lib/lib/linkedGeo.c index f925aad0b..87e58a958 100644 --- a/src/h3lib/lib/linkedGeo.c +++ b/src/h3lib/lib/linkedGeo.c @@ -107,7 +107,7 @@ void destroyLinkedGeoLoop(LinkedGeoLoop *loop) { * responsible for freeing memory allocated to input polygon struct. * @param polygon Pointer to the first polygon in the structure */ -void H3_EXPORT(destroyLinkedPolygon)(LinkedGeoPolygon *polygon) { +void H3_EXPORT(destroyLinkedMultiPolygon)(LinkedGeoPolygon *polygon) { // flag to skip the input polygon bool skip = true; LinkedGeoPolygon *nextPolygon; @@ -352,7 +352,7 @@ int normalizeMultiPolygon(LinkedGeoPolygon *root) { // If we can't find a polygon (possible with invalid input), then // we need to release the memory for the hole, because the loop has // been unlinked from the root and the caller will no longer have - // a way to destroy it with destroyLinkedPolygon. + // a way to destroy it with destroyLinkedMultiPolygon. destroyLinkedGeoLoop(innerLoops[i]); H3_MEMORY(free)(innerLoops[i]); resultCode = NORMALIZATION_ERR_UNASSIGNED_HOLES; diff --git a/website/docs/library/migration-3.x/functions.md b/website/docs/library/migration-3.x/functions.md index 53ae79baf..600e5752a 100644 --- a/website/docs/library/migration-3.x/functions.md +++ b/website/docs/library/migration-3.x/functions.md @@ -147,10 +147,12 @@ the passed-in cell. ### Functions -| 3.x name | 4.0.0 name | Notes | -|-----------------------------------|--------------------------|------------------------| -| `h3ToGeoBoundary` | `cellToBoundary` | returns `CellBoundary` | -| *DNE* | `cellToLoop` | returns `GeoLoop` | -| *DNE* | `loopToBoundary` | | -| *DNE* | `boundaryToLoop` | | -| `getH3UnidirectionalEdgeBoundary` | `directedEdgeToBoundary` | returns `CellBoundary` | +| 3.x name | 4.0.0 name | Notes | +|-----------------------------------|-----------------------------|----------------------------| +| `h3ToGeoBoundary` | `cellToBoundary` | returns `CellBoundary` | +| *DNE* | `cellToLoop` | returns `GeoLoop` | +| *DNE* | `loopToBoundary` | | +| *DNE* | `boundaryToLoop` | | +| `getH3UnidirectionalEdgeBoundary` | `directedEdgeToBoundary` | returns `CellBoundary` | +| `h3SetToLinkedGeo` | `cellsToLinkedMultiPolygon` | returns `LinkedGeoPolygon` | +| `h3SetToToMultiPolygon` | `cellsToMultiPolygon` | bindings only | \ No newline at end of file