ST_Box2dFromGeoHash

更新时间:
复制 MD 格式

Constructs a Box2D bounding box from a Geohash string.

Syntax

box2d ST_Box2dFromGeoHash(text geohash, integer precision)

Parameters

ParameterDescription
geohashThe Geohash string to decode.
precisionThe precision based on which to construct the Box2D object. If omitted, the full precision of the Geohash string is used.

Examples

Full precision — uses all characters of the Geohash string:

SELECT ST_Box2dFromGeoHash('wx47x9u8gumnhzp791zb');
       st_box2dfromgeohash
----------------------------------
 BOX(116 39.9999999999999,116 40)
(1 row)

Custom precision — uses the first 5 characters, producing a larger box:

SELECT ST_Box2dFromGeoHash('wx47x9u8gumnhzp791zb', 5);
                   st_box2dfromgeohash
-----------------------------------------------------------
 BOX(115.9716796875 39.990234375,116.015625 40.0341796875)
(1 row)