Ticket #2418 (closed feature: fixed)

Opened 3 years ago

Last modified 3 years ago

selecting features using a box shouldn't select unrendered features

Reported by: pgiraud Owned by: pgiraud
Priority: major Milestone: 2.9 Release
Component: Control.SelectFeature Version: 2.8
Keywords: Cc:
State: Complete

Description

In the SelectFeature control, the selectBox method doesn't take care about whether the feature is rendered or not.

Please review the attached patch.

Attachments

patch-2418-r9944.diff Download (1.8 KB) - added by pgiraud 3 years ago.
patch-2418-A1-r10006.diff Download (3.1 KB) - added by pgiraud 3 years ago.
patch with Andreas recommandations
patch-2418-A2-r10006.diff Download (4.7 KB) - added by pgiraud 3 years ago.
same patch with unit tests for the new "isDisplayed" method

Change History

Changed 3 years ago by pgiraud

Changed 3 years ago by elemoine

although I think it's correct that, in the current code, features with display:none are in the unrenderedFeatures object I'm not sure it's good idea to rely on that object to look up features that aren't displayed. The documentation for undereredFeatures says: hash of features, keyed by feature.id, that the renderer failed to draw, so the purpose of this object doesn't include storing features that aren't rendered because their "display" property is set to "none". I'd to know what others - ahocevar in particular - think about that.

Changed 3 years ago by ahocevar

  • state changed from Review to Needs More Work

There are several reasons why features can end up in the unrenderedFeatures object, and these are not consistent among renderers. So this is definitely not the condition to check. While the patch will work with SVG renderers, it will most likely fail with others. The correct way to check whether a feature is displayed is to check for the "display" symbolizer property:

  • feature.style.display
  • feature.layer.styleMap ? feature.layer.styleMap.createSymbolizer(feature, feature.renderIntent).display
  • feature.layer.style.display

Changed 3 years ago by pgiraud

patch with Andreas recommandations

Changed 3 years ago by pgiraud

I just attached a new patch. It takes Andreas' great recommendations into account. It looks like it's the way to go. I'm currently writing tests to add to this patch for the new Feature.Vector.isDisplayed() method but you can already take a look at the patch.

Changed 3 years ago by pgiraud

same patch with unit tests for the new "isDisplayed" method

Changed 3 years ago by pgiraud

  • state changed from Needs More Work to Review

Changed 3 years ago by ahocevar

  • state changed from Review to Commit

Looks good. One suggestion: rename the new isDisplayed method to getVisibility, to be consistent with the Layer API. Please commit after making this change and if you can confirm that tests pass.

Changed 3 years ago by tschaub

  • owner changed from tschaub to pgiraud

Changed 3 years ago by pgiraud

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [10064]) adds a new getVisibility method in the Feature.Vector class, used in the SelectFeature control this method now allows us to tell the select feature box handler wether to select or not the features, r=ahocevar, (Closes #2418)

Note: See TracTickets for help on using tickets.