tridge/MAVProxy — pull request #4 by pchickey (2012-06-11 06:12:46+00:00)
Title: modules mp_util: Fix to longitude output range in gps_newpos

I noticed a strange bug in the new 'map' module where SlipObjects would not render when in locations near Portland, OR, but would render if placed in the vicinity of Canberra.

I discovered that SlipObjects would have a (lat, lon) of (45.0, -112.0) while the MPSlipMap had a (lat, lon) of (45.0, 248.0). These two coordinates do represent the same point on the earth, but the mp_util.bounds_overlap used from MPSlipMapPanel.draw_objects() assumes a euclidean geometry, and does not find the SlipObjects to be in focus.

The fix may be to correct the implementation of bounds_overlap, but I discovered this bug would only occur in my corner of the world because of the initial shift of the MPSlipMap lat lon from (-35, 149), the initial SlipMap location, to (45, -112), my location. In the first call to MPSlipMapPanel.re_center(), gps_newpos would result in 248 degrees longitude rather than -112.

I wrote a quick fix to treat the longitude output of mp_util.gps_newpos.

However, I suspect this class of bug may come up again. A more general solution might find a way to treat writes to a (latitude, longitude) pair as a point on a sphere, but that is beyond my python foo.

Signed-off-by: Pat Hickey