将Lat / Long坐标转换为ISN93

时间:2013-04-03 20:27:11

标签: c# .net windows-phone gis

我需要将纬度和经度更改为ISN93

我正在使用ISN93格式的GIS数据,所以我需要以相同的格式获取GPS内容。

有没有人有任何可以进行这些转换的代码?

2 个答案:

答案 0 :(得分:2)

几年前我制作了这个Java代码,将ISN93转换为GPS使用的系统:WGS84

https://github.com/Kjarni/StraetoRouteAPI/blob/master/java/ISN93_to_WGS84.java

package org.kjarni;

import android.graphics.PointF;

/*
 * Copyright (c) 2012, Gunnar Gu�var�arson, Gabr�el A. P�tursson
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the <organization> nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 * // example conversion:
 * PointF point = new PointF(359583, 406481);
 * ISN93_to_WGS84 converter = new ISN93_to_WGS84();
 * PointF result = converter.ISN93_WGS84(point);
 * label1.setText("x: " + result.x + " y: " + result.y);
 */

public class ISN93_to_WGS84
{
    private double a     = 6378137.0;
    private double f     = 1.0 / 298.257222101;
    private double lat1  = 64.25;
    private double lat2  = 65.75;
    private double latc  = 65.00;
    private double lonc  = 19.00;
    private double eps   = 0.00000000001;
    private double lat   = 0;
    private double delta = 1.0;

    private double rho, e, dum, sint, f2sin1, pol1, polc, peq;

    public ISN93_to_WGS84()
    {
        rho    = 45.0 / Math.atan2(1.0, 1.0);
        e      = Math.sqrt(f * (2 - f));
        dum    = f2(Math.sin(lat1 / rho)) - f2(Math.sin(lat2 / rho));
        sint   = 2 * (Math.log(fx(lat1)) - Math.log(fx(lat2))) / dum;
        f2sin1 = f2(Math.sin(lat1 / rho));
        pol1   = fx(lat1) / sint;
        polc   = f3(latc) + 500000.0;
        peq    = a * Math.cos(latc / rho) / (sint * Math.exp(sint * Math.log((45 - latc / 2) / rho)));
    }

    private double fx (double p)
    {
        return a * Math.cos(p / rho) / Math.sqrt(1 - Math.pow(e * Math.sin(p / rho), 2));
    }

    private double f1 (double p)
    {
        return Math.log((1 - p) / (1 + p));
    }

    private double f2 (double p)
    {
        return f1(p) - e * f1(e * p);
    }

    private double f3 (double p)
    {
        return pol1 * Math.exp((f2(Math.sin(p / rho)) - f2sin1) * sint / 2);
    }

    public PointF ISN93_WGS84(PointF input)
    {
        double pol  = Math.sqrt(Math.pow(input.x - 500000, 2) + Math.pow(polc - input.y, 2));
        double lon  = 90 - 2 * rho * Math.atan(Math.exp(Math.log(pol / peq) / sint));
        double fact = rho * Math.cos(lon / rho) / sint / pol;

        while (Math.abs(delta) > eps)
        {
            delta = (f3(lon) - pol) * fact;
            lon += delta;
        }

        lat = -(lonc + rho * Math.atan((500000 - input.x) / (polc - input.y)) / sint);
        return new PointF((float)lat, (float)lon);
    }
}

答案 1 :(得分:1)

以下是一些将WGS84转换为ISN93的JavaScript:

https://gist.github.com/kristjanmik/6925cbefaa311145c58a

function WGS84_To_ISN93(l,m){
    l = parseFloat(l);
    m = parseFloat(m);
    var k=l*0.0174532925199433;
    var p=0.0818191913305*Math.sin(k);

    var o=11616778.382033*Math.pow(Math.tan(
        0.785398163397448-(k/2))/Math.pow(
        (1-p)/(1+p),0.04090959566525),0.90633380084752);

    var q=(m+19)*0.0158185089469038;
    return {
        x:Math.round((500000+o*Math.sin(q))*1000)/1000,
        y:Math.round((3482044.27322585-o*Math.cos(q))*1000)/1000
    };
}

在使用之前,请务必对此进行一整套测试。我没有对此进行全面分析,以确保它在所有情况下都是完全正确的。如果您发现任何问题,请告诉我。

相关问题