MapSuiteGisEditor/WpfDesktopExtension/Shares/Extensions/FeaturesExtension.cs
/// <summary>
/// Get all the features that will be drawn at the current zoom level.
/// This method filter the input feature by using the containing layer's styles, .
/// </summary>
/// <param name="features">The input features.</param>
/// <param name="containingLayer">The FeatureLayer that contains the features.</param>
/// <returns>The features that are visible at current zoom level.</returns>
Get all the features that will be drawn at the current zoom level.
This method filter the input feature by using the containing layer's styles, .
Get all the features that will be drawn at the current zoom level . This method filter the input feature by using the containing layer ' s styles .
public static IEnumerable<Feature> GetVisibleFeatures(this IEnumerable<Feature> features, ZoomLevelSet zoomLevelSet, RectangleShape boundingBox, double screenWidth, GeographyUnit mapUnit)
        {
            ZoomLevel currentDrawingZoomLevel = zoomLevelSet.GetZoomLevelForDrawing(boundingBox, screenWidth, mapUnit);
            if (currentDrawingZoomLevel != null)
            {
                if (ContainsCustomStyles(currentDrawingZoomLevel) || ContainsDefaultStyles(currentDrawingZoomLevel))
                {
                    foreach (var feature in features)
                    {
                        yield return feature;
                    }
                }
                else
                {
                    var valueStyles = currentDrawingZoomLevel.CustomStyles.OfType<CompositeStyle>().SelectMany(c => c.Styles).OfType<ValueStyle>();
                    var classBreakStyles = currentDrawingZoomLevel.CustomStyles.OfType<CompositeStyle>().SelectMany(c => c.Styles).OfType<ClassBreakStyle>();
                    var filterStyles = currentDrawingZoomLevel.CustomStyles.OfType<CompositeStyle>().SelectMany(c => c.Styles).OfType<FilterStyle>();
                    foreach (var feature in features)
                    {
                        bool isFeatureValidForValueStyle = valueStyles.Any(valueStyle => ValidateFeature(feature, valueStyle));
                        bool isFeatureValidForClassBreakStyle = classBreakStyles.Any(classBreakStyle => ValidateFeature(feature, classBreakStyle));
                        bool isFeatureValidForFilterStyles = filterStyles.Any(filterStyle => ValidateFeature(feature, filterStyle));
                        if (isFeatureValidForValueStyle || isFeatureValidForClassBreakStyle || isFeatureValidForFilterStyles)
                        {
                            yield return feature;
                        }
                    }
                }
            }
        }
public static IEnumerable < Feature > GetVisibleFeatures ( this IEnumerable < Feature > features , ZoomLevelSet zoomLevelSet , RectangleShape boundingBox , double screenWidth , GeographyUnit mapUnit ) { ZoomLevel currentDrawingZoomLevel = zoomLevelSet . GetZoomLevelForDrawing ( boundingBox , screenWidth , mapUnit ) ; if ( currentDrawingZoomLevel != null ) { if ( ContainsCustomStyles ( currentDrawingZoomLevel ) || ContainsDefaultStyles ( currentDrawingZoomLevel ) ) { foreach ( var feature in features ) { yield return feature ; } } else { var valueStyles = currentDrawingZoomLevel . CustomStyles . OfType < CompositeStyle > ( ) . SelectMany ( c => c . Styles ) . OfType < ValueStyle > ( ) ; var classBreakStyles = currentDrawingZoomLevel . CustomStyles . OfType < CompositeStyle > ( ) . SelectMany ( c => c . Styles ) . OfType < ClassBreakStyle > ( ) ; var filterStyles = currentDrawingZoomLevel . CustomStyles . OfType < CompositeStyle > ( ) . SelectMany ( c => c . Styles ) . OfType < FilterStyle > ( ) ; foreach ( var feature in features ) { bool isFeatureValidForValueStyle = valueStyles . Any ( valueStyle => ValidateFeature ( feature , valueStyle ) ) ; bool isFeatureValidForClassBreakStyle = classBreakStyles . Any ( classBreakStyle => ValidateFeature ( feature , classBreakStyle ) ) ; bool isFeatureValidForFilterStyles = filterStyles . Any ( filterStyle => ValidateFeature ( feature , filterStyle ) ) ; if ( isFeatureValidForValueStyle || isFeatureValidForClassBreakStyle || isFeatureValidForFilterStyles ) { yield return feature ; } } } } }
Get all the features that will be drawn at the current zoom level.
Get all the features that will be drawn at the current zoom level .
//ClassBreakStyle //ValueStyle //if there are any default styles, then the features are visible //if there are any regular styles in the custom styles collection, then the features are visible //if there are no default styles and there are no regular styles in the custom styles collection, then we need //to check every style in the custom styles collection to determine if a feature is visible
The features that are visible at current zoom level.
The features that are visible at current zoom level .
IEnumerable<Feature>
this
zoomLevelSet
ZoomLevelSet
boundingBox
RectangleShape
screenWidth
double
mapUnit
GeographyUnit
features
The input features.
The input features .
containingLayer
The FeatureLayer that contains the features.
The FeatureLayer that contains the features .