求助大佬们,坐标转换问题,急!
将百度经纬度bd09II转百度墨卡托bd09mc,我这里有JavaScript版本的,如何改写为Python的。JavaScript版本代码:
var LLBAND =
var LL2MC = [
[-0.0015702102444, 111320.7020616939, 1704480524535203, -10338987376042340, 26112667856603880, -35149669176653700, 26595700718403920, -10725012454188240, 1800819912950474, 82.5],
,
,
,
[-0.0003441963504368392, 111320.7020576856, 278.2353980772752, 2485758.690035394, 6070.750963243378, 54821.18345352118, 9540.606633304236, -2710.55326746645, 1405.483844121726, 22.5],
[-0.0003218135878613132, 111320.7020701615, 0.00369383431289, 823725.6402795718, 0.46104986909093, 2351.343141331292, 1.58060784298199, 8.77738589078284, 0.37238884252424, 7.45]
]
function getRange(cC, cB, T) {
if (cB != null) {
cC = Math.max(cC, cB);
}
if (T != null) {
cC = Math.min(cC, T);
}
return cC;
}
function getLoop(cC, cB, T) {
while (cC > T) {
cC -= T - cB;
}
while (cC < cB) {
cC += T - cB;
}
return cC;
}
function convertor(cC, cD) {
if (!cC || !cD) {
return null;
}
let T = cD + cD * Math.abs(cC.x);
const cB = Math.abs(cC.y) / cD;
let cE = cD + cD * cB + cD * cB * cB +
cD * cB * cB * cB + cD * cB * cB * cB * cB +
cD * cB * cB * cB * cB * cB +
cD * cB * cB * cB * cB * cB * cB;
T *= (cC.x < 0 ? -1 : 1);
cE *= (cC.y < 0 ? -1 : 1);
return ;
}
function convertLL2MC(T) {
let cD, cC, len;
T.x = getLoop(T.x, -180, 180);
T.y = getRange(T.y, -74, 74);
const cB = T;
for (cC = 0, len = LLBAND.length; cC < len; cC++) {
if (cB.y >= LLBAND) {
cD = LL2MC;
break;
}
}
if (!cD) {
for (cC = LLBAND.length - 1; cC >= 0; cC--) {
if (cB.y <= -LLBAND) {
cD = LL2MC;
break;
}
}
}
const cE = convertor(T, cD);
return cE;
你这是在找人打工啊{:10_277:} nahongyan1997 发表于 2021-8-4 16:09
你这是在找人打工啊
算是吧{:5_109:}
页:
[1]