开发者

X Y Conversion to lat lng

i have places location in the database by x ,y and shape How can I convert this location points to latitude and longitude pairs? Is there a tool or a formula?

for example x =220162.636213404 y = 762057.914609313 it should be something like lat = 34.55667开发者_如何学Go500000000000 lng = 31.68173300000000000

Thanks!


There are a lot of different geographic coordinate systems. The most commonly used is WGS84 (EPSG:4326). Google Maps uses it's own spherical mercator projection which is commonly known as Google Mercator, but its latlong values are WGS84 coordinates.

In order to transform your coordinates you have to know the source and destination coordinate system. Once you have figured this out you can use a library like Proj4js to calculate the transformation.

Proj4js also provides an online coordinate calculator, which might help you to figure out which coordinates system the coordinates in your database are using.

If you are looking for a C# framework: SharpMap is great for handling all aspects of geospatial applications.


That depends on the projection model you choose to use.


Asumming x, y are pixel-measured positions, you could adapt this snippet:

> 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);
} ...

Taken from: http://groups.google.com/group/android-developers/msg/f40fa714555c9617

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