Hi!
I have bumped into something I find counter intuitive with
St_GeoHash() - boundary checking for non-point objects seems stricter
than for points in case precision is not set:
select st_geohash(ST_MakeLine(st_point(0, 0), st_point(0.00002, 0.00002)));
-- returns "" <- this is unexpected, I expected "s00000000"
This breaks my assumption that st_geoshash(st_geomfromgeohash(hash))
will return the original geohash:
select st_geohash(st_geomfromgeohash('s0'));
-- returns "" <- I expected "s0"
I bumped to this in Postgis 3.2.1 and it is still reproducible in 3.6.1
Meanwhile if precision is set OR the geometry is a point OR it doesn't
touch geohash boundaries then I get what I expect:
select st_geohash(st_point(0, 0), 8));
-- returns "s0000000"
select st_geohash(st_point(0, 0));
--- returns "s0000000000000000000"
select st_geohash(ST_MakeLine(st_point(0, 0), st_point(0.00002, 0.00002)), 8);
-- returns "s0000000"
select st_geohash(ST_MakeLine(st_point(0.00001, 0.00001),
st_point(0.00002, 0.00002)), 8);
-- returns "s0000000"
select st_geohash(ST_MakeLine(st_point(0.00001, 0.00001),
st_point(0.00002, 0.00002)));
-- returns "s00000000"
I plan to create a bug report about this, but wanted to check first on
the mailing list if this is something intended.
These edge cases are interesting to me because I am trying to create
an implementation of st_geohash()/st_geomfromgeohash() for two Apache
projects (Hive, Impala), and cross- checked my tests with the results
in postgis.
regards,
Csaba