private void RenderInternal(D2D1.Factory factory, D2D1.RenderTarget rt, Map map, Envelope envelope, Rendering.Thematics.ITheme theme) { var ds = new FeatureDataSet(); lock (_syncRoot) { DataSource.Open(); DataSource.ExecuteIntersectionQuery(envelope, ds); DataSource.Close(); } var scale = map.MapScale; var zoom = map.Zoom; foreach (FeatureDataTable features in ds.Tables) { // Transform geometries if necessary if (CoordinateTransformation != null) { for (var i = 0; i < features.Count; i++) { features[i].Geometry = ToTarget(features[i].Geometry); } } //Linestring outlines is drawn by drawing the layer once with a thicker line //before drawing the "inline" on top. if (Style.EnableOutline) { for (int i = 0; i < features.Count; i++) { var feature = features[i]; var outlineStyle = theme.GetStyle(feature) as VectorStyle; if (outlineStyle == null) continue; if (!(outlineStyle.Enabled && outlineStyle.EnableOutline)) continue; double compare = outlineStyle.VisibilityUnits == VisibilityUnits.ZoomLevel ? zoom : scale; if (!(outlineStyle.MinVisible <= compare && compare <= outlineStyle.MaxVisible)) continue; using (var sdxStyle = SharpDXVectorStyle.FromVectorStyle(rt, factory, outlineStyle)) { if (sdxStyle != null) { //Draw background of all line-outlines first if (feature.Geometry is ILineString) { SharpDXVectorRenderer.DrawLineString(rt, factory, (ILineString)feature.Geometry, sdxStyle.Outline, sdxStyle.OutlineWidth, sdxStyle.OutlineStrokeStyle, map, sdxStyle.LineOffset); } else if (feature.Geometry is IMultiLineString) { SharpDXVectorRenderer.DrawMultiLineString(rt, factory, (IMultiLineString)feature.Geometry, sdxStyle.Outline, sdxStyle.OutlineWidth, sdxStyle.OutlineStrokeStyle, map, sdxStyle.LineOffset); } } } } } var sdxVectorStyles = new Dictionary<VectorStyle, SharpDXVectorStyle>(); for (var i = 0; i < features.Count; i++) { var feature = features[i]; var style = theme.GetStyle(feature); if (style == null) continue; if (!style.Enabled) continue; var compare = style.VisibilityUnits == VisibilityUnits.ZoomLevel ? zoom : scale; if (!(style.MinVisible <= compare && compare <= style.MaxVisible)) continue; IEnumerable<IStyle> stylesToRender = GetStylesToRender(style); if (stylesToRender == null) return; foreach (var styleToRender in stylesToRender) { if (!styleToRender.Enabled) continue; if (!(styleToRender is VectorStyle)) continue; if (!(style.MinVisible <= compare && compare <= style.MaxVisible)) continue; var vstyle = (VectorStyle) styleToRender; SharpDXVectorStyle sdxStyle; if (!sdxVectorStyles.TryGetValue(vstyle, out sdxStyle)) { sdxStyle = SharpDXVectorStyle.FromVectorStyle(rt, factory, vstyle); sdxVectorStyles.Add(vstyle, sdxStyle); } RenderGeometry(factory, rt, map, feature.Geometry, sdxStyle); } } foreach (var value in sdxVectorStyles.Values) value.Dispose(); } }