Catégories :

Fonctions géospatiales

ST_ASWKT , ST_ASTEXT

Si la valeur est de type GEOGRAPHY ou GEOMETRY, renvoie la représentation du texte (VARCHAR) de cette valeur au format WKT (texte bien connu).

Voir aussi :

ST_ASEWKT

Syntaxe

Utilisez l’une des méthodes suivantes :

ST_ASWKT( <geography_or_geometry_expression> ) ST_ASTEXT( <geography_or_geometry_expression> ) 
Copy

Arguments

geography_or_geometry_expression

L’argument doit être une expression de type GEOGRAPHY ou GEOMETRY.

Renvoie

Un VARCHAR.

Notes sur l’utilisation

  • ST_ASTEXT est un alias pour ST_ASWKT.

  • Pour renvoyer la sortie au format EWKT, utilisez plutôt ST_ASEWKT.

Exemples

Exemples GEOGRAPHY

L’exemple suivant illustre la fonction ST_ASWKT :

create table geospatial_table (id INTEGER, g GEOGRAPHY); insert into geospatial_table values (1, 'POINT(-122.35 37.55)'), (2, 'LINESTRING(-124.20 42.00, -120.01 41.99)'); 
Copy
select st_astext(g) from geospatial_table order by id; +-------------------------------------+ | ST_ASTEXT(G) | |-------------------------------------| | POINT(-122.35 37.55) | | LINESTRING(-124.2 42,-120.01 41.99) | +-------------------------------------+ 
Copy
select st_aswkt(g) from geospatial_table order by id; +-------------------------------------+ | ST_ASWKT(G) | |-------------------------------------| | POINT(-122.35 37.55) | | LINESTRING(-124.2 42,-120.01 41.99) | +-------------------------------------+ 
Copy

Exemples GEOMETRY

L’exemple ci-dessous montre comment utiliser la fonction ST_ASEWKT. L’exemple renvoie les représentations EWKT de deux géométries.

CREATE OR REPLACE TABLE geometry_table (g GEOMETRY); INSERT INTO geometry_table VALUES ('POINT(-122.35 37.55)'), ('LINESTRING(0.75 0.75, -10 20)'); ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='WKT'; SELECT ST_ASWKT(g) FROM geometry_table; 
Copy
+------------------------------+ | ST_ASWKT(G) | |------------------------------| | POINT(-122.35 37.55) | | LINESTRING(0.75 0.75,-10 20) | +------------------------------+ 
Copy