Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

当地图放大到大的级别时,绘制的线或者面,位置不准确 #721

Closed
deyihu opened this issue Jul 17, 2018 · 4 comments
Closed
Labels

Comments

@deyihu
Copy link
Collaborator

deyihu commented Jul 17, 2018

maptalks's version and what browser you use?

Issue description

当地图放大到大的级别时,绘制的线或者面,位置不准确

http://jsfiddle.net/fjqwuaop/20/ (左右移动地图或者旋转地图试试)

当pitch 调整的越大,误差越大
绘制的线,和面出现偏移,这里的数据我是采取的几个道路经纬度,
按正常的绘制结果,应该和底图的道路重合。

然后我把pitch调整为0 ,在尝试移动地图,旋转地图,这时绘制的结果是正确的;

当zoom小的时候,是不存在该问题的

Please provide a reproduction URL (on any jsfiddle like site)

@deyihu
Copy link
Collaborator Author

deyihu commented Jul 17, 2018

然后我基于 examples 里的 helloLayer ,做了一个示例
http://jsfiddle.net/Lrh3x5qu/20/
问题是一样的, 排除了VectorLayer绘制问题,说明问题出在
map.coordinateToContainerPoint 方法上

@fuzhenn fuzhenn added the bug label Jul 17, 2018
@fuzhenn
Copy link
Member

fuzhenn commented Jul 17, 2018

感谢报告。

这是个重要的bug,我会尽快对应

@fuzhenn
Copy link
Member

fuzhenn commented Jul 17, 2018

初步判定是点在相机(近剪裁面)之后,且点的投影点高度大于相机高度,投影矩阵计算不正确导致的(所以只在高级别出现)

貌似是个比较纯粹的数学问题 (hmm...)

@fuzhenn
Copy link
Member

fuzhenn commented Jul 19, 2018

下午研究了一下这个问题,主要原因如下:

  • 点在相机背后时,需要把点投影到相机视平面上(_projIfBehindCamera)
  • 投影并不是100%精确的,点距离相机越远时,误差会越大
  • 三维点在相机背后时,目前还没有精确的屏幕投影算法

解决办法如下:

  1. 绘制前需要先做clip,把线或面用map的extent做剪切后只绘制被剪切的部分,这样就能保证准确绘制
  2. 优先选用webgl绘制, webgl因为是逐像素绘制,不会出现这个问题

我修改了一下程序,目前VectorLayer中的绘制开启了clip后绘制就正常了,但在下面两种情况仍会出现问题:

  • 贝塞尔 Curve 曲线的绘制(默认关闭了clip)
  • 手动将enableClip设为false的geometry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants