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

Fix depth picking from GeoJSON layer for binary features #7817

Merged
merged 20 commits into from
Apr 21, 2023

Conversation

gabeboning
Copy link
Contributor

@gabeboning gabeboning commented Apr 6, 2023

Depth picking from binary features does not work when the features are not all the same type (i.e. not all polygons). This is because the global feature index -- the index in the GeoJSON equivalent -- does not necessarily match the index of the feature/datum in each of the point/polygon/line sublayers.

This PR adds a _getSublayerPickingIndex method to allow composite layers to translate picked ids from a global id into the correct one (or multiple, to correctly handle MultiPolygon/MultiLineString cases where a single global id has multiple local ids) to be used for clearing the picking buffer.

It doesn't feel like the cleanest approach, but I do like that it keeps the knowledge about indices in the layer that would know (the composite parent). Happy to attempt it some other way if anyone has a proposed better approach; though this does seem to work reliably.

@gabeboning gabeboning changed the title Fix depth picking for binary features Fix depth picking from GeoJSON layer for binary features Apr 6, 2023
@gabeboning gabeboning marked this pull request as draft April 7, 2023 00:29
@gabeboning gabeboning force-pushed the binary-features-depth-picking branch from 579ed5d to 7d36e64 Compare April 7, 2023 01:48
@coveralls
Copy link

coveralls commented Apr 7, 2023

Coverage Status

Coverage: 89.746% (-0.03%) from 89.778% when pulling 4c8b383 on gabeboning:binary-features-depth-picking into 2eaabdd on visgl:master.

@gabeboning gabeboning marked this pull request as ready for review April 7, 2023 16:23
modules/core/src/lib/layer.ts Outdated Show resolved Hide resolved
modules/core/src/lib/layer.ts Outdated Show resolved Hide resolved
modules/core/src/lib/layer.ts Outdated Show resolved Hide resolved
modules/core/src/lib/layer.ts Outdated Show resolved Hide resolved
modules/core/src/lib/layer.ts Outdated Show resolved Hide resolved
modules/core/src/lib/layer.ts Show resolved Hide resolved
values[i + 2] === objectColor[2]
) {
this._disablePickingIndex(index);
break;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This break will prevent disabling picking colors correctly for multi polygons or multi line strings -- every match needs to disabled, not just the first one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see, sorry about that. Could you kill the line and make sure this PR fixes the original issue before we merge? I think the only thing missing is unit tests, but I can add that in a follow up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed + verified that it works as I'd expect now!

@Pessimistress Pessimistress merged commit edf231c into visgl:master Apr 21, 2023
Pessimistress added a commit that referenced this pull request Apr 26, 2023
Co-authored-by: Xiaoji Chen <Pessimistress@users.noreply.github.com>
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.

3 participants