使用proj4js转换坐标时的精度误差

发布于 2024-09-29 08:11:28 字数 1050 浏览 5 评论 0原文

我正在使用 Proj4js 库来转换坐标。我正在将坐标从 EPSG: 23029 转换为 EPSG: 4326。问题是,通过转换坐标,处理负载中使用的精度存在一些偏差。我通过将坐标系从原点转换为目的地(反之亦然)来注意到这一点。我用来进行变换的代码是:

<script type="text/javascript" src="/proj4js/lib/proj4js-compressed.js"> </ script>
<script type="text/javascript" src="/proj4js/lib/projCode/merc.js"> </ script>
<script type="text/javascript" src="/projCode/tmerc.js"> </ script>
<script type="text/javascript" src="/proj4js/defs/EPSG23029.js"> </ script>
<script type="text/javascript" src="/proj4js/defs/EPSG4326.js"> </ script>

source = new Proj4js.Proj ('EPSG: 23029');
dest = new Proj4js.Proj (map.projection.toString ());

x = feature_selected.geometry.x;
y = feature_selected.geometry.y;

p = new Proj4js.Point (x, y);

p = Proj4js.transform (source, dest, feature_selected.geometry);

当我在两个方向上进行变换时,原点不相同。

 x1= -6.34378379330039
 y1=  39.48007480688388

 x2= -6.343783791584894
 y2= 39.4800748068322604

有人知道如何解决这个问题吗?

谢谢。

I am using the library Proj4js to transform coordinates. I'm transforming coordinates from EPSG: 23029 to EPSG: 4326. The problem is that by transforming the coordinates there is some deviation from the precision used in the processing load. I noticed this by transforming a coordinate system from origin to destination and vice versa. The code I use to make the transformation is:

<script type="text/javascript" src="/proj4js/lib/proj4js-compressed.js"> </ script>
<script type="text/javascript" src="/proj4js/lib/projCode/merc.js"> </ script>
<script type="text/javascript" src="/projCode/tmerc.js"> </ script>
<script type="text/javascript" src="/proj4js/defs/EPSG23029.js"> </ script>
<script type="text/javascript" src="/proj4js/defs/EPSG4326.js"> </ script>

source = new Proj4js.Proj ('EPSG: 23029');
dest = new Proj4js.Proj (map.projection.toString ());

x = feature_selected.geometry.x;
y = feature_selected.geometry.y;

p = new Proj4js.Point (x, y);

p = Proj4js.transform (source, dest, feature_selected.geometry);

when I do the transformation in both directions, the point of origin is not the same.

 x1= -6.34378379330039
 y1=  39.48007480688388

 x2= -6.343783791584894
 y2= 39.4800748068322604

Anyone know how to solve this problem?

thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雪落纷纷 2024-10-06 08:11:28

在投影系统之间转换时总是会损失一些精度。错误来源有很多,包括 JavaScript 引擎中浮点运算的限制以及投影之间转换的可逆性。

另一方面,您的源数据来自哪里?考虑到您仅损失小数点后第九位左右的精度,很可能您的源数据一开始实际上并不那么准确(当然不是您常用的 GPS,甚至是差分校正的),因此没有太多意义担心重投影算法中引入的错误。

编辑:所以,经过一些计算 - 两次重新投影后的误差约为 1/10 毫米。我非常怀疑是否值得尝试针对任何现实世界的应用程序进行改进。

You will always lose some precision when converting between projection systems. There are a number of sources of error, including limitations on floating point arithmetic in the JavaScript engine and around the reversibility of a transformation between projections.

On the other hand, where is your source data coming from? Considering that you're only losing precision at about the ninth decimal place, it is likely that your source data isn't actually that accurate to begin with (certainly not your usual GPS, or even differentially corrected), so there is not much point worrying about errors introduced in the re-projection algorithm.

EDIT: So, after some calculations - your error after two re-projections is about 1/10th of a millimetre. I highly doubt it is worth trying to improve on that for any real world application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文