OSMDroid PathOverlay绘图在高缩放级别损坏 [英] OSMDroid PathOverlay drawing is corrupted at high zoom levels

查看:477
本文介绍了OSMDroid PathOverlay绘图在高缩放级别损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用OSMdroid来实现一个地图应用程序。



我实现了一个自定义的MapTileProvider,使用一个允许缩放级别高达22的图块来源。 p>

默认的MAPNIK提供程序只允许缩放级别为18.



问题是任何PathOverlay实例完全绘制直到缩放级别19,但然后
在缩放级别20-22绘制不正确。它看起来像有人用路径长度的90%的橡皮擦擦掉路径(见下面的屏幕截图)。



我已经走过draw()方法路径叠加和外观似乎正确计算(中间点对于ZoomLevel 22显示正确,然后XY投影除以22-ZoomLevel以获得当前屏幕坐标)。



任何人都可以提供一些有关问题是什么以及如何解决问题的洞察?



事情发生,如果我调用MapView使用Cloudmade小瓷砖,允许放大到20级,是一个'内置'osmDroid瓦片提供程序类。

  // mMapTileProvider = new HighResMapTileProvider(this); 
mMapTileProvider = new MapTileProviderBasic(this,TileSourceFactory.CLOUDMADESMALLTILES);
mMapView = new MapView(this,256,mResourceProxy,mMapTileProvider);

因此,问题不是与tile源或提供程序,而是与canvas画布方法。关于如何解决这个问题的任何想法?



在zoomLevel 19我可以很好地看到我的路径:



但是下面的缩放级别是相同的路径:

解决方案

更新:已在osmdroid 3.0.9中修复。



原始答案:

此问题似乎已在Android中生根。我相信这是由于舍入错误发生时,你滚动视图到一个大的偏移量(可能是由于使用SKScalar)。可以通过创建一个具有活动和视图的新Android项目来隔离此错误:


  1. 从原点开始,

  2. 在画布上绘制一个圆形: canvas.drawCircle(screenCenterX,screenCenterY,100,mPaint)

  3. 将视图滚动到一个大数字: mainView.scrollTo(536870912,536870912)

  4. 画一个圆在画布上: canvas.drawCircle(newScreenCenterX,newScreenCenterY,100,mPaint)

第一个圆圈绘制好,第二个圆圈绘制变形。为了进一步的证据,尝试绘制你的路径接近0纬度/ 0长和放大 - 注意失真不再出现。



我将更新osmdroid票与一些可能解决方案解决方法。


I'm using OSMdroid to implement a mapping application.

I have implemented a custom MapTileProvider that uses a tile source that allows zoom levels up to 22.

The default MAPNIK provider only allows zooms to level 18.

The problem is that any PathOverlay instances draw perfectly until zoom level 19, but then are not drawn properly at zoom level 20-22. it looks like someone's rubbed out the path with an eraser over 90% of the path length (see screenshots below).

I've stepped through the draw() method of PathOverlay and exerything seems to be calculating correctly (the intermediate points appear correct for ZoomLevel 22, and then the XY projections are dividing by 22-ZoomLevel to get current screen coordinates).

Can anyone provide some insight as to what the problem is, and how to resolve it?

The same thing happens if I invoke the MapView using Cloudmade small tiles, which allows zooms up until level 20 and is a 'built-in' osmDroid tile provider class.

    //mMapTileProvider = new HighResMapTileProvider(this);
    mMapTileProvider = new MapTileProviderBasic(this,TileSourceFactory.CLOUDMADESMALLTILES);
    mMapView = new MapView(this, 256, mResourceProxy,mMapTileProvider);

So the problem does not appear to be with the tile source or provider but with the canvas drawing method. Any ideas on how to resolve this?

At zoomLevel 19 I can see my paths nicely:

But here is that same path at the next zoom level:

解决方案

Update: This has been fixed in osmdroid 3.0.9.

Original Answer:
This issue appears to be rooted in Android. I believe it is due to a rounding error that happens when you scroll a view to a large offset (possibly due to use of SKScalar). This bug can be isolated by creating a new android project with an activity and a view:

  1. Begin with the view at the origin with no scroll offset yet.
  2. Draw a circle on the canvas: canvas.drawCircle(screenCenterX, screenCenterY, 100, mPaint)
  3. Scroll the view to a large number: mainView.scrollTo(536870912, 536870912)
  4. Draw a circle on the canvas: canvas.drawCircle(newScreenCenterX, newScreenCenterY, 100, mPaint)

The first circle draws ok, the second one draws distorted. For further evidence, try to draw your path near 0 lat/0 long and zoom in - notice the distortion no longer appears.

I will update the osmdroid ticket with some possible solutions workarounds.

这篇关于OSMDroid PathOverlay绘图在高缩放级别损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