Поделиться через


Функция h3_try_coverash3string

Applies to:check marked yes Databricks SQL check marked yes Databricks Runtime 16.3 and above

This function behaves the same as h3_coverash3string, but returns NULL instead of an error if the first argument is invalid. It returns an ARRAY of BIGINT values representing H3 cell IDs. These values correspond to the minimal set of hexagons or pentagons at the specified resolution that fully covers the input linear or areal geography.

Синтаксис

h3_try_coverash3string ( geographyExpr, resolutionExpr )

Аргументы

  • geographyExpr: A BINARY or STRING expression representing a linear (linestring or multilinestring) or areal (polygon or multipolygon) geography in WKB, WKT, or GeoJSON. Ожидается, что география будет иметь координаты долготы и широты в градусах в системе координат WGS84.
  • resolutionExpr: An INT expression, with a value between 0 and 15 inclusive, specifying the resolution for the H3 cell IDs.

Возвраты

An ARRAY of BIGINT values corresponding to the minimal set of hexagons or pentagons at the specified resolution that fully covers the input linear or areal geography.

Функция возвращается NULL , если какой-либо из входных выражений имеет значение NULL. If the first input argument is of type BINARY, the input value must be the WKB description of a linestring, polygon, multilinestring, or multipolygon. If the first input argument is of type STRING, the input value must be either the WKT or the GeoJSON description of a linestring, polygon, multilinestring, or multipolygon. Измерение входной линейной строки, многоугольника, многолинейной строки или сложного многоугольника может быть 2D, 3DZ, 3DM или 4D. The function returns NULL if the first argument corresponds to an invalid WKB, WKT, or GeoJSON or does not represent a linestring, polygon, multilinestring, or multipolygon.

Условия ошибок

  • Если значение resolutionExpr меньше 0 или больше 15, функция возвращает H3_INVALID_RESOLUTION_VALUE.

Примеры

-- Simple example where the input is a triangle in WKT format.
> SELECT h3_coverash3string('POLYGON((-122.4194 37.7749,-118.2437 34.0522,-74.0060 40.7128,-122.4194 37.7749))', 0)
  [8027fffffffffff,8029fffffffffff,802bfffffffffff,8049fffffffffff]

-- Simple example where the input is a triangle in hexadecimal WKB format.
> SELECT h3_coverash3string(unhex('0103000000010000000400000050fc1873d79a5ec0d0d556ec2fe342404182e2c7988f5dc0f46c567dae064140aaf1d24d628052c05e4bc8073d5b444050fc1873d79a5ec0d0d556ec2fe34240'), 0)
  [8027fffffffffff,8029fffffffffff,802bfffffffffff,8049fffffffffff]

-- Simple example where the input is a linestring in GeoJSON format.
SELECT h3_coverash3string('{"type":"LineString","coordinates":[[-122.4194,37.7749],[-118.2437,34.0522],[-74.0060,40.7128]]}', 1)
  [8148fffffffffff, 8129bffffffffff, 812a3ffffffffff, 812abffffffffff, 81267ffffffffff, 8126fffffffffff, 81283ffffffffff]

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

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

-- Feeding an invalid polygon in WKT (polygon is not closed)
> SELECT h3_try_coverash3string('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_coverash3string('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