在Albers投影图上将Lat / Longs转换为X / Y坐标

时间:2014-10-20 20:36:30

标签: javascript map latitude-longitude projection map-projections

我有一个map with Albers projection,我有Lat和Long的某个位置,我需要在此图像上画一个点。我知道这张地图是用Albers投影建造的,使用52和64以及WGS 84的标准平行线。 我尝试在Javascript中实现this formulas,但结果似乎错了。我不知道该怎么做。我发现了a few类似的问题,但他们没有给我回答我的问题。

// lat and long of left top corner
f0 = 66 * (Math.PI/180); 
a0 = 36 * (Math.PI/180);
// lat and long of my point
f = 55 * (Math.PI/180);
a = 37 * (Math.PI/180); 
// Standart parallers
f1 = 52 * (Math.PI/180);
f2 = 64 * (Math.PI/180);

n = 1/2 * (Math.sin(f1)+Math.sin(f2));
c = Math.pow(Math.cos(f1),2) + 2*n*Math.sin(f1);
t = n*(a*(180/Math.PI) - a0*(180/Math.PI))* (Math.PI/180);
p0 = 1/n * Math.sqrt(c-2*n*Math.sin(f0));
p=1/n*Math.sqrt(c-2*n*Math.sin(f));

x=p*Math.sin(t);
y=p0-p*Math.cos(t);

感谢。

1 个答案:

答案 0 :(得分:2)

问题已解决 好的,我还需要为我的地图计算Central Meridian。这段代码工作正常。

function albers(lat, lng) {

    var lat0 = 66 * (Math.PI/180),   // Latitude_Of_Origin
        lng0 = 105 * (Math.PI/180),  // Central_Meridian
        phi1 = 52 * (Math.PI/180),   // Standard_Parallel_1
        phi2 = 64 * (Math.PI/180),  // Standard_Parallel_2


        n = 0.5 * (Math.sin(phi1) + Math.sin(phi2)),
        c = Math.cos(phi1),
        C = c*c + 2*n*Math.sin(phi1),
        p0 = Math.sqrt(C - 2*n*Math.sin(lat0)) / n,
        theta = n * (lng * Math.PI/180 - lng0),
        p = Math.sqrt(C - 2*n*Math.sin(lat* Math.PI/180)) / n,

        x = p * Math.sin(theta),
        y = p0 - p * Math.cos(theta)

        return [x,y]
}

所有积分都转到https://gist.github.com/RandomEtc/476238

相关问题