Kategorien:

Geodatenfunktionen

ST_ASEWKT

Given a value of type GEOGRAPHY or GEOMETRY, return the text (VARCHAR) representation of that value in EWKT (extended well-known text) format.

Siehe auch:

ST_ASWKT

Syntax

ST_ASEWKT( <geography_or_geometry_expression> )

Argumente

geography_or_geometry_expression

The argument must be an expression of type GEOGRAPHY or GEOMETRY.

Rückgabewerte

Ein VARCHAR-Wert.

Nutzungshinweise

  • For GEOGRAPHY objects, the SRID in the return value is always 4326. See the note on EWKT handling.

  • Verwenden Sie stattdessen ST_ASWKT, um die Ausgabe im WKT-Format zurückzugeben.

Beispiele

GEOGRAPHY Examples

Das folgende Beispiel veranschaulicht die Funktion ST_ASEWKT:

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_asewkt(g)
    from geospatial_table
    order by id;
+-----------------------------------------------+
| ST_ASEWKT(G)                                  |
|-----------------------------------------------|
| SRID=4326;POINT(-122.35 37.55)                |
| SRID=4326;LINESTRING(-124.2 42,-120.01 41.99) |
+-----------------------------------------------+

GEOMETRY Examples

The example below demonstrates how to use the ST_ASEWKT function. The example returns the EWKT representations of two geometries that have different SRIDs.

CREATE OR REPLACE TABLE geometry_table (g GEOMETRY);
INSERT INTO geometry_table VALUES
  ('SRID=4326;POINT(-122.35 37.55)'),
  ('SRID=0;LINESTRING(0.75 0.75, -10 20)');

ALTER SESSION SET GEOMETRY_OUTPUT_FORMAT='EWKT';
SELECT ST_ASEWKT(g) FROM geometry_table;
+-------------------------------------+
| ST_ASEWKT(G)                        |
|-------------------------------------|
| SRID=4326;POINT(-122.35 37.55)      |
| SRID=0;LINESTRING(0.75 0.75,-10 20) |
+-------------------------------------+
Zurück zum Anfang