项目上第三方提供的3Dtiles地图文件的经纬度可能设置不准确,需要手动调整,以下的调整的办法:
1.打开文件夹中的tileset.json文件
2.找到"transform"参数
"transform":[-0.895779807996946,-0.444498071519951,0.0,0.0,0.285164247917456,-0.574680502827843,0.767087785966645,0.0,-0.340969041548682,0.687141749630003,0.64154214874846,0.0,-2177749.44940341,4388734.4144855,4070062.24292389,1.0]
3.我们需要修改以上-2426377.1198234824,4676669.941649223,3582677.5713166697这三个数值即XYZ
4.计算XYZ数值的方法(Python)
import math
def geodetic_to_ecef(lat, lon, h):
# WGS84椭球体参数
a = 6378137.0 # 长半轴
f = 1/298.257223563 # 扁率
b = a * (1 - f) # 短半轴
e = math.sqrt(1 - (b*b)/(a*a)) # 第一偏心率
# 将度转换为弧度
lat = math.radians(lat)
lon = math.radians(lon)
# 计算卯酉圈曲率半径
N = a / math.sqrt(1 - e*e * math.sin(lat)*math.sin(lat))
# 计算ECEF坐标
x = (N + h) * math.cos(lat) * math.cos(lon)
y = (N + h) * math.cos(lat) * math.sin(lon)
z = (N * (1 - e*e) + h) * math.sin(lat)
return x, y, z
# 输入经纬度和高度
latitude = 34.3949
longitude = 117.4214500
height = 0 # 高度(米)
# 计算ECEF坐标
x, y, z = geodetic_to_ecef(latitude, longitude, height)
print(f"ECEF坐标: X={x}, Y={y}, Z={z}")
# 输出示例
ECEF坐标: X=-2426377.1198234824, Y=4676669.941649223, Z=3582677.5713166697
5.根据上一步的输出结果修改参数
"transform":[-0.895779807996946,-0.444498071519951,0.0,0.0,0.285164247917456,-0.574680502827843,0.767087785966645,0.0,-0.340969041548682,0.687141749630003,0.64154214874846,0.0,-2426377.1198234824,4676669.941649223,3582677.5713166697,1.0]
6.如有些许偏移,再调整第四步中的经纬度参数再重新计算即可
7.此外,也可以使用CesiumLab的三维可视工具来进行初步的坐标矫正
高德坐标拾取在线 https://lbs.amap.com/tools/picker