private void BuildPaths(MapArgs e, IEnumerable <IFeature> features, out List <GraphicsPath> borderPaths) { borderPaths = new List <GraphicsPath>(); Rectangle clipRect = ComputeClippingRectangle(e); Extent drawExtents = e.PixelToProj(clipRect); SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect); for (int selectState = 0; selectState < 2; selectState++) { foreach (IPolygonCategory category in Symbology.Categories) { // Determine the subset of the specified features that are visible and match the category IPolygonCategory polygonCategory = category; int i = selectState; Func <IDrawnState, bool> isMember = state => state.SchemeCategory == polygonCategory && state.IsVisible && state.IsSelected == (i == 1); var drawnFeatures = from feature in features where isMember(DrawingFilter[feature]) select feature; GraphicsPath borderPath = new GraphicsPath(); foreach (IFeature f in drawnFeatures) { BuildPolygon(DataSet.Vertex, f.ShapeIndex, borderPath, e, drawExtents.Contains(f.Envelope) ? null : shClip); } borderPaths.Add(borderPath); } } }
private void BuildPaths(MapArgs e, IEnumerable <IFeature> features, out Dictionary <FastDrawnState, GraphicsPath> borderPaths, bool selected) { borderPaths = new Dictionary <FastDrawnState, GraphicsPath>(); if (selected && !DrawingFilter.DrawnStates.Any(_ => _.Value.IsSelected)) { return; } Rectangle clipRect = ComputeClippingRectangle(e); Extent drawExtents = e.PixelToProj(clipRect); SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect); var featureList = features as IList <IFeature> ?? features.ToList(); foreach (var category in Symbology.Categories) { // Determine the subset of the specified features that are visible and match the category IFeatureCategory polygonCategory = category; Func <IDrawnState, bool> isMember; if (selected) { // get only selected features isMember = state => state.SchemeCategory == polygonCategory && state.IsVisible && state.IsSelected; } else { // get all features isMember = state => state.SchemeCategory == polygonCategory && state.IsVisible; } var drawnFeatures = (from feature in featureList where isMember(DrawingFilter[feature]) select feature).ToList(); if (drawnFeatures.Count > 0) { GraphicsPath borderPath = new GraphicsPath(); foreach (IFeature f in drawnFeatures) { BuildPolygon(DataSet.Vertex, f.ShapeIndex, borderPath, e, drawExtents.Contains(f.Geometry.EnvelopeInternal) ? null : shClip); } borderPaths.Add(new FastDrawnState(selected, category), borderPath); } } }
private void BuildPaths(MapArgs e, IEnumerable <int> indices, out List <GraphicsPath> paths) { DateTime startTime = DateTime.Now; paths = new List <GraphicsPath>(); Rectangle clipRect = ComputeClippingRectangle(e); Extent drawExtents = e.PixelToProj(clipRect); SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect); List <GraphicsPath> graphPaths = new List <GraphicsPath>(); Dictionary <FastDrawnState, GraphicsPath> borders = new Dictionary <FastDrawnState, GraphicsPath>(); for (int selectState = 0; selectState < 2; selectState++) { foreach (IPolygonCategory category in Symbology.Categories) { FastDrawnState state = new FastDrawnState(selectState == 1, category); GraphicsPath border = new GraphicsPath(); borders.Add(state, border); graphPaths.Add(border); } } paths.AddRange(graphPaths); List <ShapeRange> shapes = DataSet.ShapeIndices; double[] vertices = DataSet.Vertex; if (ProgressReportingEnabled) { ProgressMeter = new ProgressMeter(ProgressHandler, "Building Paths", indices.Count()); } if (!DrawnStatesNeeded) { FastDrawnState state = new FastDrawnState(false, Symbology.Categories[0]); foreach (int shp in indices) { if (ProgressReportingEnabled) { ProgressMeter.Next(); } ShapeRange shape = shapes[shp]; if (!shape.Extent.Intersects(e.GeographicExtents)) { return; } if (shp >= shapes.Count) { return; } if (!borders.ContainsKey(state)) { return; } BuildPolygon(vertices, shapes[shp], borders[state], e, drawExtents.Contains(shape.Extent) ? null : shClip); } } else { FastDrawnState[] states = DrawnStates; foreach (GraphicsPath borderPath in borders.Values) { if (borderPath != null) { borderPath.FillMode = FillMode.Winding; } } foreach (int shp in indices) { if (ProgressReportingEnabled) { ProgressMeter.Next(); } if (shp >= shapes.Count) { return; } if (shp >= states.Length) { AssignFastDrawnStates(); states = DrawnStates; } if (states[shp].Visible == false) { continue; } ShapeRange shape = shapes[shp]; if (!shape.Extent.Intersects(e.GeographicExtents)) { return; } if (drawExtents.Contains(shape.Extent)) { FastDrawnState state = states[shp]; if (!borders.ContainsKey(state)) { return; } BuildPolygon(vertices, shapes[shp], borders[state], e, null); } else { FastDrawnState state = states[shp]; if (!borders.ContainsKey(state)) { return; } BuildPolygon(vertices, shapes[shp], borders[state], e, shClip); } } } if (ProgressReportingEnabled) { ProgressMeter.Reset(); } TimeSpan interval = DateTime.Now - startTime; totalTime += interval.TotalMilliseconds; //Console.WriteLine("Total milliseconds: " + totalTime.ToString()); }
private void BuildPaths(MapArgs e, IEnumerable<IFeature> features, out List<GraphicsPath> borderPaths) { borderPaths = new List<GraphicsPath>(); Rectangle clipRect = ComputeClippingRectangle(e); Extent drawExtents = e.PixelToProj(clipRect); SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect); for (int selectState = 0; selectState < 2; selectState++) { foreach (IPolygonCategory category in Symbology.Categories) { // Determine the subset of the specified features that are visible and match the category IPolygonCategory polygonCategory = category; int i = selectState; Func<IDrawnState, bool> isMember = state => state.SchemeCategory == polygonCategory && state.IsVisible && state.IsSelected == (i == 1); var drawnFeatures = from feature in features where isMember(DrawingFilter[feature]) select feature; GraphicsPath borderPath = new GraphicsPath(); foreach (IFeature f in drawnFeatures) { BuildPolygon(DataSet.Vertex, f.ShapeIndex, borderPath, e, drawExtents.Contains(f.Envelope) ? null : shClip); } borderPaths.Add(borderPath); } } }
private void BuildPaths(MapArgs e, IEnumerable<int> indices, out List<GraphicsPath> paths) { DateTime startTime = DateTime.Now; paths = new List<GraphicsPath>(); Rectangle clipRect = ComputeClippingRectangle(e); Extent drawExtents = e.PixelToProj(clipRect); SoutherlandHodgman shClip = new SoutherlandHodgman(clipRect); List<GraphicsPath> graphPaths = new List<GraphicsPath>(); Dictionary<FastDrawnState, GraphicsPath> borders = new Dictionary<FastDrawnState, GraphicsPath>(); for (int selectState = 0; selectState < 2; selectState++) { foreach (IPolygonCategory category in Symbology.Categories) { FastDrawnState state = new FastDrawnState(selectState == 1, category); GraphicsPath border = new GraphicsPath(); borders.Add(state, border); graphPaths.Add(border); } } paths.AddRange(graphPaths); List<ShapeRange> shapes = DataSet.ShapeIndices; double[] vertices = DataSet.Vertex; if (ProgressReportingEnabled) { ProgressMeter = new ProgressMeter(ProgressHandler, "Building Paths", indices.Count()); } if (!DrawnStatesNeeded) { FastDrawnState state = new FastDrawnState(false, Symbology.Categories[0]); foreach (int shp in indices) { if (ProgressReportingEnabled) ProgressMeter.Next(); ShapeRange shape = shapes[shp]; if (!shape.Extent.Intersects(e.GeographicExtents)) return; if (shp >= shapes.Count) return; if (!borders.ContainsKey(state)) return; BuildPolygon(vertices, shapes[shp], borders[state], e, drawExtents.Contains(shape.Extent) ? null : shClip); } } else { FastDrawnState[] states = DrawnStates; foreach (GraphicsPath borderPath in borders.Values) { if (borderPath != null) { borderPath.FillMode = FillMode.Winding; } } foreach (int shp in indices) { if (ProgressReportingEnabled) ProgressMeter.Next(); if (shp >= shapes.Count) return; if (shp >= states.Length) { AssignFastDrawnStates(); states = DrawnStates; } if (states[shp].Visible == false) continue; ShapeRange shape = shapes[shp]; if (!shape.Extent.Intersects(e.GeographicExtents)) return; if (drawExtents.Contains(shape.Extent)) { FastDrawnState state = states[shp]; if (!borders.ContainsKey(state)) return; BuildPolygon(vertices, shapes[shp], borders[state], e, null); } else { FastDrawnState state = states[shp]; if (!borders.ContainsKey(state)) return; BuildPolygon(vertices, shapes[shp], borders[state], e, shClip); } } } if (ProgressReportingEnabled) ProgressMeter.Reset(); TimeSpan interval = DateTime.Now - startTime; totalTime += interval.TotalMilliseconds; //Console.WriteLine("Total milliseconds: " + totalTime.ToString()); }
private void BuildPaths(MapArgs e, IEnumerable<int> indices, out List<GraphicsPath> paths) { paths = new List<GraphicsPath>(); var clipRect = ComputeClippingRectangle(e); var drawExtents = e.PixelToProj(clipRect); var shClip = new SoutherlandHodgman(clipRect); var graphPaths = new List<GraphicsPath>(); var borders = new Dictionary<FastDrawnState, GraphicsPath>(); for (var selectState = 0; selectState < 2; selectState++) { foreach (var category in Symbology.Categories) { var state = new FastDrawnState(selectState == 1, category); var border = new GraphicsPath {FillMode = FillMode.Winding}; borders.Add(state, border); graphPaths.Add(border); } } paths.AddRange(graphPaths); var states = DrawnStates; foreach (var shp in indices) { var state = states[shp]; if (!state.Visible) continue; if (!borders.ContainsKey(state)) continue; var shape = DataSet.GetShape(shp, false); if (!shape.Range.Extent.Intersects(e.GeographicExtents)) continue; BuildPolygon(shape.Range, borders[state], e, drawExtents.Contains(shape.Range.Extent) ? null : shClip); } }