【发布时间】:2012-02-16 20:17:11
【问题描述】:
正如标题中所说,我需要一些帮助来将米勒圆柱投影中的纬度/经度转换为 x/y 坐标。我目前正在编写一个应用程序(在 Java 中),它获取城市列表作为输入,然后从 Yahoo Placefinder 获取每个城市的纬度/经度。我在代码中使用了these 公式。 Here is an example 我得到的。 (图片仅供参考,不是我用的那个)。如您所见,X 位置仅相差几个像素 (2-3),这可能是我在此地图中计算本初子午线偏移 (CENTRAL_MERIDIAN_OFFSET) 的问题。但主要问题是 Y 坐标不正确。
这是我的代码(更新 - 赤道偏移补偿 34px):
public final double W = 6343;
public final double H = 4767 - 34;
protected Point toMillerXY(double lon, double lat)
{
double x, y;
lon = Utils.degToRad(lon);
lat = Utils.degToRad(lat);
x = lon - CENTRAL_MERIDIAN_OFFSET;
y = 1.25 * Math.log( Math.tan( 0.25 * Math.PI + 0.4 * lat ) );
x = ( W / 2 ) + ( W / (2 * Math.PI) ) * x;
y = ( H / 2 ) - ( H / ( 2 * 2.303412543 ) ) * y;
y += 34;
return new Point(x, y);
}
Output:
Fetching data with: http://where.yahooapis.com/geocode?location=Buenos+Aires,Argentina
Latitude: -34.608521, longitude: -58.373539
---
Fetching data with: http://where.yahooapis.com/geocode?location=Tokyo,Japan
Latitude: 35.670479, longitude: 139.740921
---
Fetching data with: http://where.yahooapis.com/geocode?location=Cape+Town,CAR
Latitude: -33.919060, longitude: 18.421961
---
Fetching data with: http://where.yahooapis.com/geocode?location=Rome,Italy
Latitude: 41.903110, longitude: 12.495760
---
Total cities: 4
Result for Buenos Aires: 1964.598428, 3046.740995
Result for Tokyo: 5455.265150, 1732.669551
Result for Cape Town: 3317.692474, 3032.814395
Result for Rome: 3213.276105, 1602.176163
显然,Y 坐标计算有问题。我不确定 5.6 是否真的应该是正确的值,但在我阅读的一篇参考文献中,米勒投影的垂直范围据说是 -2.3..+2.3,所以我使用了它。
【问题讨论】:
-
Here is an example of what I get它在哪里? -
忘记添加图片,已修复。
-
gis.stackexchange.com 可能是这个问题的一个更好的地方 - 它的观众更关注这类问题
-
感谢您的信息,我不妨把这个贴在那里。
-
@Varnius 你有你使用的确切图像吗?你提供的那个是不正确的,因为赤道没有穿过它的中心。
标签: latitude-longitude map-projections