tangram icon indicating copy to clipboard operation
tangram copied to clipboard

Implement getFeaturesIn(polygon, filterOptions)

Open mountainMath opened this issue 8 years ago • 2 comments
trafficstars

The getFeatureAt method allows to get access to the properties of a single visible feature. For data visualizations it would be great to also have a getFeaturesIn method that allows access to all of the properties of (visible) features of a particular source intersecting a given polygon (or bounding box) within the map window. My use case is to display e.g. a histogram of a property of all the visible features. I am thinking of something like mapbox-gl queryRenderedFeatures and/or querySourceFeatures.

mountainMath avatar Mar 13 '17 06:03 mountainMath

Hi @mountainMath - we are interested in adding something like this (some prototypes are here and here), but need to assess the right approach. We might limit such a method's scope in a couple ways:

  • Only queries visible features (those that matches the style filters), rather than all raw source data features.
  • Only returns feature properties, not full geometries (the latter is often suboptimal anyway since many logical features are split across tiles).

The above limitations are related to the need to retain the full tile data, even after the visible geometry has been built. While we do currently retain all that data, I'm hesitant to introduce a new feature that requires us to in the future. In fact, we're already looking at deallocating that tile data sooner (or completely), because it could significantly decrease memory usage... competing priorities :)

However, I think a query feature method could probably be tied into our existing feature selection system for visible properties, without too much downside. This is the approach the query-features-selection branch takes.

For histograms and other lightweight analysis, returning properties would suffice though and I think would provide a nice extension to the library.

bcamper avatar Mar 27 '17 17:03 bcamper

@mountainMath The open PR #566 is not exactly what is described here, but is very relevant.

bcamper avatar Jun 12 '17 17:06 bcamper