From e262ed0b6d8675fdbd7b306749b2865e7e8965f8 Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Thu, 5 Dec 2024 09:48:05 -0800 Subject: [PATCH 1/7] upgrade to h3 v4.2.0 --- README.md | 2 +- h3 | 2 +- test/sql/h3/h3_functions_vertex.test | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 08341e4..9ccbf73 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Extension Test](https://github.com/isaacbrodsky/h3-duckdb/actions/workflows/test.yml/badge.svg)](https://github.com/isaacbrodsky/h3-duckdb/actions/workflows/test.yml) [![DuckDB Version](https://img.shields.io/static/v1?label=duckdb&message=v1.1.3&color=blue)](https://github.com/duckdb/duckdb/releases/tag/v1.1.3) -[![H3 Version](https://img.shields.io/static/v1?label=h3&message=v4.1.0&color=blue)](https://github.com/uber/h3/releases/tag/v4.1.0) +[![H3 Version](https://img.shields.io/static/v1?label=h3&message=v4.2.0&color=blue)](https://github.com/uber/h3/releases/tag/v4.2.0) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE) This is a [DuckDB](https://duckdb.org) extension that adds support for the [H3 discrete global grid system](https://github.com/uber/h3/), so you can index points and geometries to hexagons in SQL. diff --git a/h3 b/h3 index 5c91149..2d8a62d 160000 --- a/h3 +++ b/h3 @@ -1 +1 @@ -Subproject commit 5c91149104ac02c4f06faa4fc557e69cf6b131ef +Subproject commit 2d8a62d5fe456bba2af7ca0be7efe9754f1dd25b diff --git a/test/sql/h3/h3_functions_vertex.test b/test/sql/h3/h3_functions_vertex.test index 1d26ee6..cc7d1de 100644 --- a/test/sql/h3/h3_functions_vertex.test +++ b/test/sql/h3/h3_functions_vertex.test @@ -73,22 +73,22 @@ NULL query I SELECT h3_vertex_to_latlng(h3_string_to_h3('2222597fffffffff')); ---- -[39.38084284181813, 88.57496213785487] +[39.38084284181812, 88.57496213785487] query I SELECT h3_vertex_to_latlng(cast(h3_string_to_h3('2222597fffffffff') as bigint)); ---- -[39.38084284181813, 88.57496213785487] +[39.38084284181812, 88.57496213785487] query I SELECT h3_vertex_to_lat(h3_string_to_h3('2222597fffffffff')); ---- -39.38084284181813 +39.38084284181812 query I SELECT h3_vertex_to_lat(cast(h3_string_to_h3('2222597fffffffff') as bigint)); ---- -39.38084284181813 +39.38084284181812 query I SELECT h3_vertex_to_lng(h3_string_to_h3('2222597fffffffff')); @@ -123,12 +123,12 @@ NULL query I SELECT h3_vertex_to_latlng('2222597fffffffff'); ---- -[39.38084284181813, 88.57496213785487] +[39.38084284181812, 88.57496213785487] query I SELECT h3_vertex_to_lat('2222597fffffffff'); ---- -39.38084284181813 +39.38084284181812 query I SELECT h3_vertex_to_lng('2222597fffffffff'); From 264434f3540c38f9b57dd144e8e995c2c7593532 Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Thu, 5 Dec 2024 09:54:18 -0800 Subject: [PATCH 2/7] add experimental functions --- README.md | 2 + src/h3_regions.cpp | 207 +++++++++++++++++++++++++++++++++++ src/include/h3_functions.hpp | 4 + 3 files changed, 213 insertions(+) diff --git a/README.md b/README.md index 9ccbf73..8a2a6cc 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ one to use. The unsigned and signed APIs are identical. All functions also suppo | `h3_cells_to_multi_polygon_wkt` | Convert a set of cells to multipolygon WKT | `h3_polygon_wkt_to_cells` | Convert polygon WKT to a set of cells | `h3_polygon_wkt_to_cells_string` | Convert polygon WKT to a set of cells (returns VARCHAR) +| `h3_polygon_wkt_to_cells_experimental` | Convert polygon WKT to a set of cells, new algorithm +| `h3_polygon_wkt_to_cells_experimental_string` | Convert polygon WKT to a set of cells, new algorithm (returns VARCHAR) # Alternative download / install diff --git a/src/h3_regions.cpp b/src/h3_regions.cpp index 14bc297..3266e90 100644 --- a/src/h3_regions.cpp +++ b/src/h3_regions.cpp @@ -360,6 +360,199 @@ static void PolygonWktToCellsVarcharFunction(DataChunk &args, }); } +static void PolygonWktToCellsExperimentalFunction(DataChunk &args, ExpressionState &state, + Vector &result) { + // TODO: Note this function is not fully noexcept -- some invalid WKT strings + // will throw, others will return empty lists. + TernaryExecutor::Execute( + args.data[0], args.data[1], args.data[2], result, args.size(), + [&](string_t input, string_t flagsStr, int res) { + GeoPolygon polygon; + int32_t flags = 0; + + std::string str = input.GetString(); + + uint64_t offset = ListVector::GetListSize(result); + + // TODO: Make flags easier to work with + if (flagsStr == "CONTAINMENT_CENTER") { + flags = 0; + } else if (flagsStr == "CONTAINMENT_FULL") { + flags = 1; + } else if (flagsStr == "CONTAINMENT_OVERLAPPING") { + flags = 2; + } else { + // Invalid flags input + return list_entry_t(offset, 0); + } + + if (str.rfind(POLYGON, 0) != 0) { + return list_entry_t(offset, 0); + } + + size_t strIndex = POLYGON.length(); + strIndex = whitespace(str, strIndex); + + if (str.rfind(EMPTY, strIndex) == strIndex) { + return list_entry_t(offset, 0); + } + + if (str[strIndex] == '(') { + strIndex++; + strIndex = whitespace(str, strIndex); + + auto outerVerts = duckdb::make_shared_ptr>(); + strIndex = readGeoLoop(str, strIndex, outerVerts, polygon.geoloop); + + std::vector holes; + std::vector>> holesVerts; + while (strIndex < str.length() && str[strIndex] == ',') { + strIndex++; + strIndex = whitespace(str, strIndex); + if (str[strIndex] == '(') { + GeoLoop hole; + auto verts = duckdb::make_shared_ptr>(); + strIndex = readGeoLoop(str, strIndex, verts, hole); + holes.push_back(hole); + holesVerts.push_back(verts); + } else { + throw InvalidInputException(StringUtil::Format( + "Invalid WKT: expected a hole loop '(' after ',' at pos %lu", + strIndex)); + } + } + if (str[strIndex] != ')') { + throw InvalidInputException(StringUtil::Format( + "Invalid WKT: expected a hole loop ',' or final ')' at pos %lu", + strIndex)); + } + + polygon.numHoles = holes.size(); + polygon.holes = holes.data(); + + int64_t numCells = 0; + H3Error err = maxPolygonToCellsSizeExperimental(&polygon, res, flags, &numCells); + if (err) { + return list_entry_t(offset, 0); + } else { + std::vector out(numCells); + H3Error err2 = polygonToCellsExperimental(&polygon, res, flags, numCells, out.data()); + if (err2) { + return list_entry_t(offset, 0); + } else { + uint64_t actual = 0; + for (H3Index outCell : out) { + if (outCell != H3_NULL) { + ListVector::PushBack(result, Value::UBIGINT(outCell)); + actual++; + } + } + return list_entry_t(offset, actual); + } + } + } + return list_entry_t(offset, 0); + }); +} + +static void PolygonWktToCellsExperimentalVarcharFunction(DataChunk &args, + ExpressionState &state, + Vector &result) { + // TODO: Note this function is not fully noexcept -- some invalid WKT strings + // will throw, others will return empty lists. + TernaryExecutor::Execute( + args.data[0], args.data[1], args.data[2], result, args.size(), + [&](string_t input, string_t flagsStr, int res) { + GeoPolygon polygon; + int32_t flags = 0; + + std::string str = input.GetString(); + + uint64_t offset = ListVector::GetListSize(result); + + // TODO: Make flags easier to work with + if (flagsStr == "CONTAINMENT_CENTER") { + flags = 0; + } else if (flagsStr == "CONTAINMENT_FULL") { + flags = 1; + } else if (flagsStr == "CONTAINMENT_OVERLAPPING") { + flags = 2; + } else { + // Invalid flags input + return list_entry_t(offset, 0); + } + + if (str.rfind(POLYGON, 0) != 0) { + return list_entry_t(offset, 0); + } + + size_t strIndex = POLYGON.length(); + strIndex = whitespace(str, strIndex); + + if (str.rfind(EMPTY, strIndex) == strIndex) { + return list_entry_t(offset, 0); + } + + if (str[strIndex] == '(') { + strIndex++; + strIndex = whitespace(str, strIndex); + + auto outerVerts = duckdb::make_shared_ptr>(); + strIndex = readGeoLoop(str, strIndex, outerVerts, polygon.geoloop); + + std::vector holes; + std::vector>> holesVerts; + while (strIndex < str.length() && str[strIndex] == ',') { + strIndex++; + strIndex = whitespace(str, strIndex); + if (str[strIndex] == '(') { + GeoLoop hole; + auto verts = duckdb::make_shared_ptr>(); + strIndex = readGeoLoop(str, strIndex, verts, hole); + holes.push_back(hole); + holesVerts.push_back(verts); + } else { + throw InvalidInputException(StringUtil::Format( + "Invalid WKT: expected a hole loop '(' after ',' at pos %lu", + strIndex)); + } + } + if (str[strIndex] != ')') { + throw InvalidInputException(StringUtil::Format( + "Invalid WKT: expected a hole loop ',' or final ')' at pos %lu", + strIndex)); + } + + polygon.numHoles = holes.size(); + polygon.holes = holes.data(); + + int64_t numCells = 0; + H3Error err = maxPolygonToCellsSizeExperimental(&polygon, res, flags, &numCells); + if (err) { + return list_entry_t(offset, 0); + } else { + std::vector out(numCells); + H3Error err2 = polygonToCellsExperimental(&polygon, res, flags, numCells, out.data()); + if (err2) { + return list_entry_t(offset, 0); + } else { + uint64_t actual = 0; + for (H3Index outCell : out) { + if (outCell != H3_NULL) { + auto str = StringUtil::Format("%llx", outCell); + string_t strAsStr = string_t(strdup(str.c_str()), str.size()); + ListVector::PushBack(result, strAsStr); + actual++; + } + } + return list_entry_t(offset, actual); + } + } + } + return list_entry_t(offset, 0); + }); +} + CreateScalarFunctionInfo H3Functions::GetCellsToMultiPolygonWktFunction() { ScalarFunctionSet funcs("h3_cells_to_multi_polygon_wkt"); funcs.AddFunction(ScalarFunction( @@ -393,4 +586,18 @@ CreateScalarFunctionInfo H3Functions::GetPolygonWktToCellsVarcharFunction() { PolygonWktToCellsVarcharFunction)); } +CreateScalarFunctionInfo H3Functions::GetPolygonWktToCellsExperimentalFunction() { + return CreateScalarFunctionInfo(ScalarFunction( + "h3_polygon_wkt_to_cells_experimental", {LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::INTEGER}, + LogicalType::LIST(LogicalType::UBIGINT), PolygonWktToCellsExperimentalFunction)); +} + +CreateScalarFunctionInfo H3Functions::GetPolygonWktToCellsExperimentalVarcharFunction() { + return CreateScalarFunctionInfo( + ScalarFunction("h3_polygon_wkt_to_cells_experimental_string", + {LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::INTEGER}, + LogicalType::LIST(LogicalType::VARCHAR), + PolygonWktToCellsExperimentalVarcharFunction)); +} + } // namespace duckdb diff --git a/src/include/h3_functions.hpp b/src/include/h3_functions.hpp index e2dde89..cd5a00d 100644 --- a/src/include/h3_functions.hpp +++ b/src/include/h3_functions.hpp @@ -90,6 +90,8 @@ class H3Functions { functions.push_back(GetCellsToMultiPolygonWktFunction()); functions.push_back(GetPolygonWktToCellsFunction()); functions.push_back(GetPolygonWktToCellsVarcharFunction()); + functions.push_back(GetPolygonWktToCellsExperimentalFunction()); + functions.push_back(GetPolygonWktToCellsExperimentalVarcharFunction()); return functions; } @@ -168,6 +170,8 @@ class H3Functions { static CreateScalarFunctionInfo GetCellsToMultiPolygonWktFunction(); static CreateScalarFunctionInfo GetPolygonWktToCellsFunction(); static CreateScalarFunctionInfo GetPolygonWktToCellsVarcharFunction(); + static CreateScalarFunctionInfo GetPolygonWktToCellsExperimentalFunction(); + static CreateScalarFunctionInfo GetPolygonWktToCellsExperimentalVarcharFunction(); static void AddAliases(vector names, CreateScalarFunctionInfo fun, vector &functions) { From f79b8c1629b689f3c3212888df58c44873fa9805 Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Fri, 6 Dec 2024 12:52:53 -0800 Subject: [PATCH 3/7] round --- test/sql/h3/h3_functions_vertex.test | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/sql/h3/h3_functions_vertex.test b/test/sql/h3/h3_functions_vertex.test index cc7d1de..5986497 100644 --- a/test/sql/h3/h3_functions_vertex.test +++ b/test/sql/h3/h3_functions_vertex.test @@ -71,34 +71,34 @@ SELECT h3_cell_to_vertex(cast(h3_string_to_h3('823d6ffffffffff') as bigint), -1) NULL query I -SELECT h3_vertex_to_latlng(h3_string_to_h3('2222597fffffffff')); +SELECT list_transform(h3_vertex_to_latlng(h3_string_to_h3('2222597fffffffff')), x -> round(x, 12)); ---- -[39.38084284181812, 88.57496213785487] +[39.380842841818, 88.574962137855] query I -SELECT h3_vertex_to_latlng(cast(h3_string_to_h3('2222597fffffffff') as bigint)); +SELECT list_transform(h3_vertex_to_latlng(cast(h3_string_to_h3('2222597fffffffff') as bigint)), x -> round(x, 12)); ---- -[39.38084284181812, 88.57496213785487] +[39.380842841818, 88.574962137855] query I -SELECT h3_vertex_to_lat(h3_string_to_h3('2222597fffffffff')); +SELECT round(h3_vertex_to_lat(h3_string_to_h3('2222597fffffffff')), 12); ---- -39.38084284181812 +39.380842841818 query I -SELECT h3_vertex_to_lat(cast(h3_string_to_h3('2222597fffffffff') as bigint)); +SELECT round(h3_vertex_to_lat(cast(h3_string_to_h3('2222597fffffffff') as bigint)), 12); ---- -39.38084284181812 +39.380842841818 query I -SELECT h3_vertex_to_lng(h3_string_to_h3('2222597fffffffff')); +SELECT round(h3_vertex_to_lng(h3_string_to_h3('2222597fffffffff')), 12); ---- -88.57496213785487 +88.574962137855 query I -SELECT h3_vertex_to_lng(cast(h3_string_to_h3('2222597fffffffff') as bigint)); +SELECT round(h3_vertex_to_lng(cast(h3_string_to_h3('2222597fffffffff') as bigint)), 12); ---- -88.57496213785487 +88.574962137855 query I SELECT h3_cell_to_vertexes('823d6ffffffffff'); @@ -121,16 +121,16 @@ SELECT h3_cell_to_vertex('823d6ffffffffff', -1); NULL query I -SELECT h3_vertex_to_latlng('2222597fffffffff'); +SELECT list_transform(h3_vertex_to_latlng('2222597fffffffff'), x -> round(x, 12)); ---- -[39.38084284181812, 88.57496213785487] +[39.380842841818, 88.574962137855] query I -SELECT h3_vertex_to_lat('2222597fffffffff'); +SELECT round(h3_vertex_to_lat('2222597fffffffff'), 12); ---- -39.38084284181812 +39.380842841818 query I -SELECT h3_vertex_to_lng('2222597fffffffff'); +SELECT round(h3_vertex_to_lng('2222597fffffffff'), 12); ---- -88.57496213785487 +88.574962137855 From 8f9f4e9e20a4f654e97d5ed0ab86511201180c21 Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Fri, 6 Dec 2024 13:47:32 -0800 Subject: [PATCH 4/7] upgrade ci tools --- extension-ci-tools | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extension-ci-tools b/extension-ci-tools index 83f847f..5121955 160000 --- a/extension-ci-tools +++ b/extension-ci-tools @@ -1 +1 @@ -Subproject commit 83f847f8467a760f6c66dc7996c13300210220a8 +Subproject commit 5121955637acac20ba5ef7abf0b8957b0f0c849b From 965bb73f369555a7162ee10c01c872b6912b44fc Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Fri, 6 Dec 2024 17:31:19 -0800 Subject: [PATCH 5/7] upgrade artifact download --- .github/workflows/_extension_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/_extension_deploy.yml b/.github/workflows/_extension_deploy.yml index d6c5b4d..0c8b129 100644 --- a/.github/workflows/_extension_deploy.yml +++ b/.github/workflows/_extension_deploy.yml @@ -92,7 +92,7 @@ jobs: cd duckdb git checkout ${{ inputs.duckdb_version }} - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: ${{ inputs.extension_name }}-${{ inputs.duckdb_version }}-extension-${{matrix.duckdb_arch}}${{inputs.artifact_postfix}}${{startsWith(matrix.duckdb, 'wasm') && '.wasm' || ''}} path: | From 179c35ca19704de668b8cbe93f090a1ec60d5b60 Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Sun, 8 Dec 2024 16:45:30 -0800 Subject: [PATCH 6/7] test --- src/h3_regions.cpp | 4 + test/sql/h3/h3_functions_regions.test | 105 ++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) diff --git a/src/h3_regions.cpp b/src/h3_regions.cpp index 3266e90..3ed586f 100644 --- a/src/h3_regions.cpp +++ b/src/h3_regions.cpp @@ -381,6 +381,8 @@ static void PolygonWktToCellsExperimentalFunction(DataChunk &args, ExpressionSta flags = 1; } else if (flagsStr == "CONTAINMENT_OVERLAPPING") { flags = 2; + } else if (flagsStr == "CONTAINMENT_OVERLAPPING_BBOX") { + flags = 3; } else { // Invalid flags input return list_entry_t(offset, 0); @@ -477,6 +479,8 @@ static void PolygonWktToCellsExperimentalVarcharFunction(DataChunk &args, flags = 1; } else if (flagsStr == "CONTAINMENT_OVERLAPPING") { flags = 2; + } else if (flagsStr == "CONTAINMENT_OVERLAPPING_BBOX") { + flags = 3; } else { // Invalid flags input return list_entry_t(offset, 0); diff --git a/test/sql/h3/h3_functions_regions.test b/test/sql/h3/h3_functions_regions.test index 9bf754f..7039ebd 100644 --- a/test/sql/h3/h3_functions_regions.test +++ b/test/sql/h3/h3_functions_regions.test @@ -274,3 +274,108 @@ query I select h3_polygon_wkt_to_cells_string('POLYGON EMPTY', 9); ---- [] + +query I +select length(h3_polygon_wkt_to_cells_experimental('POLYGON', 'CONTAINMENT_CENTER', 9)); +---- +0 + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'AAA', 9); +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_CENTER', 5) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_FULL', 5) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING', 5) +---- +[599685771850416127, 599685772924157951, 599685776145383423, 599685777219125247] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 5) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_CENTER', 5) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_FULL', 5) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING', 5) +---- +[85283083fffffff, 85283087fffffff, 85283093fffffff, 85283097fffffff] + +query I +select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 5) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_FULL', 5) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING', 5) +---- +[599685771850416127, 599685772924157951, 599685776145383423, 599685777219125247] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 5) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_CENTER', 6) +---- +[604189371075133439, 604189371209351167, 604189372417310719, 604189376175407103, 604189376309624831] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_FULL', 6) +---- +[604189371209351167, 604189376309624831] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING', 6) +---- +[604189370538262527, 604189370672480255, 604189371075133439, 604189371209351167, 604189372148875263, 604189372417310719, 604189374967447551, 604189375235883007, 604189375906971647, 604189376041189375, 604189376175407103, 604189376309624831] + +query I +select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 6) +---- +[] + +query I +select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_CENTER', 6) +---- +[862830827ffffff, 86283082fffffff, 862830877ffffff, 862830957ffffff, 86283095fffffff] + +query I +select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_FULL', 6) +---- +[86283082fffffff, 86283095fffffff] + +query I +select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING', 6) +---- +[862830807ffffff, 86283080fffffff, 862830827ffffff, 86283082fffffff, 862830867ffffff, 862830877ffffff, 86283090fffffff, 86283091fffffff, 862830947ffffff, 86283094fffffff, 862830957ffffff, 86283095fffffff] + +query I +select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 6) +---- +[] \ No newline at end of file From 005b472046f59da93f9c323c50e3383e1d5b1862 Mon Sep 17 00:00:00 2001 From: Isaac Brodsky Date: Sun, 8 Dec 2024 17:12:45 -0800 Subject: [PATCH 7/7] fix test --- test/sql/h3/h3_functions_regions.test | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/sql/h3/h3_functions_regions.test b/test/sql/h3/h3_functions_regions.test index 7039ebd..94fcc72 100644 --- a/test/sql/h3/h3_functions_regions.test +++ b/test/sql/h3/h3_functions_regions.test @@ -303,7 +303,7 @@ select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81 query I select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 5) ---- -[] +[599685771850416127, 599685772924157951, 599685773997899775, 599685775071641599, 599685776145383423, 599685777219125247, 599685784735318015, 599686100415414271, 599686104710381567] query I select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_CENTER', 5) @@ -323,7 +323,7 @@ select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.5340121537441 query I select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 5) ---- -[] +[85283083fffffff, 85283087fffffff, 8528308bfffffff, 8528308ffffffff, 85283093fffffff, 85283097fffffff, 852830b3fffffff, 8528354bfffffff, 8528355bfffffff] query I select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_FULL', 5) @@ -338,7 +338,7 @@ select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81 query I select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 5) ---- -[] +[599685771850416127, 599685772924157951, 599685773997899775, 599685775071641599, 599685776145383423, 599685777219125247, 599685784735318015, 599686100415414271, 599686104710381567] query I select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_CENTER', 6) @@ -358,7 +358,7 @@ select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81 query I select h3_polygon_wkt_to_cells_experimental('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 6) ---- -[] +[604189370538262527, 604189370672480255, 604189370940915711, 604189371075133439, 604189371209351167, 604189371343568895, 604189371612004351, 604189372148875263, 604189372283092991, 604189372417310719, 604189374967447551, 604189375235883007, 604189375906971647, 604189376041189375, 604189376175407103, 604189376309624831, 604189376578060287, 604189376712278015] query I select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_CENTER', 6) @@ -378,4 +378,4 @@ select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.5340121537441 query I select h3_polygon_wkt_to_cells_experimental_string('POLYGON ((-122.53401215374411 37.81666158907579, -122.53401215374411 37.70454536656959, -122.3479361380842 37.70454536656959, -122.3479361380842 37.81666158907579, -122.53401215374411 37.81666158907579))', 'CONTAINMENT_OVERLAPPING_BBOX', 6) ---- -[] \ No newline at end of file +[862830807ffffff, 86283080fffffff, 86283081fffffff, 862830827ffffff, 86283082fffffff, 862830837ffffff, 862830847ffffff, 862830867ffffff, 86283086fffffff, 862830877ffffff, 86283090fffffff, 86283091fffffff, 862830947ffffff, 86283094fffffff, 862830957ffffff, 86283095fffffff, 86283096fffffff, 862830977ffffff] \ No newline at end of file