我需要编写一个函数,可以将latitude / longitue定义的某个位置投影到地图上的x,y坐标(图像)。
地图本身似乎使用“belgian Lambert”作为投影类型。
我找到了有关此投影及其配置的一些官方信息:http://ign.be/FR/FR2-1-4.shtm和http://ign.be/Common/Lambert2008/Transformation_Geographic_Lambert_FR.pdf(法语版,如果需要,我会翻译)。
基本上,我得出结论,使用某些库会更容易(尽管这不是必需的)。经过一番研究,似乎OpenMap应该能够完成这项工作。
所以,这是我到目前为止所得到的:
private Point mapCoordinatesToPoint(LatLonPoint latLonPoint) {
LatLonPoint centerLatLonPoint = new LatLonPoint(50.797815, 4.3592158333333333333333333333333);
Proj proj = new LambertConformal(centerLatLonPoint, 1, 1000, 1000, 4.3592158333333333333333333333333, 49.833333333333333333333333333333, 51.166666666666666666666666666667, 50.797815, 649328.0, 665262.0, Ellipsoid.GRS_1980);
return proj.forward(latLonPoint);
}
(知道我的gif是1000x1000)
LamberConformal构造函数的JavaDoc:http://openmap.bbn.com/doc/api/com/bbn/openmap/proj/LambertConformal.html#LambertConformal%28com.bbn.openmap.LatLonPoint,%20float,%20int,%20int,%20double,%20double,%20double,%20double,%20double,%20double,%20com.bbn.openmap.proj.Ellipsoid%29
我想我没有正确配置:应该在地图上的一些点,xxx,给出了这个结果:
x=-1766051.0; y=-1.6355546E7;
将“中心点”(?)作为参数给出
x=500.0; y=500.0;
(地图中间,看起来不错)
有谁熟悉这个,或者能够从链接中找出配置?
编辑:
尝试用以下方法替换方法中的最后一行:
return proj.forward(latLonPoint.getLatitude(), latLonPoint.getLongitude(), new Point(), false);
但不是更好。
答案 0 :(得分:0)
对于那些感兴趣的人,我就是这样做的。
这是针对比利时的地图(似乎使用Lambert 72或2008)。
Proj proj = new LambertConformal(centerLatLonPoint, scale, 1776, 1468,
4.3592158333333333333333333333333, //centralMeridian
49.833333333333333333333333333333, //lambert_sp_one
51.166666666666666666666666666667, //lambert_sp_two
50.797815, //referenceLatitude
649328.0, //falseEasting
665262.0, //falseNorthing
Ellipsoid.GRS_1980);
比例可以这样计算:
LatLonPoint dePanneLatLonPoint = new LatLonPoint(51.0975f, 2.5855f);
Point dePannePoint = new Point(27, 313);
LatLonPoint mussonLatLonPoint = new LatLonPoint(49.5567f, 5.7106f);
Point mussonPoint = new Point(1464, 1426);
float scale = proj.getScale(dePanneLatLonPoint, mussonLatLonPoint, dePannePoint, mussonPoint);
这两个点是任意点(尽可能为nw和se),你知道它们的地理坐标以及在地图上投影的位置。
我还必须找到地图中心的地理坐标。
然后可以通过以下方式找到地图上某个点的位置:
Point point = proj.forward(latitude, longitude, new Point(), false);