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

symbol sorting for viewport labelling #5298

Merged
merged 6 commits into from Sep 15, 2017

Conversation

ansis
Copy link
Contributor

@ansis ansis commented Sep 14, 2017

This sorts symbols that may overlap based on their vertical position. The sorting happens at the end of symbol placement within commitPlacement.

The sorting happens in each tile independently. This means there might be incorrect sorting near tile edges but I think that fixing that minor drawback would be not worth the added complexity. Unless we switch back to the clipping approach we used before.

@ChrisLoer

Copy link
Contributor

@ChrisLoer ChrisLoer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me (pending tests passing).

}

bind() {
this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.buffer);
}

updateData(array: TriangleIndexArray | LineIndexArray) {
this.bind();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to assert here that it's in dynamicDraw mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep!

const symbolInstance = this.symbolInstances[i];

for (const placedTextSymbolIndex of symbolInstance.placedTextSymbolIndices) {
const placedSymbol = this.placedGlyphArray.get(placedTextSymbolIndex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in reading this as "we sort symbols within a segment, but symbols can't reorder between segments"? And if that's the case, aren't we basically giving up on sorting when there are multiple segments? That seems OK since this is an edge case, but if we're going to give up, why not just early-exit the entire sorting process?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's kind of giving up. I hadn't thought about an early-exit but that's probably cleaner. This approach sorts them so that they look mostly right, but is more complicated and probably error-prone. I'll switch to an early exit!

@ChrisLoer
Copy link
Contributor

Oh also as part of these changes we should un-ignore the tests tagged 5150 in ignores.json and update the expected images as appropriate.

@ChrisLoer
Copy link
Contributor

Err, another concern: doesn't this break the debug collision boxes/circles for sorted symbols? Their index arrays will need the same re-sorting...

@ansis
Copy link
Contributor Author

ansis commented Sep 14, 2017

Err, another concern: doesn't this break the debug collision boxes/circles for sorted symbols? Their index arrays will need the same re-sorting...

Nope, this leaves collision box rendering unchanged. Their boxes are rendered un an unsorted order, but that seems ok to consider it's just a debug view and these symbols are all allowed to overlap.

@ChrisLoer
Copy link
Contributor

Nope, this leaves collision box rendering unchanged.

🤦‍♂️ I didn't think that through all the way -- forgot you're not changing the sort of the symbolInstances themselves.

Previously the symbols were sorted in the y direction before running
them through the collision code. Now only the rendering is sorted and
the collision order depends on the original data order.

I think this is the right approach because:
- we should respect data order so that it can be used for label
  importance
- data order is consistent, while y order changes with rotation
@ChrisLoer
Copy link
Contributor

Looks great to me, let's merge it into viewport-collision.

We can do it on either branch, but we should be able to remove these three ignores now:

"render-tests/symbol-spacing/line-close": "WIP Ignore for PR #5150 (no more tile clipping artifacts)",
"render-tests/symbol-spacing/line-far": "WIP Ignore for PR #5150 (no more tile clipping artifacts)",
"render-tests/text-tile-edge-clipping/default": "WIP Ignore for PR #5150 (no more tile clipping artifacts)"

We'll have to update the expected results, but the new results should be unambiguously better. 😃

@ansis ansis merged commit 8f330f3 into viewport-collision Sep 15, 2017
@jfirebaugh jfirebaugh deleted the viewport-collision-sort branch September 21, 2017 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants