ST_ASWKT , ST_ASTEXT
Ao receber um valor do tipo GEOGRAPHY ou GEOMETRY, retorna o texto (VARCHAR) que representa esse valor no formato WKT (texto bem conhecido).
- Consulte também:
ST_ASEWKT
Sintaxe
Use uma das seguintes opções:
ST_ASWKT( <geography_or_geometry_expression> )
ST_ASTEXT( <geography_or_geometry_expression> )
Argumentos
geography_or_geometry_expressionO argumento deve ser uma expressão do tipo GEOGRAPHY ou GEOMETRY.
Notas de uso
ST_ASTEXT é um alias para ST_ASWKT.
Para retornar a saída no formato EWKT, use ST_ASEWKT em seu lugar.
Exemplos
Exemplos GEOGRAPHY
O exemplo a seguir demonstra a função 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)');
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) |
+-------------------------------------+
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) |
+-------------------------------------+
Exemplos GEOMETRY
O exemplo abaixo demonstra como utilizar a função ST_ASEWKT. O exemplo retorna as representações EWKT de duas geometrias.
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;
+------------------------------+
| ST_ASWKT(G) |
|------------------------------|
| POINT(-122.35 37.55) |
| LINESTRING(0.75 0.75,-10 20) |
+------------------------------+