geotools icon indicating copy to clipboard operation
geotools copied to clipboard

Geohash Integer methods

Open mablae opened this issue 10 years ago • 9 comments

It would be quite nice to allow encoding into geohash integers.

For example https://github.com/sunng87/node-geohash offers the encode_int = function (latitude, longitude, bitDepth) function.

Since the current Geohash implemenation manages state inside the class and is not like a static converter class, the way to go would be a new GehashInteger class, right?

Or does it make sense to refactor the the current Geohash class to support additional converting methods for geohash integers?

EDIT: Better description

cheers mablae

mablae avatar Apr 18 '15 23:04 mablae

@toin0u Any opinion on this?

mablae avatar Apr 26 '15 20:04 mablae

Hi @mablae! Sorry to reply so late. I think I'll go to refactor the current Geohash class :) Are you willing to help with this?

toin0u avatar Apr 28 '15 07:04 toin0u

Sure, I am. I already looked at the current implementation and noticed that Geohash maintains its state internally as geohash string. How would you refactor the class in a sane way?

EDIT: Another thing is the internal handling of long integer values in PHP when printing them out. When not formatted with number_format or sprintf they get print out as 2.4681012141618E+35 format.

When putting geohashes into Redis, I had to work around this issue by using number format. Should it be handled by the GeoInteger methods, meaning it would return an string?

Or is returning real integer better and let the users decide, depending their usecase?

http://stackoverflow.com/questions/9630793/how-to-display-long-integers-on-browser-in-php

mablae avatar Apr 28 '15 16:04 mablae

For a personal project I converted the algorithm used by https://github.com/sunng87/node-geohash to PHP.

Since there is also #3 (Geohash36) maybe it would be the better way to have a GeoHashInterface and then multiple self containing implementations on that?

This would be easier to extend and no BC breaks at all.. Let's not couple all different implementations into the GeoHash class.

Converting between different geohashes would also be easily possible then...

What do you think?

mablae avatar Apr 28 '15 17:04 mablae

@mablae I agree with you :) The interface is a good idea. I'm :+1: for that.

Thanks for pointing out the issue with the long integer.. I think you're right to return the string make sense in this case.

Thank you very much for commenting and come with inputs, I appreciate it :)

toin0u avatar Apr 29 '15 18:04 toin0u

Okay, fine. :+1:

I will prepare a PR on the weekend to be discussed further then.

mablae avatar Apr 29 '15 19:04 mablae

That's sound nice! I'm looking forward to it :)

toin0u avatar Apr 29 '15 19:04 toin0u

@mablae any news about this? :)

toin0u avatar Oct 10 '15 17:10 toin0u

Any news about integer version of Geohash?

TeaDove avatar Mar 19 '22 22:03 TeaDove