如标题所述,我需要帮助将经纬度转换为米勒圆柱投影中的x/y坐标。我正在编写一个应用程序(使用Java),它将城市列表作为输入,并从Yahoo Placefinder获取每个城市的经纬度。我在代码中使用了这些公式。这是一个示例。 (图像仅供参考,不是我使用的那个)。正如您所看到的,X位置只偏移了几个像素(2-3),这可能是由于我在此地图中的本初子午线偏移(CENTRAL_MERIDIAN_OFFSET)计算错误引起的问题。但主要问题是Y坐标不正确。
这是我的代码(已更新-34px补偿赤道偏移):
很明显,Y轴计算出现了问题。我不确定5.6是否真的是正确的值,但在我阅读的参考文献中,Millers投影的垂直范围被说成是-2.3..+2.3,所以我使用了这个值。
这是我的代码(已更新-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是否真的是正确的值,但在我阅读的参考文献中,Millers投影的垂直范围被说成是-2.3..+2.3,所以我使用了这个值。