CesiumGS/cesium

EntityCluster hasLabelIndex always returns false

Open

#7,446 建立於 2019年1月2日

在 GitHub 查看
 (3 留言) (0 反應) (1 負責人)JavaScript (3,324 fork)batch import
FCFJTCcategory - clusteringgood first issuetype - bug

倉庫指標

Star
 (11,758 star)
PR 合併指標
 (平均合併 15天 12小時) (30 天內合併 23 個 PR)

描述

This was reported on the forum with a suggested fix but I haven't had a chance to try it out and investigate it further so I'm documenting it here.

The Problem

This is the hasLabelIndex function in EntityCluster.js:

function hasLabelIndex(entityCluster, entityId) {
   return defined(entityCluster) && defined(entityCluster._collectionIndicesByEntity[entityId]) && defined(entityCluster._collectionIndicesByEntity[entityId].labelIndex);
}

The supplied entityId is an object, not a string, so defined(entityCluster._collectionIndicesByEntity[entityId]) will always be false.

Suggested Fix

I think the problem is that in addNonClusteredItem and getBoundingBox, it passes item.id as the entityId, but that's actually the entity itself. Instead, it should perhaps pass item.id.id.

It would be good to also write a test that would start out failing and is fixed after this is fixed.

How To Test

What I did to see that this was happening was launch the test suite on the EntityCluster class (using http://localhost:8080/Specs/SpecRunner.html?spec=DataSources%2FEntityCluster) and placing a console.log to see that it does indeed always return false, and passes an object instead of a string.

@hpinkos maybe we can label this "Good First Issue" ?

貢獻者指南