问题
I need to create a function that converts longitude and latitude to UTM X and UTM Y coordinates in SQL Server. When the user provides longitude and latitude, the function should convert that information to UTM X and UTM Y coordinates.
回答1:
I would recommend using CoordinateSharp which is available as a NuGet package:
https://github.com/Tronald/CoordinateSharp
It has support for UTM
回答2:
I have developed a library in .NET to be called from transact sql Converts WGS84/UTM coordinates to Latitude and Longitude
It does just the opposite, but as it uses CoordinateSharp you can download the code and change it easily to convert from lat/long to wgs84 instead.
You can download it from github:
https://github.com/j-v-garcia/UTM2LATITUDE
usage:
SELECT dbo.UTM2LATITUDE(723399.51,4373328.5,'S',30) AS Latitude, dbo.UTM2LONGITUDE(723399.51,4373328.5,'S',30) AS Longitude
result:
39,4805657453054 -0,402592727245112
<param name="XUTM">pos UTM X</param>
<param name="YUTM">pos UTM Y</param>
<param name="LatBand">Latitude band grid zone designation letter (see http://www.dmap.co.uk/utmworld.htm) </param>
<param name="LongBand">Longitude band grid zone designation number (see http://www.dmap.co.uk/utmworld.htm) </param>
来源:https://stackoverflow.com/questions/57211949/function-to-convert-from-latitude-and-longitude-to-utm-x-and-utm-y-coordinate-in