【发布时间】:2012-12-13 10:27:05
【问题描述】:
我的数据库中有许多北距/东距数据(例如:n 15217, e 88911),我需要使用 T-SQL 将其转换为 Lat/long。
我该怎么做?
【问题讨论】:
-
投票重新打开,因为除了标记的副本之外还包含有用的信息。
标签: sql sql-server sql-server-2008 tsql
我的数据库中有许多北距/东距数据(例如:n 15217, e 88911),我需要使用 T-SQL 将其转换为 Lat/long。
我该怎么做?
【问题讨论】:
标签: sql sql-server sql-server-2008 tsql
有一个开源 dll 库here (geocoordconversion) 可以将东/北转换为纬度/经度。因此,您可以敲出一些东西以将其用于原始转换。
另外,可能有用的是,我有一个 project on GitHub,它使用此 DLL 将完整的军械调查邮政编码数据集导入 SQL Server,将东/北转换为纬度/经度。这可作为命令行可执行文件使用。如果这与您想要的完全一致,那么您也许可以使用它。或者至少,有代码强调如何使用 DLL 来执行转换。
更新 在我的项目中,.NET sn-p 使用 dll 转换为纬度/经度:
/// <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);
}
【讨论】:
GridReference.ChangeToPolarGeo(new GridReference(1233, 123));?
如果您看到 this page 显示您可以应用更改此 UTM 格式的算法,请更改它们。您下载的页面上有一个示例电子表格,并查看计算结果。我怀疑应该很容易抓住查找表并使用它们加入您的数据。
【讨论】: