Class FeatureLayer


  • public class FeatureLayer
    extends StyleLayer
    Layer responsible for rendering vector information provided by a FeatureSource.

    The FeatureLayer combines:

    • data: FeatureSource
    • style: Style
    Please note that a StyleLayerDescriptor (defined by SLD) document is usually used to describe the rendering requirements for an entire Map; while a Style (defined by SE) is focused on a single layer of content
    Since:
    2.7
    • Field Detail

      • query

        protected Query query
        Query use to limit content of featureSource
      • sourceListener

        protected FeatureListener sourceListener
        Listener to forward feature source events as layer events
    • Constructor Detail

      • FeatureLayer

        public FeatureLayer​(FeatureSource featureSource,
                            Style style)
        Creates a new instance of FeatureLayer
        Parameters:
        featureSource - the data source for this layer
        style - the style used to represent this layer
    • Method Detail

      • connectDataListener

        protected void connectDataListener​(boolean listen)
        Used to connect/disconnect a FeatureListener if any map layer listeners are registered.
        Overrides:
        connectDataListener in class Layer
        Parameters:
        listen - true to connect, false to disconnect
      • dispose

        public void dispose()
        Description copied from class: Layer
        Allows a Layer to clean up any listeners, or internal caches or resources it has added during use.
        Overrides:
        dispose in class StyleLayer
      • getFeatureSource

        public FeatureSource<?,​?> getFeatureSource()
        Get the feature source for this layer.
        Overrides:
        getFeatureSource in class Layer
        Returns:
        feature source for the contents of this layer
      • getSimpleFeatureSource

        public SimpleFeatureSource getSimpleFeatureSource()
        Get the feature source for this layer.
        Returns:
        SimpleFeatureSource for this layer, or null if not available
      • getQuery

        public Query getQuery()
        Returns the definition query (filter) for this layer. If no definition query has been defined Query.ALL is returned.
        Overrides:
        getQuery in class Layer
        Returns:
        Query used to process content prior to display, or Query.ALL to indicate all content is used
      • setQuery

        public void setQuery​(Query query)
        Sets a definition query for the layer which acts as a filter for the features that the layer will draw.

        A consumer must ensure that this query is used in combination with the bounding box filter generated on each map interaction to limit the number of features returned to those that complains both the definition query and relies inside the area of interest.

        IMPORTANT: only include attribute names in the query if you want them to be ALWAYS returned. It is desirable to not include attributes at all but let the layer user (a renderer?) to decide wich attributes are actually needed to perform its requiered operation.

      • getBounds

        public ReferencedEnvelope getBounds()
        Description copied from class: Layer
        The bounds of the Layer content (if known). The bounds can be used to determine if any of the layers content is "on screen" when rendering the map; however often it is expensive to calculate a layers bounds up front so we are allowing this value to be optional.

        The returned bounds are a ReferencedEnvelope using the same CoordinateReferenceSystem as the layers contents.

        Specified by:
        getBounds in class Layer
        Returns:
        layer bounds, null if unknown