Ejemplo n.º 1
0
        private static List <IFeature> RenderVectorLayerFeatures(IViewport viewport, ILayer layer)
        {
            try
            {
                var features = new List <IFeature>();
                if (layer.Name.Equals("Open Street Map"))
                {
                    Console.WriteLine("");
                    features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();
                }
                else
                {
                    features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();
                }

                //Console.WriteLine("Layer " + layer.Name + " Features.Count = " + features.Count);

                //if(layer.Name.Equals("Open Street Map") && features.Count > 0)
                Console.WriteLine("");

                if (layer.Style != null)
                {
                    var style = layer.Style;                     // This is the default that could be overridden by an IThemeStyle

                    foreach (var feature in features)
                    {
                        if (layer.Style is IThemeStyle)
                        {
                            style = (layer.Style as IThemeStyle).GetStyle(feature);
                        }
                        if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.Resolution) || (style.MaxVisible < viewport.Resolution))
                        {
                            continue;
                        }

                        RenderFeature(viewport, style, feature, layer.Name);
                    }
                }

                foreach (var feature in features)
                {
                    var styles = feature.Styles ?? Enumerable.Empty <IStyle>();
                    foreach (var style in styles)
                    {
                        if (feature.Styles != null && style.Enabled)
                        {
                            RenderFeature(viewport, style, feature, layer.Name);
                        }
                    }
                }

                return(features);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(null);
            }
        }
Ejemplo n.º 2
0
        private static void IterateLayer(IViewport viewport, ILayer layer,
            Action<IViewport, IStyle, IFeature> callback)
        {
            var features = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution).ToList();

            var layerStyles = layer.Style is StyleCollection ? (layer.Style as StyleCollection).ToArray() : new [] {layer.Style};
            foreach (var layerStyle in layerStyles)
            {
                var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                foreach (var feature in features)
                {
                    if (layerStyle is IThemeStyle) style = (layerStyle as IThemeStyle).GetStyle(feature);
                    if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.RenderResolution) || (style.MaxVisible < viewport.RenderResolution)) continue;

                    callback(viewport, style, feature);
                }
            }

            foreach (var feature in features)
            {
                var featureStyles = feature.Styles ?? Enumerable.Empty<IStyle>();
                foreach (var featureStyle in featureStyles)
                {
                    if (feature.Styles != null && featureStyle.Enabled)
                    {
                        callback(viewport, featureStyle, feature);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static Canvas RenderVectorLayer(IViewport viewport, ILayer layer, bool rasterizing = false)
        {
            // todo:
            // find solution for try catch. Sometimes this method will throw an exception
            // when clearing and adding features to a layer while rendering
            var canvas = new Canvas
            {
                Opacity          = layer.Opacity,
                IsHitTestVisible = false
            };

            try
            {
                var features    = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution).ToList();
                var layerStyles = BaseLayer.GetLayerStyles(layer);
                var brushCache  = new BrushCache();

                foreach (var layerStyle in layerStyles)
                {
                    var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                    foreach (var feature in features)
                    {
                        if (layerStyle is IThemeStyle)
                        {
                            style = (layerStyle as IThemeStyle).GetStyle(feature);
                        }
                        if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.Resolution) || (style.MaxVisible < viewport.Resolution))
                        {
                            continue;
                        }

                        RenderFeature(viewport, canvas, feature, style, rasterizing, brushCache);
                    }
                }

                foreach (var feature in features)
                {
                    var styles = feature.Styles ?? Enumerable.Empty <IStyle>();
                    foreach (var style in styles)
                    {
                        if (feature.Styles != null && style.Enabled)
                        {
                            RenderFeature(viewport, canvas, feature, style, rasterizing, brushCache);
                        }
                    }
                }

                return(canvas);
            }
            catch (Exception)
            {
                return(canvas);
                //If exception happens inside RenderFeature function after at-least one child has been added to the canvas,
                //returning new canvas will leave the previously created (but not yet added to parent canvas) canvas abandoned, that will
                //cause the exception when resuing RenderedGeometry object, because at-least one RenderedGeometry was attached to that abandoned canvas.
                //returning the same canvas will solve this error, as it will be clear this canvas childs on next render call.
                //return new Canvas { IsHitTestVisible = false };
            }
        }
Ejemplo n.º 4
0
        private static Canvas RenderVectorLayer(IViewport viewport, ILayer layer, bool rasterizing = false)
        {
            // todo:
            // find solution for try catch. Sometimes this method will throw an exception
            // when clearing and adding features to a layer while rendering
            try
            {
                var canvas = new Canvas
                {
                    Opacity          = layer.Opacity,
                    IsHitTestVisible = false
                };

                var features    = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution).ToList();
                var layerStyles = BaseLayer.GetLayerStyles(layer);
                var brushCache  = new BrushCache();

                foreach (var layerStyle in layerStyles)
                {
                    var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                    foreach (var feature in features)
                    {
                        if (layerStyle is IThemeStyle)
                        {
                            style = (layerStyle as IThemeStyle).GetStyle(feature);
                        }
                        if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.Resolution) || (style.MaxVisible < viewport.Resolution))
                        {
                            continue;
                        }

                        RenderFeature(viewport, canvas, feature, style, rasterizing, brushCache);
                    }
                }

                foreach (var feature in features)
                {
                    var styles = feature.Styles ?? Enumerable.Empty <IStyle>();
                    foreach (var style in styles)
                    {
                        if (feature.Styles != null && style.Enabled)
                        {
                            RenderFeature(viewport, canvas, feature, style, rasterizing, brushCache);
                        }
                    }
                }

                return(canvas);
            }
            catch (Exception e)
            {
                return(new Canvas {
                    IsHitTestVisible = false
                });
            }
        }
Ejemplo n.º 5
0
        private static void IterateVectorLayer(IViewport viewport, ILayer layer, StyleContext context,
            Action<IViewport, IStyle, IFeature, StyleContext> callback)
        {
            var features = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution)
                .Select((f, i) =>
                {
                    ReleaseLoad(i);
                    return f;
                })
                .Where(f =>
                {
                    if (f.Geometry is Mapsui.Geometries.Point) return true;
                    var boundingBox = f.Geometry.GetBoundingBox();
                    return boundingBox.Height / viewport.Resolution > 0.1 ||
                        boundingBox.Width / viewport.Resolution > 0.1;
                })
            .ToList();

            var layerStyles = layer.Style is StyleCollection ? (layer.Style as StyleCollection).ToArray() : new[] { layer.Style };
            foreach (var layerStyle in layerStyles)
            {
                var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.RenderResolution) || (style.MaxVisible < viewport.RenderResolution)) continue;

                for (int i = 0; i < features.Count; i++)
                {
                    var feature = features[i];

                    if (layerStyle is IThemeStyle) style = (layerStyle as IThemeStyle).GetStyle(feature);

                    callback(viewport, style, feature, context);

                    ReleaseLoad(i);
                }
            }

            for (int i = 0; i < features.Count; i++)
            {
                var feature = features[i];

                if (feature.Styles != null)
                {
                    foreach (var featureStyle in feature.Styles)
                    {
                        if (feature.Styles != null && featureStyle.Enabled)
                        {
                            callback(viewport, featureStyle, feature, context);
                        }
                    }
                }

                ReleaseLoad(i);
            }

            ReleaseLoad(0);
        }
