ST_AsText

Definición

ST_AsText toma una geometría y devuelve su representación de texto conocida.

Sintaxis

Oracle y PostgreSQL

sde.st_astext (geometry sde.st_geometry)

SQLite

st_astext (geometry geometryblob)

Tipo de devolución

Oracle

CLOB

PostgreSQL y SQLite

Texto

Ejemplo

La función ST_AsText convierte el punto de ubicación hazardous_sites en su descripción de texto.

Oracle

CREATE TABLE hazardous_sites (
 site_id integer not null,
 name varchar(40),
 loc sde.st_geometry);

INSERT INTO HAZARDOUS_SITES (site_id, name, loc) VALUES (
 102,
 'W. H. KleenareChemical Repository',
 sde.st_geometry ('point (1020.12 324.02)', 4326)
);

SELECT site_id, name, sde.st_astext (loc) Location
 FROM HAZARDOUS_SITES;

SITE_ID      NAME                             Location

   102    W. H. KleenareChemical Repository   POINT (1020.12000000 324.02000000)

PostgreSQL

CREATE TABLE hazardous_sites (
 site_id serial,
 name varchar(40),
 loc sde.st_geometry);

INSERT INTO hazardous_sites (name, loc) VALUES (
 'W. H. KleenareChemical Repository',
 sde.st_point ('point (1020.12 324.02)', 4326)
);

SELECT site_id, name, sde.st_astext (loc) 
 AS location
 FROM hazardous_sites;

site_id      name                             location

   102    W. H. KleenareChemical Repository   POINT (1020.12000001 324.01999999)

SQLite

CREATE TABLE hazardous_sites (
 site_id integer primary key autoincrement not null,
 name varchar(40)
);

SELECT AddGeometryColumn(
 NULL, 
 'hazardous_sites',
 'loc',
 4326,
 'point',
 'xy',
 'null'
);

INSERT INTO hazardous_sites (name, loc) VALUES (
 'W. H. KleenareChemical Repository',
 st_point ('point (1020.12 324.02)', 4326)
);

SELECT site_id, name, st_astext (loc) 
 FROM hazardous_sites;

   1    W. H. KleenareChemical Repository   POINT (1020.12000000 324.02000000)

Temas relacionados

5/10/2014