Categories:

Geospatial functions

H3_GRID_DISTANCE

Returns the distance between two H3 cells specified by their IDs.

语法

H3_GRID_DISTANCE( <cell_id_1> , <cell_id_2> )

实参

cell_id_1

An INTEGER that represents the H3 cell ID (index (https://h3geo.org/docs/core-library/h3Indexing)), or a VARCHAR that represents the cell ID in hexadecimal format.

cell_id_2

An INTEGER that represents the H3 cell ID (index (https://h3geo.org/docs/core-library/h3Indexing)), or a VARCHAR that represents the cell ID in hexadecimal format.

返回

返回表示两个 H3 单元格之间的网格单元格距离的 INTEGER 值。

使用说明

两个输入单元格 IDs 必须使用相同的分辨率。

示例

以下示例返回两个 H3 单元格之间的距离(以网格单元格数表示)。该示例将 H3 单元格 IDs 指定为 INTEGER 值。

SELECT H3_GRID_DISTANCE(617540519103561727, 617540519052967935);
+----------------------------------------------------------+
| H3_GRID_DISTANCE(617540519103561727, 617540519052967935) |
%----------------------------------------------------------%
|                                                        5 |
+----------------------------------------------------------+

以下示例将 H3 单元格 IDs 的十六进制值指定为 VARCHAR 值:

SELECT H3_GRID_DISTANCE('891f1d48b93ffff', '891f1d4888fffff');
+--------------------------------------------------------+
| H3_GRID_DISTANCE('891F1D48B93FFFF', '891F1D4888FFFFF') |
%--------------------------------------------------------%
|                                                      5 |
+--------------------------------------------------------+