本文介绍了我怎样才能改变纬度和经度的x,y在Java中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作Java中的地理项目。

I am working on a geographic project in Java.

输入的坐标:24.4444ñ等输出:一个PLAIN地图(不圆)表示的坐标的点

The input are coordinates : 24.4444 N etcOutput: a PLAIN map (not round) showing the point of the coordinates.

我不知道该算法的坐标变换的x,y的一个JComponent,有人可以帮我吗?

I don't know the algorithm to transform from coordinates to x,y on a JComponent, can somebody help me?

在地图上看起来是这样的: http://upload.wikimedia.org/wikipedia/commons/7 /74/Mercator-projection.jpg

The map looks like this:http://upload.wikimedia.org/wikipedia/commons/7/74/Mercator-projection.jpg

感谢您

推荐答案

鉴于你的疏例如,您输入的范围将是(90.0N - 90.0S)和(180W - 180E)。这是最简单的 - 标准 - 如果转换的南部和西部,以底片给你的(90.0 ..- 90.0),纬度和(180.0 ..- 180.0)经度

Given your sparse example, the range of your inputs will be (90.0N - 90.0S) and (180W - 180E). It is easiest - and standard - if you convert South and West to negatives giving you latitudes of (90.0..-90.0) and longitudes of (180.0..-180.0).

由于画布的大小 - 让我们说这是140x120像素 - 你:

Given the size of your canvas - let's say it is 140x120 pixels - you get:

x = (latitude * canvas_height / 180.0) + (canvas_height / 2)
y = (longitude * canvas_width / 360.0) + (canvas_width / 2)

x = (longitude * 120.0 / 180.0) + (120/2)
y = (latitude  * 140.0 / 360.0) + (140/2)

在哪里我已命令操作,以尽量减少舍入误差。这假定画布具有点(0,0)在左上角,或者,如果没有,你是澳大利亚

where I have ordered the operations to minimize rounding error. This assumes the canvas has point (0,0) in the upper-left or, if not, that you are Australian.

添加:您刚才在有关墨卡托投影位扔让我简单的回答不正确(但可能仍然可以使用由你,如果你不真正关心的投影)

Added: you just threw in the bit about Mercator projections making my simple answer incorrect (but possibly still usable by you if you don't actually care about projection)

这篇关于我怎样才能改变纬度和经度的x,y在Java中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 18:56
查看更多