将纬度/长坐标转换为ISN93
本文关键字:转换 ISN93 坐标 纬度 | 更新日期: 2023-09-27 18:07:21
我需要改变纬度和经度为ISN93
。
我正在玩ISN93格式的GIS数据,所以我需要以相同的格式获得GPS的东西。
谁有任何代码可以做这些转换?
我几年前编写了这个Java代码,它将ISN93
转换为GPS使用的系统:WGS84
。
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);
}
}
下面是一些将WGS84转换为ISN93的javascript代码:
https://gist.github.com/kristjanmik/6925cbefaa311145c58afunction 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
};
}
请确保在使用它之前对其进行全面的测试。我没有做一个完整的分析,以确保它在所有情况下都是正确的。