scottschluer/geolocation

Remove default rounding behavior in GetDistance

Opened this issue · 0 comments

First, thanks for creating this great library!

Today, GetDistance accepts a decimalPlaces parameter which defaults to 1. I find this unintuitive from an API perspective; if I want to do rounding on the value I can easily do it myself after calling GetDistance, I would not expect that method to do it for me. I definitely would not expect it to round to 1 decimal place; that feels arbitrary to me especially when we support different distance units and so 1 decimal place implies many different levels of precision.

Another oddity with this is that the library uses .NET's default "banker's rounding" under the hood (MidpointRoundingMode.ToEven), which doesn't feel like an appropriate choice for coordinate math (I would use AwayFromZero).

My suggestion would be to take a breaking change and simply remove the rounding behavior from GetDistance. Consumers can easily call Math.Round themselves on the result if they so desire.