Converting coordinates from EPSG 3857 to 4326(将坐标从EPSG 3857转换为4326)
本文介绍了将坐标从EPSG 3857转换为4326的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据库中有一个EPSG 3857格式的坐标列表。 我需要在EPSG 4326中转换它们 我正在尝试使用DotSpatial,但我的代码总是返回一个双精度无限数组。
public double[] ConvertCoodinates()
{
double[] xy = new double[2];
xy[0] = 5085240.8300000000;
xy[1] = 1530088.9600000000;
//An array for the z coordinate
double[] z = new double[1];
z[0] = 0;
ProjectionInfo pStart = KnownCoordinateSystems.Geographic.World.WGS1984;
pStart.AuthorityCode = 3857;
ProjectionInfo pEnd = KnownCoordinateSystems.Geographic.World.WGS1984;
pEnd.AuthorityCode = 4326;
Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1);
return xy;
}
xy数组总是无穷大;
有人能帮帮我吗?
推荐答案
最后我找到了一个数学公式来转换坐标。
我在存储过程中实现它,因为我有一个点列表,而此存储过程计算距离。
DECLARE @e FLOAT=2.7182818284
DECLARE @X DECIMAL(18,2) =20037508.34
SET @StartLat3857 =(SELECT TOP 1 Latitude FROM Coordinates WHERE IdCoord=@IdCoord ORDER By IdTDFPath ASC)
SET @StartLng3857=(SELECT TOP 1 Longitude FROM Coordinates WHERE IdCoord=@IdCoord ORDER By IdTDFPath ASC)
--converting the logitute from epsg 3857 to 4326
SET @StartLng=(@StartLng3857*180)/@X
--converting the latitude from epsg 3857 to 4326
SET @StartLat = @StartLat3857/(@X/180)
SET @StartLat = ((ATAN(POWER(@e,((PI()/180)*@StartLat))))/(PI()/360))-90
最后只是一个可以在每种语言中使用的数学公式。例如,如果是Javascript,它将是
const e = 2.7182818284
const X = 20037508.34
const lat3857 = 1743704.947843
const long3857 = 16978473.105100
//converting the logitute from epsg 3857 to 4326
const long4326 = (lat3857*180)/X
//converting the latitude from epsg 3857 to 4326 split in multiple lines for readability
let lat4326 = lat3857/(X / 180)
const exponent = (Math.PI / 180) * lat4326
lat4326 = Math.atan(e ** exponent)
lat4326 = lat4326 / (Math.PI / 360)
lat4326 = lat4326 - 90
这篇关于将坐标从EPSG 3857转换为4326的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:将坐标从EPSG 3857转换为4326


基础教程推荐
猜你喜欢
- 全局 ASAX - 获取服务器名称 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01