2013-04-03 86 views
0

我需要将经度和纬度更改为ISN93将纬/长坐标转换为ISN93

我在玩的是ISN93格式的GIS数据,所以我需要获取GPS格式相同的东西。

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

+0

您是否需要在.NET应用程序中转换这些数据,或者您是否需要转换一堆GPS数据?这很容易取决于你有什么工具。例如,如果您在PostGIS数据库中有GPS数据(假设为WGS84数据),则可以简单地运行一条语句,如“SELECT ST_Transform(geometry_column_name,4659)'。如果您有像ArcGIS这样的工具,那么您可以使用内置的重投影功能。 – sovemp 2013-04-08 16:46:12

回答

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

下面是一些JavaScript代码转换WGS84到ISN93:

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

确保您使用它之前做的测试,电池完全解决这个问题。我没有对此进行全面分析,以确保在所有情况下都完全正确。如果您发现任何问题,请告知我。