请问高德经纬度怎么转换成平面坐标
我用的Unity进行的AR开发,staticdoubleRc=6378137;//赤道半径staticdoubleRj=6356725;//极半径doublem_LoDe...
我用的Unity进行的AR开发,
static double Rc = 6378137; // 赤道半径
static double Rj = 6356725; // 极半径
double m_LoDeg, m_LoMin, m_LoSec; // longtitude 经度
double m_LaDeg, m_LaMin, m_LaSec;
double m_Longitude, m_Latitude;
double m_RadLo, m_RadLa;
double Ec;
double Ed;
public JWD(double longitude, double latitude)
{
m_LoDeg = (int)longitude;
m_LoMin = (int)((longitude - m_LoDeg)*60);
m_LoSec = (longitude - m_LoDeg - m_LoMin/60.)*3600;
m_LaDeg = (int)latitude;
m_LaMin = (int)((latitude - m_LaDeg)*60);
m_LaSec = (latitude - m_LaDeg - m_LaMin/60.)*3600;
m_Longitude = longitude;
m_Latitude = latitude;
m_RadLo = longitude * Math.PI/180.;
m_RadLa = latitude * Math.PI/180.;
Ec = Rj + (Rc - Rj) * (90.-m_Latitude) / 90.;
Ed = Ec * Math.cos(m_RadLa);
}
上面是计算距离的
下面是计算在我的方向的
/! 计算点A 和 点B的经纬度,求他们的距离和点B相对于点A的方位
/*!
* \param A A点经纬度
* \param B B点经纬度
* \param angle B相对于A的方位, 不需要返回该值,则将其设为空
* \return A点B点的角度
*/
public static double angle(JWD A, JWD B)
{
double dx = (B.m_RadLo - A.m_RadLo) * A.Ed;
double dy = (B.m_RadLa - A.m_RadLa) * A.Ec;
// double out = Math.sqrt(dx * dx + dy * dy);
double angle = 0.0;
angle = Math.atan(Math.abs(dx/dy))*180./Math.PI;
// 判断象限
double dLo = B.m_Longitude - A.m_Longitude;
double dLa = B.m_Latitude - A.m_Latitude;
if(dLo > 0 && dLa <= 0) { angle = (90. - angle) + 90.; }
else if(dLo <= 0 && dLa < 0) {
angle = angle + 180.;
}
else if(dLo < 0 && dLa >= 0) {
angle = (90. - angle) + 270;
} return angle; }
现在的问题是通过高德地图查找到周围商店没大问题,但是导航时生成的路径会有偏差 展开
static double Rc = 6378137; // 赤道半径
static double Rj = 6356725; // 极半径
double m_LoDeg, m_LoMin, m_LoSec; // longtitude 经度
double m_LaDeg, m_LaMin, m_LaSec;
double m_Longitude, m_Latitude;
double m_RadLo, m_RadLa;
double Ec;
double Ed;
public JWD(double longitude, double latitude)
{
m_LoDeg = (int)longitude;
m_LoMin = (int)((longitude - m_LoDeg)*60);
m_LoSec = (longitude - m_LoDeg - m_LoMin/60.)*3600;
m_LaDeg = (int)latitude;
m_LaMin = (int)((latitude - m_LaDeg)*60);
m_LaSec = (latitude - m_LaDeg - m_LaMin/60.)*3600;
m_Longitude = longitude;
m_Latitude = latitude;
m_RadLo = longitude * Math.PI/180.;
m_RadLa = latitude * Math.PI/180.;
Ec = Rj + (Rc - Rj) * (90.-m_Latitude) / 90.;
Ed = Ec * Math.cos(m_RadLa);
}
上面是计算距离的
下面是计算在我的方向的
/! 计算点A 和 点B的经纬度,求他们的距离和点B相对于点A的方位
/*!
* \param A A点经纬度
* \param B B点经纬度
* \param angle B相对于A的方位, 不需要返回该值,则将其设为空
* \return A点B点的角度
*/
public static double angle(JWD A, JWD B)
{
double dx = (B.m_RadLo - A.m_RadLo) * A.Ed;
double dy = (B.m_RadLa - A.m_RadLa) * A.Ec;
// double out = Math.sqrt(dx * dx + dy * dy);
double angle = 0.0;
angle = Math.atan(Math.abs(dx/dy))*180./Math.PI;
// 判断象限
double dLo = B.m_Longitude - A.m_Longitude;
double dLa = B.m_Latitude - A.m_Latitude;
if(dLo > 0 && dLa <= 0) { angle = (90. - angle) + 90.; }
else if(dLo <= 0 && dLa < 0) {
angle = angle + 180.;
}
else if(dLo < 0 && dLa >= 0) {
angle = (90. - angle) + 270;
} return angle; }
现在的问题是通过高德地图查找到周围商店没大问题,但是导航时生成的路径会有偏差 展开
1个回答
展开全部
见范例代码:<pre t="code" l="java">mBaiduMap.setOnMapClickListener(new OnMapClickListener(){
@Override
public void onMapClick(LatLng point) {
// TODO Auto-generated method stub
//这里的point就是点击屏幕所获得的经纬度
//下面两个函数可以将经纬度转换为屏幕的点坐标,
//另一个是将屏幕点转换为经纬度
//mBaiduMap.getProjection()
// .fromScreenLocation(point);
//mBaiduMap.getProjection()
// .toScreenLocation(latlng);
}
@Override
public boolean onMapPoiClick(MapPoi arg0) {
// TODO Auto-generated method stub
return false;
}
});
@Override
public void onMapClick(LatLng point) {
// TODO Auto-generated method stub
//这里的point就是点击屏幕所获得的经纬度
//下面两个函数可以将经纬度转换为屏幕的点坐标,
//另一个是将屏幕点转换为经纬度
//mBaiduMap.getProjection()
// .fromScreenLocation(point);
//mBaiduMap.getProjection()
// .toScreenLocation(latlng);
}
@Override
public boolean onMapPoiClick(MapPoi arg0) {
// TODO Auto-generated method stub
return false;
}
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询