go.geo icon indicating copy to clipboard operation
go.geo copied to clipboard

normalize cartesian coordinate range

Open missinglink opened this issue 9 years ago • 2 comments
trafficstars

I have this javascript code which normalizes geographic coordinates to within the ranges of lat +-90 and lon +-180 (it unwinds multiple rotations around the globe).

This function is quite nice as it avoids floating point precision errors which can occur when using other methods.

Would you be interested in me porting the code to go.geo? If so what would you call the method? it's specific to geographic coordinates.

Maybe this could close https://github.com/paulmach/go.geo/pull/41 as it appears to be doing something similar?

Could be named something like point.NormalizeGeographicCoordinates()

missinglink avatar Aug 05 '16 09:08 missinglink

I'm fine with adding that, but I am curious about your usecase.

paulmach avatar Aug 07 '16 22:08 paulmach

The use case for us was that we have a geocoder based on elasticsearch.

When elasticsearch released 2.0.x they changed a bunch of behaviors and one of those was that elasticsearch used to handle this wrapping for us and now it just returns an error.

We provide one API called focus where you tell the geocoder to emphasize results around a point (center of map, geolocation, etc) and users send all kinds of weird co-ordinates like lat:-450.1, lon:199.

These errors are usually because of the tools they are using and it's not really their fault, for instance if you use a slippy web map and you zoom out, you can generally scroll all the way to the right and center the map past +180.

The function just allows developers to unwind the wrapping so they are consistent with systems which don't support ranges greater than -90/+90 -180/+180.

wrap

missinglink avatar Aug 08 '16 12:08 missinglink