internal MapPathSegment FilterSegment(MapPathSegment segment, IList <double> weights, double minSuitableWeight) { MapPathSegment filtedSegment = new MapPathSegment(); if (segment.Points.Count == 0) { return(filtedSegment); } filtedSegment.Points.Add(segment.Points[0]); if (segment.Points.Count == 1) { return(filtedSegment); } filtedSegment.Points.BeginUpdate(); try { for (int i = 1; i < segment.Points.Count - 1; ++i) { if (weights[i - 1] >= minSuitableWeight) { filtedSegment.Points.Add(segment.Points[i]); } } filtedSegment.Points.Add(segment.Points[segment.Points.Count - 1]); } finally { filtedSegment.Points.EndUpdate(); } return(filtedSegment); }
public static MapPathSegment CreateSegment(int pointsNumber) { MapPathSegment segment = new MapPathSegment(); for (int i = 0; i < pointsNumber; ++i) { segment.Points.Add(new GeoPoint(i, i)); } return(segment); }
IList <double> ProcessSegment(MapPathSegment segment) { IList <double> pointsWeight = new List <double>(); for (int i = 1; i < segment.Points.Count - 1; ++i) { pointsWeight.Add(this.weightedPoints[segment.Points[i]]); } return(pointsWeight); }
public void Filter() { IList <WeightedItem> weightedItems = new List <WeightedItem>(); IEnumerable <MapItem> actual = this.filter.Filter(weightedItems, new double[] { }, 100); ComparisonHelper.CheckTotalPointsCount(0, actual); MapPath mapPath1 = new MapPath(); MapPathSegment segment1 = MapUtils.CreateSegment(4); mapPath1.Segments.Add(segment1); IList <IList <double> > weights1 = new List <IList <double> > { new double[] { 1, 2 } }; weightedItems = new List <WeightedItem> { new WeightedItem(mapPath1, weights1) }; actual = this.filter.Filter(weightedItems, new double[] { 1, 2 }, 100); ComparisonHelper.CheckTotalPointsCount(4, actual); actual = this.filter.Filter(weightedItems, new double[] { 1, 2 }, 0); ComparisonHelper.CheckTotalPointsCount(2, actual); mapPath1.Segments.Add(segment1); weights1.Add(new double[] { 1, 2 }); actual = this.filter.Filter(weightedItems, new double[] { 1, 1, 2, 2 }, 49); ComparisonHelper.CheckTotalPointsCount(6, actual); MapPathSegment segment2 = MapUtils.CreateSegment(5); MapPath mapPath2 = new MapPath(); mapPath2.Segments.Add(segment2); IList <IList <double> > weights2 = new List <IList <double> > { new double[] { 1, 2, 3 } }; weightedItems.Add(new WeightedItem(mapPath2, weights2)); actual = this.filter.Filter(weightedItems, new double[] { 1, 1, 1, 2, 2, 2, 3 }, 50); ComparisonHelper.CheckTotalPointsCount(10, actual); }
public void Process() { List <MapItem> items = new List <MapItem>(); MapPath mapPath1 = new MapPath(); items.Add(mapPath1); MapPathSegment segment1 = MapUtils.CreateSegment(4); mapPath1.Segments.Add(segment1); this.calculator.Process(items); IList <IList <double> > weights1 = new List <IList <double> > { new double[] { 1, 2 } }; IList <WeightedItem> expectedWeightedItems = new List <WeightedItem> { new WeightedItem(mapPath1, weights1) }; Assert.AreEqual(new double[] { 1, 2 }, this.calculator.Weights); ComparisonHelper.AssertWeightedItems(expectedWeightedItems, this.calculator.WeightedItems); mapPath1.Segments.Add(segment1); this.calculator.Process(items); weights1.Add(new double[] { 1, 2 }); Assert.AreEqual(new double[] { 1, 2 }, this.calculator.Weights); ComparisonHelper.AssertWeightedItems(expectedWeightedItems, this.calculator.WeightedItems); MapPathSegment segment2 = MapUtils.CreateSegment(6); MapPath mapPath2 = new MapPath(); mapPath2.Segments.Add(segment2); items.Add(mapPath2); this.calculator.Process(items); IList <IList <double> > weights2 = new List <IList <double> >(); weights2.Add(new double[] { 1, 2, double.PositiveInfinity, 1 }); expectedWeightedItems.Add(new WeightedItem(mapPath2, weights2)); Assert.AreEqual(new double[] { 1, 1, 2 }, this.calculator.Weights); ComparisonHelper.AssertWeightedItems(expectedWeightedItems, this.calculator.WeightedItems); }
private void Form1_Load(object sender, System.EventArgs e) { #region #MapDotExample ItemStorage.Items.Add(new MapDot() { Location = new GeoPoint(-10, 10), Size = 18, Stroke = Color.Blue }); #endregion #MapDotExample #region #MapEllipseExample ItemStorage.Items.Add(new MapEllipse() { Location = new GeoPoint(40, 40), Height = 300, Width = 600 }); #endregion #MapEllipseExample #region #MapLineExample ItemStorage.Items.Add(new MapLine { Point1 = new GeoPoint(-30, 20), Point2 = new GeoPoint(-35, 25), Stroke = Color.Red, StrokeWidth = 4 }); #endregion #MapLineExample #region #MapCalloutExample ItemStorage.Items.Add(new MapCallout() { Location = new GeoPoint(10, 10), Text = "This is a MapCallout object" }); #endregion #MapCalloutExample #region #MapPathExample var path = new MapPath(); var segment = new MapPathSegment(); segment.Points.AddRange(new GeoPoint[] { new GeoPoint(20, 20), new GeoPoint(20, 30), new GeoPoint(30, 30) }); path.Segments.Add(segment); segment = new MapPathSegment(); segment.Points.AddRange(new GeoPoint[] { new GeoPoint(30, 32), new GeoPoint(20, 32), new GeoPoint(20, 42) }); path.Segments.Add(segment); ItemStorage.Items.Add(path); #endregion #MapPathExample #region #MapPolygonExample var polygon = new MapPolygon(); polygon.Points.AddRange(new GeoPoint[] { new GeoPoint(70, 80), new GeoPoint(75, 90), new GeoPoint(75, 130) }); ItemStorage.Items.Add(polygon); #endregion #MapPolygonExample #region #MapPolylineExample var polyline = new MapPolyline() { StrokeWidth = 4, Stroke = Color.Yellow }; polyline.Points.AddRange(new GeoPoint[] { new GeoPoint(-29, 130), new GeoPoint(-40, 140), new GeoPoint(-20, 150) }); ItemStorage.Items.Add(polyline); #endregion #MapPolylineExample #region #MapPushpinExample ItemStorage.Items.Add(new MapPushpin() { Location = new GeoPoint(70, -100), Text = "1" }); #endregion #MapPushpinExample #region #MapRectangleExample ItemStorage.Items.Add(new MapRectangle() { Location = new GeoPoint(-70, -100), Width = 500, Height = 750 }); #endregion #MapRectangleExample #region #MapCustomElementExample var customElement = new MapCustomElement() { Location = new GeoPoint(50, 50), Text = "This is a MapCustomElement object" }; var image = new Bitmap(imageFilePath); customElement.Image = new Bitmap(image, new Size(40, 40)); ItemStorage.Items.Add(customElement); #endregion #MapCustomElementExample #region #MapBubbleExample ItemStorage.Items.Add(new MapBubble() { Location = new GeoPoint(30, 20), Value = 400, Argument = "A", Size = 100 }); #endregion #MapBubbleExample #region #MapPieExample var pie = new MapPie() { Location = new GeoPoint(-20, -30), Size = 100 }; pie.Segments.AddRange(new PieSegment[] { new PieSegment() { Argument = "A", Value = 2 }, new PieSegment() { Argument = "B", Value = 3 }, new PieSegment() { Argument = "C", Value = 4 } }); ItemStorage.Items.Add(pie); #endregion #MapPieExample }