適用於:
Databricks SQL
Databricks Runtime 11.3 LTS 及以上版本
傳回對應至指定解析度的六邊形或五邊形的 H3 單元格 ID(以 STRING 表示)的 ARRAY,這些單元格位於輸入的地理區域內。
語法
h3_polyfillash3string ( geographyExpr, resolutionExpr )
引數
-
geographyExpr:一個 BINARY 或 STRING 運算式,表示 WKB、WKT 或 GeoJSON 格式中的面積地理(多邊形或多多邊形)。 預期地理位置的經度和緯度座標應依據 WGS84 座標參考系統。 -
resolutionExpr:INT 運算式,其值預期介於0和15之間(包含0和15),指定 H3 單元格標識碼的解析度。
退回
對應於指定解析度之H3單元格標識碼的STRING值陣列,這些標識碼被包含在輸入的地理區域中。
如果任一輸入表達式為 NULL,此函式會傳回 NULL。 如果第一個輸入參數的類型為 BINARY,則預期輸入值是多邊形或多多邊形的 WKB 描述。 如果第一個輸入自變數的類型為 STRING,則輸入值預期要是多邊形或多重多邊形的 WKT 或 GeoJSON 描述。 輸入多邊形或多多邊形的維度可以是 2D、3DZ、3DM 或 4D。
錯誤條件
- 如果
geographyExpr類型為 BINARY,且值是無效的 WKB 或不代表多邊形或多多邊形,則函式會 傳回WKB_PARSE_ERROR。 - 如果
geographyExpr類型為 STRING,且值是無效的 WKT,或不代表多邊形或多多邊形,則函式會傳回WKT_PARSE_ERROR。 - 如果
geographyExpr類型為 STRING,且值是無效的 GeoJSON,或不代表多邊形或多多邊形,則函式會 傳回GEOJSON_PARSE_ERROR。 - 如果
resolutionExpr小於0或大於15,則函式會返回 H3_INVALID_RESOLUTION_VALUE。
範例
-- Simple example where the input is a triangle in WKT format.
> SELECT h3_polyfillash3string('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-122.4194 37.7749))', 2);
[82268ffffffffff,82269ffffffffff,822987fffffffff,8226e7fffffffff,822997fffffffff,8226f7fffffffff,822657fffffffff,8229affffffffff]
-- Simple example where the input is a triangle in hexadecimal WKB format.
> SELECT h3_polyfillash3string(unhex('0103000000010000000400000050fc1873d79a5ec0d0d556ec2fe342404182e2c7988f5dc0f46c567dae064140aaf1d24d628052c05e4bc8073d5b444050fc1873d79a5ec0d0d556ec2fe34240'), 2);
[82268ffffffffff,82269ffffffffff,822987fffffffff,8226e7fffffffff,822997fffffffff,8226f7fffffffff,822657fffffffff,8229affffffffff]
-- Feeding an empty linestring in GeoJSON format (as opposed to a polygon or multipolygon).
> SELECT h3_polyfillash3string('{"type":"LineString","coordinates":[]}', 2);
[GEOJSON_PARSE_ERROR] Error parsing GeoJSON: Invalid or unsupported type '"LineString"' at position 9
-- Feeding an invalid WKB (invalid endianness value)
> SELECT h3_polyfillash3string(unhex('020700000000'), 2);
[WKB_PARSE_ERROR] Error parsing WKB: Invalid byte order 2 at position 1
-- Feeding an invalid polygon in WKT (polygon is not closed)
> SELECT h3_polyfillash3string('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-74.0060 40.7128))', 2);
[WKT_PARSE_ERROR] Error parsing WKT: Found non-closed ring at position 80
-- Resolution is out of range.
> SELECT h3_polyfillash3string('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