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.
precisionThe precision based on which you want to construct the Box2D object. If you do not specify this parameter, this function constructs the Box2D object by using the Geohash string in the full precision.

Examples

Full precision — use the entire Geohash string:

SELECT ST_Box2dFromGeoHash('wx47x9u8gumnhzp791zb');

Output:

       st_box2dfromgeohash
----------------------------------
 BOX(116 39.9999999999999,116 40)
(1 row)

Custom precision — truncate to the first 5 characters:

SELECT ST_Box2dFromGeoHash('wx47x9u8gumnhzp791zb', 5);

Output:

                   st_box2dfromgeohash
-----------------------------------------------------------
 BOX(115.9716796875 39.990234375,116.015625 40.0341796875)
(1 row)