node-geohash icon indicating copy to clipboard operation
node-geohash copied to clipboard

Convert to string notation required for auto precision

Open ppKrauss opened this issue 7 years ago • 2 comments

It is possible to change

    if (typeof(latitude) === 'number' || typeof(longitude) === 'number') {
      throw new Error('string notation required for auto precision.');
    }

To something like

    if (typeof(latitude) === 'number') {
      latitude = parseFloat(latitude).toString();
    }
    if (typeof(longitude) === 'number') {
      longitude = parseFloat(longitude).toString();
    }

or direct enforce input.toString(), without checks or parseFloats.

ppKrauss avatar Nov 28 '18 09:11 ppKrauss

I'm not sure if parseFloat returns correct precision as user want. Explicitly disable this indecisive behavior is preferred.

sunng87 avatar Nov 28 '18 13:11 sunng87

can you show an example? I not see the problem...

ppKrauss avatar Nov 28 '18 14:11 ppKrauss