Calculation of width/height in kilometers
johngouf opened this issue · 2 comments
Its more of a question, rather than an issue.
It is mentioned in the documentation that you can get the width/height from degrees to kilometers using Position.getDistanceToKm function. I checked the source code and I failed to understand how to use it in order to convert degrees to kms.
Hi, sorry I had notifications turned off so I missed your issue.
Use GeoHash.heightDegrees(hashLength) and GeoHash.widthDegrees(hashLength) to get the height and width in degrees of the hash you are interested in. The conversion of degrees to kilometres depends where you are on the earth. If you want to know width in degrees to kilometres at (lat,lon) then it will be
double distancePerDegreeWidth =
new Position(lat,lon).getDistanceToKm(new Position(lat, lon+1));
likewise for latitude.
I've updated the README with the example, thanks for you input.