// gets offset in meters static double getOffset(const GeoCoordinate& point, double offsetInMeters) { double lat = deg2Rad(point.latitude); // Radius of Earth at given latitude double radius = wgs84EarthRadius(lat); double dWidth = offsetInMeters / (2 * radius); return rad2Deg(dWidth); }
/// Gets distance in meters for given coordinate static double distance(const GeoCoordinate &p1, const GeoCoordinate &p2) { double dLat = deg2Rad(p1.latitude - p2.latitude); double dLon = deg2Rad(p1.longitude - p2.longitude); double lat1 = deg2Rad(p1.latitude); double lat2 = deg2Rad(p2.latitude); double a = std::sin(dLat/2)*std::sin(dLat/2) + std::sin(dLon/2)*std::sin(dLon/2)*std::cos(lat1)*std::cos(lat2); double c = 2*std::atan2(std::sqrt(a), std::sqrt(1 - a)); double radius = wgs84EarthRadius(dLat); return radius*c; }