mhergon/RealmGeoQueries

Unnormalized longitude fails to compare

Closed this issue · 1 comments

DJBen commented

It's more than an inconvenience than a bug. For longitude ranges from [0, 360) that some data sources use, it fails to determine proximity.

Maybe something like this before comparison?

public func wrapLongitude(_ longitude: Double) -> Double {
    let wrapped = fmod(longitude, 360)
    return wrapped < 180 ? wrapped : wrapped - 360
}

Hi @DJBen

Can you create a pull request with suggested changes?

Thanks!