T-SQL //如何将Northing/Easting坐标转换为lat/long?

Art*_*tem 4 sql t-sql sql-server sql-server-2008

可能重复:
东经北纬经度

我在数据库中有很多Northing/Easting数据(例如:) n 15217, e 88911,我需要将它转换为Lat/longT-SQL.

我怎么能这样做?

Ada*_*Dev 7

这里有一个开源dll库( geocoordconversion ),可以将eastings/northings转换为lat/lon.因此,您可以将某些内容用于原始转换.

或者,可能有用的是,我在GitHub上有一个项目,它使用这个DLL将完整的Ordnance Survey邮政编码数据集导入SQL Server,将eastings/northings转换为lat/lon.这可用作命令行可执行文件.如果这与您想要的一致,那么您可以使用它.或者至少,有代码突出显示如何使用DLL执行转换.

更新 从我的项目,使用DLL转换为lat/lon的.NET代码段:

/// <summary>
/// Converts northing and easting coordinates into Longitude/Latitude coordinates in the WGS84 coordinate system.
/// </summary>
/// <param name="northing">northing coordinate</param>
/// <param name="easting">easting coordinate</param>
/// <returns>converted coordinates</returns>
protected PolarGeoCoordinate ConvertToLonLat(double northing, double easting)
{
    // Use GeoCoordConversion DLL to convert the Eastings & Northings to Lon/Lat
    // coordinates in the WGS84 system. The DLL was pulled from: http://code.google.com/p/geocoordconversion/
    // and is available under the GNU General Public License v3: http://www.gnu.org/licenses/gpl.html
    GridReference gridRef = new GridReference((long)easting, (long)northing);
    PolarGeoCoordinate polarCoord = GridReference.ChangeToPolarGeo(gridRef);
    return PolarGeoCoordinate.ChangeCoordinateSystem(polarCoord, CoordinateSystems.WGS84);
}
Run Code Online (Sandbox Code Playgroud)