Ejemplo n.º 6
0
        private static void IterateLayer(IReadOnlyViewport viewport, ILayer layer,
                                         Action <IReadOnlyViewport, ILayer, IStyle, IFeature, float> callback)
        {
            var features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();

            var layerStyles = ToArray(layer);

            foreach (var layerStyle in layerStyles)
            {
                var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                foreach (var feature in features)
                {
                    if (layerStyle is IThemeStyle)
                    {
                        style = (layerStyle as IThemeStyle).GetStyle(feature);
                    }
                    if (ShouldNotBeApplied(style, viewport))
                    {
                        continue;
                    }

                    if (style is StyleCollection styles) // The ThemeStyle can again return a StyleCollection
                    {
                        foreach (var s in styles)
                        {
                            if (ShouldNotBeApplied(s, viewport))
                            {
                                continue;
                            }
                            callback(viewport, layer, s, feature, (float)layer.Opacity);
                        }
                    }
                    else
                    {
                        callback(viewport, layer, style, feature, (float)layer.Opacity);
                    }
                }
            }

            foreach (var feature in features)
            {
                var featureStyles = feature.Styles ?? Enumerable.Empty <IStyle>(); // null check
                foreach (var featureStyle in featureStyles)
                {
                    if (ShouldNotBeApplied(featureStyle, viewport))
                    {
                        continue;
                    }

                    callback(viewport, layer, featureStyle, feature, (float)layer.Opacity);
                }
            }
        }
Ejemplo n.º 7
0
        private static void IterateLayer(IViewport viewport, ILayer layer,
                                         Action <IViewport, IStyle, IFeature, float> callback)
        {
            var features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();

            var layerStyles = ToArray(layer);

            foreach (var layerStyle in layerStyles)
            {
                var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                foreach (var feature in features)
                {
                    if (layerStyle is IThemeStyle)
                    {
                        style = (layerStyle as IThemeStyle).GetStyle(feature);
                    }
                    if (style == null || style.Enabled == false || style.MinVisible > viewport.Resolution || style.MaxVisible < viewport.Resolution)
                    {
                        continue;
                    }

                    if (style is StyleCollection styles) // The ThemeStyle can again return a StyleCollection
                    {
                        foreach (var s in styles)
                        {
                            callback(viewport, s, feature, (float)layer.Opacity);
                        }
                    }
                    else
                    {
                        callback(viewport, style, feature, (float)layer.Opacity);
                    }
                }
            }

            foreach (var feature in features)
            {
                var featureStyles = feature.Styles ?? Enumerable.Empty <IStyle>(); // null check
                foreach (var featureStyle in featureStyles)
                {
                    if (feature.Styles != null && featureStyle.Enabled)
                    {
                        callback(viewport, featureStyle, feature, (float)layer.Opacity);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private static void RenderLayer(Graphics graphics, IViewport viewport, ILayer layer, AbortRenderDelegate abortRender)
        {
            int       counter = 0;
            const int step    = 100;

            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            foreach (var layerStyle in layer.Styles)
            {
                var style = layerStyle;

                var features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution);

                //Linestring outlines is drawn by drawing the layer once with a thicker line
                //before drawing the "inline" on top.
                var enumerable = features as IList <IFeature> ?? features.ToList();
                foreach (var feature in enumerable)
                {
                    if ((counter++ % step == 0) && abortRender != null && abortRender())
                    {
                        return;
                    }
                    if (layerStyle is IThemeStyle)
                    {
                        style = (layerStyle as IThemeStyle).GetStyle(feature);
                    }

                    if ((style is VectorStyle) && ((style as VectorStyle).Outline != null))
                    {
                        GdiGeometryRenderer.RenderGeometryOutline(graphics, viewport, feature.Geometry, style as VectorStyle);
                    }
                }

                foreach (var feature in enumerable)
                {
                    if ((counter++ % step == 0) && abortRender != null && abortRender())
                    {
                        return;
                    }
                    if (layerStyle is IThemeStyle)
                    {
                        style = (layerStyle as IThemeStyle).GetStyle(feature);
                    }
                    RenderGeometry(graphics, viewport, feature.Geometry, style as VectorStyle);
                }
            }
        }
Ejemplo n.º 9
0
        public IEnumerable <IFeature> GetFeaturesInView(BoundingBox extent, double resolution)
        {
            lock (_syncLock)
            {
                foreach (var feature in _layer.GetFeaturesInView(extent, resolution))
                {
                    // hack: clear cache to prevent cross thread exception.
                    // todo: remove this caching mechanism.
                    feature.RenderedGeometry.Clear();
                }

                IFeatures features = null;
                var       viewport = CreateViewport(extent, resolution);
                RunMethodOnStaThread(() => RenderToRaster(viewport, _layer, out features));
                return(features);
            }
        }
Ejemplo n.º 10
0
        public override IEnumerable <IFeature> GetFeaturesInView(BoundingBox box, double resolution)
        {
            var features = _source.GetFeaturesInView(box, resolution).ToList();

            foreach (var feature in features)
            {
                if (feature.Geometry is Point || feature.Geometry is MultiPoint)
                {
                    continue;                                                              // Points with a vertex on top confuse me
                }
                foreach (var vertices in feature.Geometry.MainVertices())
                {
                    yield return(new Feature {
                        Geometry = vertices
                    });
                }
            }
        }
Ejemplo n.º 11
0
        private static void IterateVectorLayer(IViewport viewport, ILayer layer,
                                               Action <IViewport, IStyle, IFeature> callback)
        {
            var features = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution).ToList();

            var layerStyles = layer.Style is StyleCollection ? (layer.Style as StyleCollection).ToArray() : new[] { layer.Style };

            foreach (var layerStyle in layerStyles)
            {
                var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                foreach (var feature in features)
                {
                    if (layerStyle is IThemeStyle)
                    {
                        style = (layerStyle as IThemeStyle).GetStyle(feature);
                    }
                    if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.RenderResolution) || (style.MaxVisible < viewport.RenderResolution))
                    {
                        continue;
                    }

                    callback(viewport, style, feature);
                }
            }

            foreach (var feature in features)
            {
                var featureStyles = feature.Styles ?? Enumerable.Empty <IStyle>();
                foreach (var featureStyle in featureStyles)
                {
                    if (feature.Styles != null && featureStyle.Enabled)
                    {
                        callback(viewport, featureStyle, feature);
                    }
                }
            }
        }
