全部产品
云市场
云游戏

空间对象输出函数

更新时间:2019-12-30 16:03:19

ST_AsBinary

描述

返回给定几何对象或地理对象的WKB表示,其中不包含SRID元数据信息。

函数声明

  1. bytea ST_AsBinary(geometry g1);

使用示例

  1. SELECT ST_AsBinary(ST_GeomFromText('POLYGON((0 0,0 1,1 1,1 0,0 0))'));
  2. st_asbinary(st_geomfromtext('POLYGON((0 0,0 1,1 1,1 0,0 0))'))
  3. ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  4. \x01030000000100000005000000000000000000000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F000000000000F03F000000000000000000000000000000000000000000000000
  5. (1 row)

ST_AsGeoJSON

描述

返回给定几何对象或地理对象的GeoJSON表示。

函数声明

  1. text ST_AsGeoJSON(geometry geom);

使用示例

  1. SELECT ST_AsGeoJSON(ST_GeomFromText('POINT (111 22)'));
  2. st_asgeojson(st_geomfromtext('POINT (111 22)'))
  3. -------------------------------------------------
  4. {"type":"Point","coordinates":[111.0,22.0]}
  5. (1 row)

ST_AsText

描述

返回给定几何对象或地理对象的WKT表示,不包含SRID元数据。

函数声明

  1. text ST_AsText(geometry g1);

使用示例

  1. SELECT ST_AsText(st_geomfromwkb('\x01030000000100000005000000000000000000000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F000000000000F03F000000000000000000000000000000000000000000000000' :: binary));
  2. st_astext(st_geomfromwkb(CAST('\x01030000000100000005000000000000000000000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F000000000000F03F000000000000000000000000000000000000000000000000' AS binary)))
  3. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  4. POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))
  5. (1 row)

ST_GeoHash

描述

返回给定几何对象的GeoHash表示。

函数声明

  1. text ST_GeoHash(geometry geom);

使用示例

  1. SELECT ST_GeoHash(ST_MakePoint(-126,48));
  2. st_geohash(st_makepoint(- 126, 48))
  3. -------------------------------------
  4. c0w3hf1s70w3
  5. (1 row)