public void CanGetMonotonicityTypeEmpty() { ISegment segmentNaNFirst = new LineClass { FromPoint = CreatePoint(0, 0, double.NaN), ToPoint = CreatePoint(0, 1, 0) }; ISegment segmentNaNSecond = new LineClass { FromPoint = CreatePoint(0, 0, 99999.88), ToPoint = CreatePoint(0, 1, double.NaN) }; ISegment segmentNaNBoth = new LineClass { FromPoint = CreatePoint(0, 0, double.NaN), ToPoint = CreatePoint(0, 1, double.NaN) }; Assert.IsTrue(MeasureUtils.GetMonotonicityType(segmentNaNFirst) == esriMonotinicityEnum.esriValuesEmpty); Assert.IsTrue(MeasureUtils.GetMonotonicityType(segmentNaNSecond) == esriMonotinicityEnum.esriValuesEmpty); Assert.IsTrue(MeasureUtils.GetMonotonicityType(segmentNaNBoth) == esriMonotinicityEnum.esriValuesEmpty); }
public void CanGetErrorSequences3() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, 0)) .LineTo(CreatePoint(1, 0, 1)) // + .LineTo(CreatePoint(1, 0, double.NaN)) .LineTo(CreatePoint(2, 0, 2)) // = .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); IEnumerable <MMonotonicitySequence> result; MMonotonicitySequence[] sequences; result = MeasureUtils.GetErrorSequences(polyline, MonotonicityDirection.Increasing, () => false, true); Assert.AreEqual(0, result.Count()); result = MeasureUtils.GetErrorSequences(polyline, MonotonicityDirection.Decreasing, () => false, true); sequences = result.ToArray(); Assert.AreEqual(1, result.Count()); Assert.AreEqual(1, sequences[0].Segments.Count); }
public void CanGetMonotonicitySequencesEmpty() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, 100)) .LineTo(CreatePoint(50, 0, double.NaN)) .LineTo(CreatePoint(100, 0, 100)) .LineTo(CreatePoint(50, 0, double.NaN)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); IEnumerable <MMonotonicitySequence> result = MeasureUtils.GetMonotonicitySequences((ISegmentCollection)polyline, esriMonotinicityEnum.esriValuesEmpty); Assert.IsTrue(1 == result.Count()); MMonotonicitySequence[] sequences = result.ToArray(); Assert.IsTrue(sequences[0].MonotonicityType == esriMonotinicityEnum.esriValuesEmpty); Assert.IsTrue(sequences[0].Segments.Count == 3); Assert.IsTrue(sequences[0].Segments[0].FromPoint.M == 100); Assert.IsTrue(double.IsNaN(sequences[0].Segments[0].ToPoint.M)); Assert.IsTrue(double.IsNaN(sequences[0].Segments[1].FromPoint.M)); Assert.IsTrue(sequences[0].Segments[1].ToPoint.M == 100); Assert.IsTrue(sequences[0].Segments[2].FromPoint.M == 100); Assert.IsTrue(double.IsNaN(sequences[0].Segments[2].ToPoint.M)); }
public void CanGetMonotonicityTypeLevel() { ISegment segment = new LineClass { FromPoint = CreatePoint(0, 0, 0), ToPoint = CreatePoint(0, 1, 0) }; Assert.IsTrue(MeasureUtils.GetMonotonicityType(segment) == esriMonotinicityEnum.esriValueLevel); }
public Solution Measure(Solution solution) { MeasureUtils.File = _fileManagerService; Parallel.ForEach(solution.Projects, (project) => { Parallel.ForEach(project.Files, (programmingFile) => { programmingFile.LOC = MeasureUtils.CalculateLOC(programmingFile); }); }); return(solution); }
private void MeasureSolution(Solution solution) { IsBusy = true; _currentSolution = _measureService.Measure(solution); Stats = MeasureUtils.CalculateStats(_currentSolution); CreateAndroidPlot(Stats); CreateIOSPlot(Stats); IsBusy = false; _fileDialogService.CreateDialog(EnumTypeDialog.Information , "Consider sharing your applications stats clicking on bottom left link and filling the form\nData collected this way will be public accessible by the community" , "Sharing"); }
public void CanGetMonotonicityTrendDecreasing1() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, -0.00001)) .LineTo(CreatePoint(4, 0, -0.1)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); esriMonotinicityEnum result = MeasureUtils.GetMonotonicityTrend(polyline); Assert.AreEqual(esriMonotinicityEnum.esriValueDecreases, result); }
public void CanGetMonotonicityTrendEmpty() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, double.NaN)) .LineTo(CreatePoint(50, 0, double.NaN)) .LineTo(CreatePoint(150, 0, double.NaN)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); esriMonotinicityEnum result = MeasureUtils.GetMonotonicityTrend(polyline); Assert.AreEqual(esriMonotinicityEnum.esriValuesEmpty, result); }
public void CanGetMonotonicityTrendLevelSymmetric() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, 0)) .LineTo(CreatePoint(1, 0, 1)) .LineTo(CreatePoint(2, 0, 2)) .LineTo(CreatePoint(3, 0, 1)) .LineTo(CreatePoint(4, 0, 0)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); esriMonotinicityEnum result = MeasureUtils.GetMonotonicityTrend(polyline); Assert.AreEqual(esriMonotinicityEnum.esriValueLevel, result); }
public void CanGetSubcurveWithNaNRange() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, 100)) .LineTo(CreatePoint(100, 0, 200)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); IList <IPoint> points; IPolyline subcurves = MeasureUtils.GetSubcurves(polyline, 150, double.NaN, out points); Console.WriteLine(GeometryUtils.ToString(subcurves)); Assert.IsNull(subcurves); Assert.AreEqual(1, points.Count); }
public void CanGetLinearSubcurveLargerThanTolerance() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, 100)) .LineTo(CreatePoint(100, 0, 200)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); IList <IPoint> points; IPolyline subcurves = MeasureUtils.GetSubcurves(polyline, 150, 150 + (_mTolerance * 2), out points); Console.WriteLine(GeometryUtils.ToString(subcurves)); Assert.IsNotNull(subcurves); Assert.AreEqual(0.020000000000010232, subcurves.Length); Assert.AreEqual(0, points.Count); }
public void CanGetMonotonicitySequencesDecreasing2() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, -100)) .LineTo(CreatePoint(1, 0, -200)) .LineTo(CreatePoint(2, 0, -300)) .LineTo(CreatePoint(3, 0, -400)) .LineTo(CreatePoint(4, 0, -300)) .LineTo(CreatePoint(5, 0, -200)) .LineTo(CreatePoint(6, 0, -300)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); IEnumerable <MMonotonicitySequence> result = MeasureUtils.GetMonotonicitySequences((ISegmentCollection)polyline, esriMonotinicityEnum.esriValueDecreases); Assert.IsTrue(2 == result.Count()); MMonotonicitySequence[] sequences = result.ToArray(); Assert.IsTrue(sequences[0].MonotonicityType == esriMonotinicityEnum.esriValueDecreases); Assert.IsTrue(sequences[0].Segments.Count == 3); Assert.IsTrue(sequences[0].Segments[0].FromPoint.M == -100); Assert.IsTrue(sequences[0].Segments[0].ToPoint.M == -200); Assert.IsTrue(sequences[0].Segments[1].FromPoint.M == -200); Assert.IsTrue(sequences[0].Segments[1].ToPoint.M == -300); Assert.IsTrue(sequences[0].Segments[2].FromPoint.M == -300); Assert.IsTrue(sequences[0].Segments[2].ToPoint.M == -400); Assert.IsTrue(sequences[1].MonotonicityType == esriMonotinicityEnum.esriValueDecreases); Assert.IsTrue(sequences[1].Segments.Count == 1); Assert.IsTrue(sequences[1].Segments[0].FromPoint.M == -200); Assert.IsTrue(sequences[1].Segments[0].ToPoint.M == -300); }
public void CanGetOvershootingLinearSubcurveSmallerThanTolerance() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, 100)) .LineTo(CreatePoint(100, 0, 200)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); IList <IPoint> points; IPolyline subcurves = MeasureUtils.GetSubcurves(polyline, 200, 300, out points); Console.WriteLine(GeometryUtils.ToString(subcurves)); Assert.IsNull(subcurves); Assert.AreEqual(1, points.Count); Assert.AreEqual(100, points[0].X); Assert.AreEqual(0, points[0].Y); }
private void btn_Run_Click(object sender, EventArgs e) { int targetStudentIndex = cbx_TargetStudent.SelectedIndex; if (targetStudentIndex == -1) { MessageBox.Show("未选择目标同学", "无法计算最邻近同学", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } IPoint pPoint = MeasureUtils.GetNearestStudent(m_pPointList, targetStudentIndex); if (pPoint != null) { IFeature pFeature = m_pFeatureLayer.FeatureClass.GetFeature(pPoint.ID); tbx_NearlyStudent.Text = pFeature.get_Value(pFeature.Fields.FindField("SNAME")).ToString(); IPoint pTargetPoint = m_pPointList[targetStudentIndex]; double distance = MeasureUtils.GetDistance(pPoint, pTargetPoint); tbx_NearlyDistance.Text = Math.Round(distance / 1000, 3) + " km"; ShowResultInMap(pTargetPoint, pPoint); } }
public void CanGetAllMonotonicityTypes() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, 100)) .LineTo(CreatePoint(50, 0, 200)) .LineTo(CreatePoint(100, 0, 100)) .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); Assert.IsTrue(MeasureUtils.ContainsAllMonotonicityTypes( polyline, esriMonotinicityEnum.esriValueIncreases)); Assert.IsTrue(MeasureUtils.ContainsAllMonotonicityTypes( polyline, esriMonotinicityEnum.esriValueIncreases, esriMonotinicityEnum.esriValueDecreases)); Assert.IsFalse(MeasureUtils.ContainsAllMonotonicityTypes( polyline, esriMonotinicityEnum.esriValueIncreases, esriMonotinicityEnum.esriValueLevel)); }
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec) { long code = ComputeInfoCode((long)widthMeasureSpec + heightMeasureSpec); if (code == viewInfoCode) { SetMeasuredDimension(MeasuredWidth, MeasuredHeight); return; } viewInfoCode = code; int paddingWidth = PaddingLeft + PaddingRight; int paddingHeight = PaddingTop + PaddingBottom; int smsw = MeasureUtils.MakeSelfMeasureSpec(widthMeasureSpec, paddingWidth); int smsh = MeasureUtils.MakeSelfMeasureSpec(heightMeasureSpec, paddingHeight); int smswnp = MeasureUtils.MakeSelfMeasureSpec(widthMeasureSpec, 0); int smshnp = MeasureUtils.MakeSelfMeasureSpec(heightMeasureSpec, 0); int contentWidth = 0; int contentHeight = 0; for (int i = 0; i < ChildCount; i++) { View child = GetChildAt(i); if (child.Visibility == ViewStates.Gone) { continue; } ViewLayoutParams lp = (ViewLayoutParams)child.LayoutParameters; int marginWidth = lp.LeftMargin + lp.RightMargin; int marginHeight = lp.TopMargin + lp.BottomMargin; int cmsw, cmsh; switch (lp.Layer) { case ViewLayoutParams.LAYER_LEFT: case ViewLayoutParams.LAYER_RIGHT: case ViewLayoutParams.LAYER_TOP: case ViewLayoutParams.LAYER_BOTTOM: cmsw = MeasureUtils.MakeChildMeasureSpec(smswnp, lp.Width, marginWidth); cmsh = MeasureUtils.MakeChildMeasureSpec(smshnp, lp.Height, marginHeight); break; default: cmsw = MeasureUtils.MakeChildMeasureSpec(smsw, lp.Width, marginWidth); cmsh = MeasureUtils.MakeChildMeasureSpec(smsh, lp.Height, marginHeight); break; } child.Measure(cmsw, cmsh); int cw = marginWidth + child.MeasuredWidth; int ch = marginHeight + child.MeasuredHeight; if (cw > contentWidth) { contentWidth = cw; } if (ch > contentHeight) { contentHeight = ch; } } contentWidth += paddingWidth; contentHeight += paddingHeight; int width = MeasureUtils.GetMeasuredDimension(contentWidth, widthMeasureSpec); int height = MeasureUtils.GetMeasuredDimension(contentHeight, heightMeasureSpec); SetMeasuredDimension(width, height); EdgeSize.SetEmpty(); CenterRect.Left = PaddingLeft; CenterRect.Top = PaddingTop; int centerWidth = Math.Max(MeasuredWidth - PaddingLeft - PaddingRight, 0); int centerHeight = Math.Max(MeasuredHeight - PaddingTop - PaddingBottom, 0); CenterRect.Right = CenterRect.Left + centerWidth; CenterRect.Bottom = CenterRect.Top + centerHeight; for (int i = 0; i < ChildCount; i++) { View child = GetChildAt(i); if (child.Visibility == ViewStates.Gone) { continue; } ViewLayoutParams lp = (ViewLayoutParams)child.LayoutParameters; int widthSpace = child.MeasuredWidth + lp.LeftMargin + lp.RightMargin; int heightSpace = child.MeasuredHeight + lp.TopMargin + lp.BottomMargin; switch (lp.Layer) { case ViewLayoutParams.LAYER_LEFT: if (widthSpace > EdgeSize.Left) { EdgeSize.Left = widthSpace; } break; case ViewLayoutParams.LAYER_TOP: if (heightSpace > EdgeSize.Top) { EdgeSize.Top = heightSpace; } break; case ViewLayoutParams.LAYER_RIGHT: if (widthSpace > EdgeSize.Right) { EdgeSize.Right = widthSpace; } break; case ViewLayoutParams.LAYER_BOTTOM: if (heightSpace > EdgeSize.Bottom) { EdgeSize.Bottom = heightSpace; } break; case ViewLayoutParams.LAYER_NONE: case ViewLayoutParams.LAYER_CENTER: default: break; } } }
public void CanGetErrorSequences() { var polyline = (IPolyline)CurveConstruction.StartLine(CreatePoint(0, 0, 0)) .LineTo(CreatePoint(1, 0, 1)) // + .LineTo(CreatePoint(1, 0, 2)) // + .LineTo(CreatePoint(2, 0, 3)) // + .LineTo(CreatePoint(3, 0, 3)) // = .LineTo(CreatePoint(4, 0, 3)) // = .LineTo(CreatePoint(5, 0, 1)) // - .LineTo(CreatePoint(6, 0, 0)) // - .LineTo(CreatePoint(7, 0, 9)) // + .LineTo(CreatePoint(8, 0, 4)) // - .Curve; polyline.SpatialReference = CreateSpatialReference(_mTolerance, _xyTolerance); GeometryUtils.MakeMAware(polyline); IEnumerable <MMonotonicitySequence> result; MMonotonicitySequence[] sequences; result = MeasureUtils.GetErrorSequences(polyline, MonotonicityDirection.Increasing, () => false, true); sequences = result.ToArray(); Assert.AreEqual(result.Count(), 2); Assert.AreEqual(sequences[0].Segments.Count, 2); Assert.AreEqual(sequences[1].Segments.Count, 1); result = MeasureUtils.GetErrorSequences(polyline, MonotonicityDirection.Increasing, () => false, false); sequences = result.ToArray(); Assert.AreEqual(result.Count(), 3); Assert.AreEqual(sequences[0].Segments.Count, 2); Assert.AreEqual(sequences[1].Segments.Count, 2); Assert.AreEqual(sequences[2].Segments.Count, 1); result = MeasureUtils.GetErrorSequences(polyline, MonotonicityDirection.Increasing, () => true, true); sequences = result.ToArray(); Assert.AreEqual(result.Count(), 2); Assert.AreEqual(sequences[0].Segments.Count, 3); Assert.AreEqual(sequences[1].Segments.Count, 1); result = MeasureUtils.GetErrorSequences(polyline, MonotonicityDirection.Any, () => false, true); sequences = result.ToArray(); Assert.AreEqual(result.Count(), 2); Assert.AreEqual(sequences[0].Segments.Count, 2); Assert.AreEqual(sequences[1].Segments.Count, 1); result = MeasureUtils.GetErrorSequences(polyline, MonotonicityDirection.Any, () => false, false); sequences = result.ToArray(); Assert.AreEqual(result.Count(), 3); Assert.AreEqual(sequences[0].Segments.Count, 2); Assert.AreEqual(sequences[1].Segments.Count, 2); Assert.AreEqual(sequences[2].Segments.Count, 1); }