Converting coordinates from EPSG 3857 to 4326 DotSpatial

末鹿安然 提交于 2019-12-10 10:05:08

问题


I have in my DB a list of coordinates in EPSG 3857 format. I need to convert them in EPSG 4326 I'm trying to use DotSpatial but my code always retun a double array of Infinity.

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;
    }

The xy array always cointain infinity; Can someone help me?


回答1:


In the end I find a math formula to convert the coordinates.

I implemented it in a stored procedure because I have a list of point and this stored procedure calculates the distance.

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


来源:https://stackoverflow.com/questions/37523872/converting-coordinates-from-epsg-3857-to-4326-dotspatial

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