Ejemplo n.º 12
0
		private static List<IFeature> RenderVectorLayerFeatures(IViewport viewport, ILayer layer)
		{
			try
			{

				var features = new List<IFeature>();
				if(layer.Name.Equals("Open Street Map"))
				{
					Console.WriteLine("");
					features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();
				}else
				{
					features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();
				}

				//Console.WriteLine("Layer " + layer.Name + " Features.Count = " + features.Count);

				//if(layer.Name.Equals("Open Street Map") && features.Count > 0)
					Console.WriteLine("");

				if(layer.Style != null)
				{
					var style = layer.Style; // This is the default that could be overridden by an IThemeStyle

					foreach (var feature in features)
					{
						if (layer.Style is IThemeStyle) style = (layer.Style as IThemeStyle).GetStyle(feature);
						if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.Resolution) || (style.MaxVisible < viewport.Resolution)) continue;

						RenderFeature(viewport, style, feature, layer.Name);
					}
				}

				foreach (var feature in features)
				{
					var styles = feature.Styles ?? Enumerable.Empty<IStyle>();
					foreach (var style in styles)
					{
						if (feature.Styles != null && style.Enabled)
						{
							RenderFeature(viewport, style, feature, layer.Name);
						}
					}
				}

				return features;
			}
			catch (Exception e)
			{
				Console.WriteLine(e.Message);
				return null;   
			}
		}
