Condividi tramite


Funzione to_geometry

Si applica a:check contrassegnato come sì controllo SQL di Databricks contrassegnato come sì Databricks Runtime 17.1 e versioni successive

Important

Questa funzionalità è in Anteprima Pubblica.

Annotazioni

Questa funzionalità non è disponibile in Databricks SQL Classic Warehouses. Per altre informazioni sui databricks SQL Warehouse, vedere Tipi di SQL Warehouse.

Analizza la descrizione di input di una geometria e restituisce il valore corrispondente GEOMETRY . Il valore SRID del valore restituito GEOMETRY dipende dal formato di input.

Syntax

to_geometry ( geoRepExpr )

Arguments

  • geoRepExpr BINARY: espressione o STRING che rappresenta una geometria in WKB, WKT, GeoJSON o WKB esteso (EWKB).

Returns

Valore di tipo GEOMETRY(ANY), corrispondente alla descrizione geografica di input.

La funzione restituisce NULL se l'input è NULL.

Condizioni di errore

  • Se geoRepExpr è di tipo BINARY e il valore è un EWKB non valido, la funzione restituisce EWKB_PARSE_ERROR.
  • Se geoRepExpr è di tipo BINARY e il valore è un WKB non valido, la funzione restituisce WKB_PARSE_ERROR.
  • Se geoRepExpr è di tipo STRING e il valore è un WKT non valido, la funzione restituisce WKT_PARSE_ERROR.
  • Se geoRepExpr è di tipo STRING e il valore è un GeoJSON non valido, la funzione restituisce GEOJSON_PARSE_ERROR.

Examples

-- Input geometry is in WKT format.
> SELECT st_asgeojson(to_geometry('POINT Z (3 4 5)'));
  {"type":"Point","coordinates":[3,4,5]}

-- Input geometry is in GeoJSON format.
> SELECT st_astext(to_geometry('{"type":"Point","coordinates":[3,4,5]}'));
  POINT Z (3 4 5)

-- Input geometry is in WKB format.
> SELECT st_astext(to_geometry(X'0101000060110f0000000000000000084000000000000010400000000000001440'));
  POINT M (3 4 5)

-- Input geometry is in EWKB format.
> SELECT st_asewkt(to_geometry(X'01010000E0110F0000000000000000084000000000000010400000000000001440000000000000F0BF'));
  SRID=3857;POINT ZM (3 4 5 -1)