绘制PointPlacemarks

时间:2015-07-15 17:58:37

标签: java worldwind

有没有办法在World Wind中修复PointPlacemarks的绘制顺序?

即使在<{>>地标B 的Placemarks example排序中,只需在特定缩放级别移动鼠标即可更改音频地标:

enter image description here

enter image description here

到目前为止,我已经尝试过:

1 个答案:

答案 0 :(得分:0)

Hacky解决方案(需要修改World Wind源代码)

gov.nasa.worldwind.render.DrawContextImpl

更改orderedRenderables
protected PriorityQueue<OrderedRenderableEntry> orderedRenderables =
    new PriorityQueue<OrderedRenderableEntry>(100, new Comparator<OrderedRenderableEntry>()
    {
        public int compare(OrderedRenderableEntry orA, OrderedRenderableEntry orB)
        {
            double eA = orA.distanceFromEye;
            double eB = orB.distanceFromEye;

            return eA > eB ? -1 : eA == eB ? (orA.time < orB.time ? -1 : orA.time == orB.time ? 0 : 1) : 1;
        }
    });

protected Queue<OrderedRenderableEntry> orderedRenderables = new ArrayDeque<>();

(或修改比较器以做你想要的)。这将修复绘图顺序。

替代解决方案(不需要修改World Wind源代码)

扩展PointPlacemark并覆盖makeOrderedRenderable()

public class OrderedPointPlacemark extends PointPlacemark {
    public OrderedPointPlacemark(Position position) {
        super(position);
    }
    @Override
    protected void makeOrderedRenderable(DrawContext dc) {
        super.makeOrderedRenderable(dc);

        if (this.intersectsFrustum(dc) || this.isDrawLine(dc)) {
            dc.pollOrderedRenderables();
            dc.addOrderedSurfaceRenderable(this);
        }
    }
}