共用方式為


h3_try_coverash3 函數

適用於:已勾選是 Databricks SQL 已勾選是 Databricks Runtime 16.3 和更高版本

此函式的行為與 h3_coverash3 相同,但若第一個參數無效,則會回傳 NULL 而非錯誤。 它回傳ARRAY 的一組代表 H3 cell ID 的BIGINT 值。 這些值對應於指定解析度下的最小六邊形或五邊形集合,可完全覆蓋輸入的線性或面積地理。

語法

h3_try_coverash3 ( geographyExpr, resolutionExpr )

論點

  • geographyExpr:一種 BINARYSTRING 表達式,代表在 WKBWKTGeoJSON 中的線性(線串或多線串)或面積(多邊形或多邊形組)地理。 地理必須具有經度和緯度座標,以度數為單位,並參考 WGS84 座標參考系統。
  • resolutionExpr:一個INT表達式,其值在015之間(含邊界值),指定 H3 單元格標識碼的解析度。

退貨

ARRAY BIGINT 一組值,對應於在指定解析度下,能夠完全覆蓋輸入的線性或區域地理的最小六邊形或五邊形集合。

如果任一輸入表示式為 NULL,則函式會傳NULL回 。 若第一個輸入參數的類型為 BINARY,則輸入值必須是多邊形或複合多邊形的 WKB 描述。 如果第一個輸入參數的類型為STRING,則輸入值必須是WKTGeoJSON描述的LINESTRING、POLYGON、MULTILINESTRING或MULTIPOLYGON。 輸入線字串、多邊形、多行字串或多多邊形的維度可以是 2D、3DZ、3DM 或 4D。 如果第一個自變數對應至無效NULLWKTGeoJSON,或不代表行字串、多邊形、多行字串或多行形,則函式會傳回

錯誤條件

範例

-- Simple example where the input is a triangle in WKT format.
> SELECT h3_try_coverash3('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-122.4194 37.7749))', 0);
  [577164439745200127, 577199624117288959, 577234808489377791, 577762574070710271]

-- Simple example where the input is a triangle in hexadecimal WKB format.
> SELECT h3_try_coverash3(unhex('0103000000010000000400000050fc1873d79a5ec0d0d556ec2fe342404182e2c7988f5dc0f46c567dae064140aaf1d24d628052c05e4bc8073d5b444050fc1873d79a5ec0d0d556ec2fe34240'), 0);
  [577164439745200127, 577199624117288959, 577234808489377791, 577762574070710271]

-- Simple example where the input is a linestring in GeoJSON format.
SELECT h3_try_coverash3('{"type":"LineString","coordinates":[[-122.4194,37.7749],[-118.2437,34.0522],[-74.0060,40.7128]]}', 1);
  [582248581512036351, 581698825698148351, 581707621791170559, 581716417884192767, 581641651093503999, 581650447186526207, 581672437419081727]

-- Feeding an empty multipoint in GeoJSON format (as opposed to a linestring, polygon, multilinestring, or multipolygon).
> SELECT h3_try_coverash3('{"type":"MultiPoint","coordinates":[]}', 2);
  null

-- Feeding an invalid WKB (invalid endianness value)
> SELECT h3_try_coverash3(unhex('020700000000'), 2);
  null

-- Feeding an invalid polygon in WKT (polygon is not closed)
> SELECT h3_try_coverash3('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-74.0060 40.7128))', 2);
  null

-- Resolution is out of range.
> SELECT h3_try_coverash3('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-122.4194 37.7749))', 16);
  [H3_INVALID_RESOLUTION_VALUE] H3 resolution 16 must be between 0 and 15, inclusive