Categories:

Geospatial functions

H3_TRY_POLYGON_TO_CELLS

A special version of H3_POLYGON_TO_CELLS that returns NULL if an error occurs when it attempts to return an array of INTEGER values of the IDs of H3 cells that have centroids contained by a Polygon (specified by a GEOGRAPHY object).

语法

H3_TRY_POLYGON_TO_CELLS( <geography_polygon> , <target_resolution> )

实参

geography_polygon

表示多边形的 GEOGRAPHY 对象。

target_resolution

An INTEGER between 0 and 15 (inclusive) that specifies the H3 resolution (https://h3geo.org/docs/core-library/restable) that you want to use for the returned H3 cells.

指定其他任何 INTEGER 值都会导致错误。

返回

返回 INTEGER 值或 NULL 的数组。

  • If the function can perform a successful calculation, returns an array of INTEGER values for the IDs of the H3 cells that have centroids contained in the specified input Polygon.
  • 如果函数无法执行成功的计算,则返回 NULL 而不报告错误。

使用说明

See H3_POLYGON_TO_CELLS for the usage notes.

示例

The following example attempts to return an array of INTEGER values of the IDs of H3 cells that have centroids contained by a Polygon (specified by a GEOGRAPHY object). Because the array with the cells that cover the given hexagon at the given resolution exceeds the allowed size limit, the function returns NULL.

SELECT H3_TRY_POLYGON_TO_CELLS(
  TO_GEOGRAPHY('POLYGON((-108.959 40.948,
                         -109.015 37.077,
                         -102.117 36.956,
                         -102.134 40.953,
                         -108.959 40.948))'
              ), 15) AS h3_cells_in_polygon;
+---------------------+
| H3_CELLS_IN_POLYGON |
%---------------------%
| NULL                |
+---------------------+

For examples that successfully return an array of IDs, see H3_POLYGON_TO_CELLS.