返回一個與給定的GeoHash字符串相對應的Geometry對象。

語法

geometry  ST_GeomFromGeoHash(text  geohash , integer  precision);

參數

參數名稱 描述
geohash GeoHash字符串。
precision 精度。如果未指定精度,則ST_GeomFromGeoHash根據輸入的GeoHash字符串的全精度返回Polygon。

示例

  • 全精度返回:
    SELECT ST_AsText(ST_GeomFromGeoHash('wx47x9u8gumnhzp791zb'));
                               st_astext
    ---------------------------------------------------------------
     POLYGON((116 39.9999999999999,116 40,116 40,116 39.9999999999.
    .999,116 39.9999999999999))
    (1 row)
    
  • 指定精度返回:
    SELECT ST_AsText(ST_GeomFromGeoHash('wx47x9u8gumnhzp791zb',2));
                               st_astext
    ---------------------------------------------------------------
     POLYGON((112.5 39.375,112.5 45,123.75 45,123.75 39.375,112.5 .
    .39.375))
    (1 row)