在java中将纬度和经度转换为北向和东向? [英] convert latitude and longitude to northing and easting in java?

查看:393
本文介绍了在java中将纬度和经度转换为北向和东向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Java中将纬度和经度转换为北向和东向?

how to convert latitude and longitude to northing and easting in Java?

推荐答案

我假设你的意思是英国OSGB东向和北方。这个背后的三角函数很有趣,但你可以使用 JCoord 库来实现这一点,它很容易(如果相当的话) CPU密集型)。

I'm assuming you mean UK OSGB easting and northings. The trigonometry behind this one is hilarious, but you can use the JCoord library for this, it makes it easy (if quite CPU intensive).

为了跟进@ DD的评论,下面是JCoord的问题,因为你有从Easting / Northing转换为Lat / Long时确保使用正确的数据,反之亦然。

To follow up on @DD's comments below, there is a gotcha with JCoord, in that you have to make sure you're using the correct datum when converting from Easting/Northing to Lat/Long, and vice versa.

取@ DD的代码:

LatLng latLng = new OSRef(394251,806376).toLatLng();

这将返回使用OSGB36数据的Lat / Long,即使用的扁平地球近似值在英国地图上。这与大多数应用程序(包括Streetmap)中使用的WSG84数据大不相同,后者将世界模拟为球体(或多或少)。

This will return a Lat/Long which uses the OSGB36 datum, i.e. the "flat earth" approximation used on UK maps. This is substantially different to the WSG84 datum used in most applications (including Streetmap), which models the world as a sphere (more or less).

为了转换为一个WGS84纬度/经度,你需要明确:

In order to convert to a WGS84 lat/long, you need to make it explicit:

LatLng latLng = new OSRef(394251,806376).toLatLng();
latLng.toWGS84();

这会将lat-long调整为正确的数据。

This will adjust the lat-long to the correct datum.

请注意 javadoc OsRef.toLatLng()非常清楚:


使用OSGB36数据将此OSGB网格参考转换为纬度/经度对。请注意,LatLng对象可能需要根据应用程序转换为WGS84数据

Convert this OSGB grid reference to a latitude/longitude pair using the OSGB36 datum. Note that, the LatLng object may need to be converted to the WGS84 datum depending on the application

坐标数据之间的转换并不简单。如果它看起来很简单,你可能做错了。

Conversion between coordinate datum is not simple. If it looks simple, you're likely doing it wrong.

这篇关于在java中将纬度和经度转换为北向和东向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