[英]How to recreate coordinate transformation from vesselfinder (EPSG:4326 to EPSG:3857)?
I'm currently trying to figure out how vesselfinder.com calculates its Box Boundaries (bbox) which they use to query data from their backend.我目前正在尝试弄清楚vesselfinder.com 如何计算其用于从后端查询数据的框边界(bbox)。
Given an input like: lat, lon = 59.8230, 22.9586
给定如下输入: lat, lon = 59.8230, 22.9586
They fetch data by using this bbox: 13761899,35886447,13779795,35898097他们使用此 bbox 获取数据: 13761899,35886447,13779795,35898097
If I try to get a similar bbox by using bboxfinder.com , I get the following values, which aren't even close to what I was expecting: 2553560.4710,8358928.9331,2556565.4293,8360514.8411如果我尝试使用 bboxfinder.com 获得类似的bbox ,我会得到以下值,这些值甚至与我的预期不接近: 2553560.4710,8358928.9331,2556565.4293,8360514.8411
The website above is using EPSG:4326 (WGS 84) to EPSG:3857 (WHS 84 / Pseudo-Mercator) by default.上面的网站默认使用 EPSG:4326 (WGS 84) 到 EPSG:3857 (WHS 84 / Pseudo-Mercator)。 I tried to verify in the JS code of vesselfinder that they're using this conversion as well.我试图在vesselfinder 的JS 代码中验证他们也在使用这种转换。
var c = new s.geom.MultiLineString(t);
return c.transform('EPSG:4326', 'EPSG:3857'),
There are also the following ones mentioned, but I'm pretty sure, that it has to be the upper shown transformation.还提到了以下几个,但我很确定,它必须是上面显示的转换。
it = [
new $('EPSG:3857'),
new $('EPSG:102100'),
new $('EPSG:102113'),
new $('EPSG:900913'),
The questions now are: What am I doing wrong?现在的问题是:我做错了什么? / Where do I think wrong? /我认为哪里不对?
I also tried using Python for the conversion and even tried out the other mentioned EPSG:XXXXXX types, but haven't got the desired result.我还尝试使用 Python 进行转换,甚至尝试了其他提到的 EPSG:XXXXXX 类型,但没有得到想要的结果。 I also changed the order of both EPSG types when creating the Transformer, but again, not the desired results.在创建 Transformer 时,我还更改了两种 EPSG 类型的顺序,但同样不是预期的结果。
from pyproj import Transformer
TRAN_4326_TO_3857 = Transformer.from_crs("EPSG:4326", "EPSG:3857", always_xy=True)
lat = 59.823002
lon = 22.958583
expansion = 2000
res = TRAN_4326_TO_3857.transform(lng, lat)
bbox = (round(res[0]-expansion), round(res[1]-expansion), round(res[0]+expansion), round(res[1]+expansion))
print(bbox)
# (2455738, 8260436, 2655738, 8460436)
This one is close to the one I got from bboxfinder, but is again not even close to the bbox vesselfinder is using.这个与我从 bboxfinder 得到的很接近,但又与正在使用的 bbox 容器查找器不接近。
https://gis.stackexchange.com/a/370496 seems to have the math. https://gis.stackexchange.com/a/370496似乎有数学。
convertCoordinates(lon, lat) {
var x = (lon * 20037508.34) / 180;
var y = Math.log(Math.tan(((90 + lat) * Math.PI) / 360)) /
(Math.PI / 180);
y = (y * 20037508.34) / 180;
return [x, y];
}
Or, in C# ( https://gis.stackexchange.com/a/325551 )或者,在 C# ( https://gis.stackexchange.com/a/325551 )
public static double[] latLonToMeters(double lat, double lon)
{
//Debug.Log(Mathd.Tan((90d + lat) * Mathd.PI / 720));
//Debug.Log(Mathd.Tan((90d + lat) * Mathd.PI / 360d));
double[] meters = new double[2];
meters[0] = lat * originShift / 180d;
meters[1] = Mathd.Log(Mathd.Tan((90d+lon) * Mathd.PI / 360d)) /
(Mathd.PI / 180d);
//meters[1] = Mathd.Log(5) / (Mathd.PI / 180d);
meters[1] = meters[1] * originShift / 180d;
return meters;
}
In any case, note the website those came from;无论如何,请注意那些来自的网站; that may be a better place to get the algorithm.那可能是获得算法的更好地方。 (Then if you need help converting to your preferred language, come back here.) (然后,如果您在转换为首选语言时需要帮助,请返回此处。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.