Converting coordinates to WGS84

允我心安 提交于 2020-01-03 02:48:11

问题


I have the following function which plots a Circle given the centroid, but I want the coordinates to be In WGS84.

var coords = new List<Tuple<double, double>>();
const double EARTH_RADIUS_NM = 3437.670013352;
var lat = (latIn * Math.PI) / 180;
var lon = (lonIn * Math.PI) / 180;
double d = radiusIn / EARTH_RADIUS_NM;
for (int x = 0; x <= 360; x++)
{
    double brng = (x * Math.PI) / 180; 
    var latRadians = Math.Asin(Math.Sin(lat) * Math.Cos(d) + Math.Cos(lat) * Math.Sin(d) * Math.Cos(brng));
    var lngRadians = lon + Math.Atan2(Math.Sin(brng) * Math.Sin(d) * Math.Cos(lat), Math.Cos(d) - Math.Sin(lat) * Math.Sin(latRadians));

    coords.Add(new Tuple<double, double>(latRadians, lngRadians));
}

回答1:


You say convert to WGS84 but from what?

Look at something like http://www.gdal.org/ or http://dotspatial.codeplex.com/ (or spatial support in your DB if you're using one).

This answer over on GIS will help explain WGS84 / EPSG:4326

https://gis.stackexchange.com/questions/23690/is-wgs84-itself-a-coordinate-reference-system

and this will help when your circle turns into a ellipse :)

SQL Server Circle




回答2:


EDIT**: sorry i misunderstood the problem at the start. I don't quite understand your naming convention so I will not write the code initially. Also I am a differential geometry enthusiast so the jokes are on me...

To begin first we look at the distances on the surfaces of any sphere: as a reminder for the coordinates we have: r ≥ 0, 0 ≤ θ ≤ π and 0 ≤ φ < 2π. (θ == latitude, φ == longitude) now since our displacement ds, is confined to the surface, we have dr == 0. Also we can consider a disc of distance ds away from the point a = [r, 0, 0]

These points must then satisfy ds == r dθ, which gives b = [r, ds/r, 0]. this is easy because it doesn't matter what φ actually is, it can go from 0 to 2π and this distance will remain the same, so any point b = [r, ds/r, φ] is sitting on the disc of coordinates that we are looking for.

So what if we start with a = [r, θ, φ] you may ask, to which i say, then why not convert back to a = [r, 0, 0] by adding transformation vector t = [0, -θ, -φ] calculate the coordinates for the disc, then do subtract the same transformation vector on each point (b) that you find. may the force be with you



来源:https://stackoverflow.com/questions/35389834/converting-coordinates-to-wgs84

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!