-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix polyline color issue involving duplicate positions #9676
Conversation
Thanks for the pull request @j9liu!
Reviewers, don't forget to make sure that:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed summary at the top of PR. It was good to see that you tested a bunch of different cases. And nice catch with the wrapAround
bug.
EDIT: now that I'm thinking about it, in the per-vertex example it probably makes more sense for the orange point to be removed rather than the middle black vertex, because that preserves the original coloring. I'll work a fix tomorrow
Thank for pointing this out. I'll look out for your fix tomorrow.
Source/Core/arrayRemoveDuplicates.js
Outdated
} | ||
|
||
return cleanedvalues; | ||
return cleanedValues; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two separate sections of code that handle wrapAround
can be combined. It should be fine to check the first and last element of values
rather than cleanedValues
, the answer ought to be the same.
Even nicer would be to combine all the code into a single for loop, but only if it can be done cleanly.
Context for just-committed changes: I ran into a case today where if I have an array This commit should take care of this case, but the |
@lilleyse - Fix just pushed. Now the sandcastle should look like this. I handled endpoint cases differently than cases where the point is in the middle of the polyline. If a polyline looks like |
@lilleyse - made the changes you suggested; let me know if there's anything else that needs adjustment! |
Thanks, the updates look great! |
Fixes #9379. This PR changes how colors are handled in
PolylineGeometry.createGeometry
:arrayRemoveDuplicates
now accepts an optionalremovedIndices
parameter. If any entries are removed from the original array during this function, the indices of those entries will be stored inremovedIndices
in sorted order.createGeometry
will use this array to remove the colors that correspond to those extraneous positions. This should work for both segment coloring and per-vertex coloring.Additionally, I noticed that if
wrapAround
were set totrue
in the parameters, and if an array's first and last entries were equal,arrayRemoveDuplicates
would remove the first entry. However, the examples in the documentation suggested that the last entry was supposed to be removed instead. I changed the function to match the example.Segment Coloring
This sandcastle was linked in the issue to demonstrate the bug. It sets up the following polyline:
In the current version of Cesium, if the orange segment is collapsed, the remaining segments will be colored incorrectly as shown.
The changes in PR result in this polyline:
Vertex Coloring
We can modify the sandcastle to have per-vertex coloring like so.
If we try to remove the black vertex by making it a duplicate, in the current version of Cesium, we'll find that it just shifts over to the other vertices:
However, we can remove it with these PR's changes:
cc @lilleyse for review
EDIT: now that I'm thinking about it, in the per-vertex example it probably makes more sense for the orange point to be removed rather than the middle black vertex, because that preserves the original coloring. I'll work a fix tomorrow