TO_GEOMETRY (Lakehouse v1)
Analyse une entrée et renvoie une valeur de type GEOMETRY.
TRY_TO_GEOMETRY renvoie NULL si une erreur se produit pendant l’analyse.
Syntaxe SQL
Section intitulée « Syntaxe SQL »TO_GEOMETRY(<string>, [<srid>])TO_GEOMETRY(<binary>, [<srid>])TO_GEOMETRY(<variant>, [<srid>])TRY_TO_GEOMETRY(<string>, [<srid>])TRY_TO_GEOMETRY(<binary>, [<srid>])TRY_TO_GEOMETRY(<variant>, [<srid>])Arguments
Section intitulée « Arguments »| Arguments | Description |
|---|---|
<string> |
L’argument doit être une expression de chaîne en WKT, EWKT, WKB ou EWKB au format hexadécimal, ou au format GeoJSON. |
<binary> |
L’argument doit être une expression binaire au format WKB ou EWKB. |
<variant> |
L’argument doit être un OBJECT JSON au format GeoJSON. |
<srid> |
La valeur entière du SRID à utiliser. |
Type de retour
Section intitulée « Type de retour »Geometry.
Exemples SQL
Section intitulée « Exemples SQL »SELECT TO_GEOMETRY( 'POINT(1820.12 890.56)' ) AS pipeline_geometry;
┌───────────────────────┐│ pipeline_geometry │├───────────────────────┤│ POINT(1820.12 890.56) │└───────────────────────┘
SELECT TO_GEOMETRY( '0101000020797f000066666666a9cb17411f85ebc19e325641', 4326 ) AS pipeline_geometry;
┌───────────────────────────────────────┐│ pipeline_geometry │├───────────────────────────────────────┤│ SRID=4326;POINT(389866.35 5819003.03) │└───────────────────────────────────────┘
SELECT TO_GEOMETRY( FROM_HEX('0101000020797f000066666666a9cb17411f85ebc19e325641'), 4326 ) AS pipeline_geometry;
┌───────────────────────────────────────┐│ pipeline_geometry │├───────────────────────────────────────┤│ SRID=4326;POINT(389866.35 5819003.03) │└───────────────────────────────────────┘
SELECT TO_GEOMETRY( '{"coordinates":[[389866,5819003],[390000,5830000]],"type":"LineString"}' ) AS pipeline_geometry;
┌───────────────────────────────────────────┐│ pipeline_geometry │├───────────────────────────────────────────┤│ LINESTRING(389866 5819003,390000 5830000) │└───────────────────────────────────────────┘
SELECT TO_GEOMETRY( PARSE_JSON('{"coordinates":[[389866,5819003],[390000,5830000]],"type":"LineString"}') ) AS pipeline_geometry;
┌───────────────────────────────────────────┐│ pipeline_geometry │├───────────────────────────────────────────┤│ LINESTRING(389866 5819003,390000 5830000) │└───────────────────────────────────────────┘