Ejemplo n.º 13
0
        private static Canvas RenderLayerStatic(IReadOnlyViewport viewport, ILayer layer, SymbolCache symbolCache, bool rasterizing = false)
        {
            // todo:
            // find solution for try catch. Sometimes this method will throw an exception
            // when clearing and adding features to a layer while rendering
            var canvas = new Canvas
            {
                Opacity          = layer.Opacity,
                IsHitTestVisible = false
            };

            try
            {
                var features    = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution).ToList();
                var layerStyles = BaseLayer.GetLayerStyles(layer);

                // If rasterizing (which is usually on a background thread) create a new SymbolCache
                // just for this rendering because cross thread access is not allowed in WPF.

                if (rasterizing)
                {
                    symbolCache = new SymbolCache();
                }

                foreach (var layerStyle in layerStyles)
                {
                    var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                    foreach (var feature in features)
                    {
                        if (layerStyle is IThemeStyle)
                        {
                            style = (layerStyle as IThemeStyle).GetStyle(feature);
                        }
                        if (style == null ||
                            style.Enabled == false ||
                            style.MinVisible > viewport.Resolution ||
                            style.MaxVisible < viewport.Resolution)
                        {
                            continue;
                        }

                        RenderFeature(viewport, canvas, feature, style, symbolCache, rasterizing);
                    }
                }

                foreach (var feature in features)
                {
                    var styles = feature.Styles ?? Enumerable.Empty <IStyle>();
                    foreach (var style in styles)
                    {
                        if (feature.Styles != null && style.Enabled)
                        {
                            RenderFeature(viewport, canvas, feature, style, symbolCache, rasterizing);
                        }
                    }
                }

                return(canvas);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, "Unexpected error in xaml renderer", ex);
                return(canvas);
                // If exception happens inside RenderFeature function after
                // at -least one child has been added to the canvas,
                // returning new canvas will leave the previously created (but
                // not yet added to parent canvas) canvas abandoned, that will
                // cause the exception when resuing RenderedGeometry object, because
                // at -least one RenderedGeometry was attached to that abandoned canvas.
                // returning the same canvas will solve this error, as it will
                // be clear this canvas childs on next render call.
                // return new Canvas { IsHitTestVisible = false };
            }
        }
Ejemplo n.º 14
0
        private static Canvas RenderVectorLayer(IViewport viewport, ILayer layer, bool rasterizing = false)
        {
            // todo:
            // find solution for try catch. Sometimes this method will throw an exception
            // when clearing and adding features to a layer while rendering
            var canvas = new Canvas
            {
                Opacity = layer.Opacity,
                IsHitTestVisible = false
            };

            try
            {
                var features = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution).ToList();
                var layerStyles = BaseLayer.GetLayerStyles(layer);
                var brushCache = new BrushCache();

                foreach (var layerStyle in layerStyles)
                {
                    var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                    foreach (var feature in features)
                    {
                        if (layerStyle is IThemeStyle) style = (layerStyle as IThemeStyle).GetStyle(feature);
                        if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.Resolution) ||
                            (style.MaxVisible < viewport.Resolution)) continue;

                        RenderFeature(viewport, canvas, feature, style, rasterizing, brushCache);
                    }
                }

                foreach (var feature in features)
                {
                    var styles = feature.Styles ?? Enumerable.Empty<IStyle>();
                    foreach (var style in styles)
                        if ((feature.Styles != null) && style.Enabled)
                            RenderFeature(viewport, canvas, feature, style, rasterizing, brushCache);
                }

                return canvas;
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, "Unexpected error in renderer", ex);
                return canvas;
                // If exception happens inside RenderFeature function after
                // at -least one child has been added to the canvas,
                // returning new canvas will leave the previously created (but
                // not yet added to parent canvas) canvas abandoned, that will
                // cause the exception when resuing RenderedGeometry object, because
                // at -least one RenderedGeometry was attached to that abandoned canvas.
                // returning the same canvas will solve this error, as it will
                // be clear this canvas childs on next render call.
                // return new Canvas { IsHitTestVisible = false };
            }
        }
Ejemplo n.º 15
0
        private static void RenderLayer(Graphics graphics, IViewport viewport, ILayer layer, AbortRenderDelegate abortRender)
        {
            int counter = 0;
            const int step = 100;

            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;

            foreach (var layerStyle in layer.Styles)
            {
                var style = layerStyle;

                var features = layer.GetFeaturesInView(viewport.Extent, viewport.Resolution);

                //Linestring outlines is drawn by drawing the layer once with a thicker line
                //before drawing the "inline" on top.
                var enumerable = features as IList<IFeature> ?? features.ToList();
                foreach (var feature in enumerable)
                {
                    if ((counter++ % step == 0) && abortRender != null && abortRender()) return;
                    if (layerStyle is IThemeStyle) style = (layerStyle as IThemeStyle).GetStyle(feature);

                    if ((style is VectorStyle) && ((style as VectorStyle).Outline != null))
                    {
                        GdiGeometryRenderer.RenderGeometryOutline(graphics, viewport, feature.Geometry, style as VectorStyle);
                    }
                }

                foreach (var feature in enumerable)
                {
                    if ((counter++ % step == 0) && abortRender != null && abortRender()) return;
                    if (layerStyle is IThemeStyle) style = (layerStyle as IThemeStyle).GetStyle(feature);
                    RenderGeometry(graphics, viewport, feature.Geometry, style as VectorStyle);
                }
            }
        }
