Returns a LocationGlobal object containing the latitude/longitude `dNorth` and `dEast` metres from the specified `original_location`. The returned Location has the same `alt` value as `original_location`. The function is useful when you want to move the vehicle around specify
(original_location, dNorth, dEast)
| 38 | |
| 39 | |
| 40 | def get_location_metres(original_location, dNorth, dEast): |
| 41 | """ |
| 42 | Returns a LocationGlobal object containing the latitude/longitude `dNorth` and `dEast` metres from the |
| 43 | specified `original_location`. The returned Location has the same `alt` value |
| 44 | as `original_location`. |
| 45 | |
| 46 | The function is useful when you want to move the vehicle around specifying locations relative to |
| 47 | the current vehicle position. |
| 48 | The algorithm is relatively accurate over small distances (10m within 1km) except close to the poles. |
| 49 | For more information see: |
| 50 | http://gis.stackexchange.com/questions/2951/algorithm-for-offsetting-a-latitude-longitude-by-some-amount-of-meters |
| 51 | """ |
| 52 | earth_radius=6378137.0 #Radius of "spherical" earth |
| 53 | #Coordinate offsets in radians |
| 54 | dLat = dNorth/earth_radius |
| 55 | dLon = dEast/(earth_radius*math.cos(math.pi*original_location.lat/180)) |
| 56 | |
| 57 | #New position in decimal degrees |
| 58 | newlat = original_location.lat + (dLat * 180/math.pi) |
| 59 | newlon = original_location.lon + (dLon * 180/math.pi) |
| 60 | return LocationGlobal(newlat, newlon,original_location.alt) |
| 61 | |
| 62 | |
| 63 | def get_distance_metres(aLocation1, aLocation2): |
no test coverage detected