Ticket #1936 (closed feature: fixed)

Opened 4 years ago

Last modified 4 years ago

Add GetFeature control

Reported by: ahocevar Owned by:
Priority: minor Milestone: 2.8 Release
Component: general Version: 2.7
Keywords: Cc:
State: Complete

Description (last modified by tschaub) (diff)

Selecting features from large data sets can not always be done with vector layers, due to expensive vector rendering on the browser. An alternative is select a limited set of features using a bbox filter and a protocol.

This control is a kind-of replacement for OpenLayers.Control.SelectFeature, with the following differences:

  • It is not strictly bound to a layer. A properly configured Protocol is sufficient to make it work.
  • It just triggers events when features are selected/unselected or hovered, instead of visualizing selections on a vector layer with a selectedFeatures array.

This ticket depends on #1648.

The patch contains an example and unit tests, tests pass in FF3 and IE7, acceptance tests using the example also pass in both browsers.

Thanks for any review.

Attachments

wfs-getfeature.patch Download (28.8 KB) - added by ahocevar 4 years ago.
getfeature.patch Download (27.2 KB) - added by ahocevar 4 years ago.
getfeature.2.patch Download (26.9 KB) - added by tschaub 4 years ago.
add a GetFeature control

Change History

Changed 4 years ago by ahocevar

Changed 4 years ago by elemoine

Andreas, I haven't looked at the code into detail but it seems to me that this control isn't really WFS-specific, it could probably work with any protocol accepting the filter passed to the read method.

Would changing the name of the control from WFSGetFeature to GetFeature be appropriate to you?

Changed 4 years ago by ahocevar

Eric: Right. WFS is just the default configuration. I think a name change would be appropriate. What would people think if by default no protocol would be created (making many config options obsolete), and instead adding a convenience factory method to the WFS protocol that allows for creating a protocol instance like it is done in the setMap method of the WFSGetFeature control from the above patch?

Changed 4 years ago by ahocevar

Changed 4 years ago by ahocevar

As suggested by elemoine, getfeature.patch renames the control to OpenLayers.Control.GetFeature and makes it independent of the WFS protocol. Instead, as can be seen in the example, the fromWMSLayer factory of Protocol.WFS (#1937) can be used to achieve the same convenience for overlaying a WMS layer with WFS features from the same WMS/WFS server instance.

This ticket depends on #1648, the example also depends on #1937. Tests pass in IE7 and FF3. Please review.

Changed 4 years ago by ahocevar

  • summary changed from Add WFSGetFeature control to Add GetFeature control

Changed 4 years ago by tschaub

  • description modified (diff)

Changed 4 years ago by tschaub

Andreas, this looks good. I agree with Eric's comments and like the changes (keeping this protocol agnostic).

I've put up an updated patch with a few small changes:

  • no more WFS references in comments
  • maxFeatures is not a parameter in GetFeatureInfo requests - FEATURE_COUNT is the analog, but I don't think it needs to be mentioned
the extend method no longer needs the destination argument to exist (so I modified a couple extend(foo {}, bar) calls)
  • no setting of document.body.style.cursor

The last change is probably the only important one. I'd like to avoid setting style properties in the code wherever possible. I also think we shouldn't assume control over the document body style. Instead, we should favor adding and removing class names. (This avoids clobbering any custom cursor that may have been set before.) So, I've changed the document.body.style.cursor changes with OpenLayers.Element.addClass(this.map.div, "olCursorWait") and removeClass calls.

Let me know if you don't think this achieves the results you want.

I want to check this out in conjunction with #1937 now (as the example requires that).

Changed 4 years ago by tschaub

add a GetFeature control

Changed 4 years ago by tschaub

  • state changed from Review to Commit

Nice. The example works well with #1937. I think that should go in first.

Additional small example changes in the latest patch:

Changed 4 years ago by ahocevar

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

(In [9003]) Added GetFeature control to get features based on spatial filters created by clicking or dragging boxes on the map. Thanks tschaub for the review and the final patch with valuable improvements. r=tschaub (closes #1936)

Note: See TracTickets for help on using tickets.