[英]X Y Conversion to lat lng
我在数据库中按x,y和shape放置了位置。如何将该位置点转换为纬度和经度对? 有工具或公式吗?
例如x = 220162.636213404 y = 762057.91460931313应该类似于lat = 34.55667500000000000 lng = 31.68173300000000000
谢谢!
这取决于您选择使用的投影模型 。
假设x,y是像素测量的位置,则可以修改以下代码段:
> public Class MyMapView extends MapView {
.... /**
* x,y are screen coordinates. The location l is set to the
latitude and longitude that corresponds to this
* point on the screen.
*/
public void setLocation(double x, double y, Location l) {
double latSpan = (getLatitudeSpan() / 1.0E6);
double lngSpan = (getLongitudeSpan() / 1.0E6);
Point center = getMapCenter();
double xPcnt = x / ((double)getWidth());
double yPcnt = y / ((double)getHeight());
double lat0 = (center.getLatitudeE6()/1.0E6 + (latSpan/2.0));
double lng0 = (center.getLongitudeE6()/1.0E6 - (lngSpan/2.0));
double lat = lat0 - (yPcnt * latSpan);
double lng = lng0 + (xPcnt * lngSpan);
l.setLatitude(lat);
l.setLongitude(lng);
} ...
摘自: http : //groups.google.com/group/android-developers/msg/f40fa714555c9617
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.