private void RenderInternal(D2D1.Factory factory, D2D1.RenderTarget rt, Map map, Envelope envelope) { //if style is not enabled, we don't need to render anything if (!Style.Enabled) { return; } var geoms = GetGeometriesInView(envelope); if (geoms.Count == 0) { return; } var stylesToRender = GetStylesToRender(Style); foreach (var style in stylesToRender) { if (style is VectorStyle) { using (var tmp = SharpDXVectorStyle.FromVectorStyle(rt, factory, (VectorStyle)style)) { //Linestring outlines is drawn by drawing the layer once with a thicker line //before drawing the "inline" on top. if (tmp.EnableOutline) { foreach (var geom in geoms) { if (geom != null) { //Draw background of all line-outlines first if (geom is ILineString) { SharpDXVectorRenderer.DrawLineString(rt, factory, geom as ILineString, tmp.Outline, tmp.OutlineWidth, tmp.OutlineStrokeStyle, map, tmp.LineOffset); } else if (geom is IMultiLineString) { SharpDXVectorRenderer.DrawMultiLineString(rt, factory, geom as IMultiLineString, tmp.Outline, tmp.OutlineWidth, tmp.OutlineStrokeStyle, map, tmp.LineOffset); } } } } foreach (IGeometry geom in geoms) { if (geom != null) { RenderGeometry(factory, rt, map, geom, tmp); } } } } else { lock (_syncRoot) _logger.Debug(fmh => fmh("Not a VectorStyle!")); } } }
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(); } } }