private static void FromOSGB70(double lat, double lon, double h,
out double x, out double y, out double z) {
// WGS coordinates in radians
double phi = lat * Math.PI / 180;
double lambda = lon * Math.PI / 180;
// Airy 1830 ellipsoid parameters
// http://www.eye4software.com/products/coordinatecalculator/datum/175/
// Semi-major axis
double a = 6377563.396;
// Flattening
double f = 1 / 299.3249646;
// Eccentricity squared
double e2 = (2 * f) - (f * f);
double nu = a / Math.Sqrt(1 - e2 * Math.Pow(Math.Sin(phi), 2));
x = (nu + h) * Math.Cos(phi) * Math.Cos(lambda);
y = (nu + h) * Math.Cos(phi) * Math.Sin(lambda);
z = ((nu * (1 - e2)) + h) * Math.Sin(phi);
}
private static void ToWGS84(double x, double y, double z,
out double lat, out double lon, out double h) {
// WGS84 ellipsoid parameters
// http://www.eye4software.com/products/coordinatecalculator/datum/7/
// Semi-major axis
double a = 6378137;
// Flattening
double f = 1 / 298.257223563;
// Eccentricity squared
double e2 = (2 * f) - (f * f);
double p = Math.Sqrt((x * x) + (y * y));
double r = Math.Sqrt((p * p) + (z * z));
double mu = Math.Atan2(
z * ((1 - f) + (e2 * a / r)),
p
);
double lambda= Math.Atan2(y, x);
double phi = Math.Atan2(
(z * (1 - f)) + (e2 * a * Math.Pow(Math.Sin(mu), 3)),
(1 - f) * (p - (e2 * a * Math.Pow(Math.Cos(mu), 3)))
);
h = (p * Math.Cos(phi)) + (z * Math.Sin(phi)) -
(a * Math.Sqrt(1 - (e2 * Math.Pow(Math.Sin(phi), 2))));
lat = phi * 180 / Math.PI;
lon = lambda * 180 / Math.PI;
}
Title | # Comments | Views | Activity |
---|---|---|---|
shortest distance between a Line (p1(lat,long), p2(lat,long)) and a point p3(lat,long) | 10 | 148 | |
Google Store Locator Script With Marker and Circle | 4 | 1,465 | |
Graphic Information System (GIS) software compatible with Access | 6 | 308 | |
Android App to Selectively Hide or Disable GPS? | 4 | 289 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
14 Experts available now in Live!