Ejemplo n.º 16
0
        private static Canvas RenderVectorLayer(IViewport viewport, ILayer layer, bool rasterizing = false)
        {
            // todo:
            // find solution for try catch. Sometimes this method will throw an exception
            // when clearing and adding features to a layer while rendering
            try
            {
                var canvas = new Canvas
                {
                    Opacity = layer.Opacity,
                    IsHitTestVisible = false
                };

                var features = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution).ToList();
                var layerStyles = BaseLayer.GetLayerStyles(layer);

                foreach (var layerStyle in layerStyles)
                {
                    var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                    foreach (var feature in features)
                    {
                        if (layerStyle is IThemeStyle) style = (layerStyle as IThemeStyle).GetStyle(feature);
                        if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.Resolution) || (style.MaxVisible < viewport.Resolution)) continue;

                        RenderFeature(viewport, canvas, feature, style, rasterizing);
                    }
                }

                foreach (var feature in features)
                {
                    var styles = feature.Styles ?? Enumerable.Empty<IStyle>();
                    foreach (var style in styles)
                    {
                        if (feature.Styles != null && style.Enabled)
                        {
                            RenderFeature(viewport, canvas, feature, style, rasterizing);
                        }
                    }
                }

                return canvas;
            }
            catch (Exception)
            {
                return new Canvas { IsHitTestVisible = false };
            }
        }
Ejemplo n.º 17
0
        private static void IterateVectorLayer(IViewport viewport, ILayer layer, StyleContext context,
                                               Action <IViewport, IStyle, IFeature, StyleContext> callback)
        {
            var features = layer.GetFeaturesInView(viewport.Extent, viewport.RenderResolution)
                           .Select((f, i) =>
            {
                ReleaseLoad(i);
                return(f);
            })
                           .Where(f =>
            {
                if (f.Geometry is Mapsui.Geometries.Point)
                {
                    return(true);
                }
                var boundingBox = f.Geometry.GetBoundingBox();
                return(boundingBox.Height / viewport.Resolution > 0.1 ||
                       boundingBox.Width / viewport.Resolution > 0.1);
            })
                           .ToList();

            var layerStyles = layer.Style is StyleCollection ? (layer.Style as StyleCollection).ToArray() : new[] { layer.Style };

            foreach (var layerStyle in layerStyles)
            {
                var style = layerStyle; // This is the default that could be overridden by an IThemeStyle

                if ((style == null) || (style.Enabled == false) || (style.MinVisible > viewport.RenderResolution) || (style.MaxVisible < viewport.RenderResolution))
                {
                    continue;
                }

                for (int i = 0; i < features.Count; i++)
                {
                    var feature = features[i];

                    if (layerStyle is IThemeStyle)
                    {
                        style = (layerStyle as IThemeStyle).GetStyle(feature);
                    }

                    callback(viewport, style, feature, context);

                    ReleaseLoad(i);
                }
            }

            for (int i = 0; i < features.Count; i++)
            {
                var feature = features[i];

                if (feature.Styles != null)
                {
                    foreach (var featureStyle in feature.Styles)
                    {
                        if (feature.Styles != null && featureStyle.Enabled)
                        {
                            callback(viewport, featureStyle, feature, context);
                        }
                    }
                }

                ReleaseLoad(i);
            }

            ReleaseLoad(0);
        }