public void CanUseFlipExpression() { IFeatureClass featureClass = CreateLineClass(TestWorkspace); IFeature row1 = featureClass.CreateFeature(); row1.Shape = CurveConstruction.StartLine(0, 0, 5).LineTo(1, 0, 6).Curve; row1.set_Value(row1.Fields.FindField(_flipFieldName), 1); row1.Store(); IFeature row2 = featureClass.CreateFeature(); row2.Shape = CurveConstruction.StartLine(0, 0, 5).LineTo(1, 0, 6).Curve; row2.set_Value(row2.Fields.FindField(_flipFieldName), -1); row2.Store(); IFeature row3 = featureClass.CreateFeature(); row3.Shape = CurveConstruction.StartLine(0, 0, 6).LineTo(1, 0, 5).Curve; row3.Store(); var test = new QaMonotonicZ(featureClass) { AllowConstantValues = false, ExpectedMonotonicity = MonotonicityDirection.Decreasing, FlipExpression = string.Format("{0} > 0", _flipFieldName) }; var runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); }
public void MultipartTest() { IFeatureWorkspace workspace = TestWorkspaceUtils.CreateInMemoryWorkspace("MultipartTest"); IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, CreateLV95(), 1000)); IFeatureClass linesFc = DatasetUtils.CreateSimpleFeatureClass(workspace, "Flow", fields); AddFeature( linesFc, CurveConstruction.StartLine(0, 0).LineTo(4, 0).MoveTo(6, 0).LineTo(6, 10).Curve); AddFeature(linesFc, CurveConstruction.StartLine(4, 0).LineTo(6, 0).Curve); AddFeature(linesFc, CurveConstruction.StartLine(0, 20).LineTo(4, 20).Curve); AddFeature( linesFc, CurveConstruction.StartLine(0, 30).LineTo(4, 30).MoveTo(0, 32).LineTo(4, 30) .MoveTo(4, 30).LineTo(8, 30).Curve); // expect counter-clockwise: 0 errors var runner = new QaContainerTestRunner( 1000, new QaFlowLogic(linesFc)); Assert.AreEqual(3, runner.Execute()); }
public void CanGetOrientationsForLinearTopologicalLines() { var polyline = (IPolyline)CurveConstruction.StartLine(10, 0) .LineTo(15, 5) .Curve; polyline.SpatialReference = CreateSpatialReference(); TopologicalLine topologicalLine = CreateTopologicalLine(polyline); Assert.AreEqual(2, topologicalLine.Orientation); polyline = (IPolyline)CurveConstruction.StartLine(15, 5) .LineTo(10, 0) .Curve; polyline.SpatialReference = CreateSpatialReference(); topologicalLine = CreateTopologicalLine(polyline); Assert.AreEqual(-2, topologicalLine.Orientation); polyline = (IPolyline)CurveConstruction.StartLine(10, 0) .LineTo(15, 5) .LineTo(10, 10) .Curve; polyline.SpatialReference = CreateSpatialReference(); topologicalLine = CreateTopologicalLine(polyline); Assert.AreEqual(-1, topologicalLine.Orientation); polyline = (IPolyline)CurveConstruction.StartLine(10, 10) .LineTo(15, 5) .LineTo(10, 0) .Curve; polyline.SpatialReference = CreateSpatialReference(); topologicalLine = CreateTopologicalLine(polyline); Assert.AreEqual(1, topologicalLine.Orientation); }
public void CanGetOrientationsForLinearLines() { double yMax; const double resol = 0.0001; var polyline = (IPolyline)CurveConstruction.StartLine(10, 0) .LineTo(15, 5) .Curve; Assert.AreEqual(2, TopologicalLineUtils.CalculateOrientation(polyline, resol, out yMax)); polyline = (IPolyline)CurveConstruction.StartLine(15, 5) .LineTo(10, 0) .Curve; Assert.AreEqual(-2, TopologicalLineUtils.CalculateOrientation(polyline, resol, out yMax)); polyline = (IPolyline)CurveConstruction.StartLine(10, 0) .LineTo(15, 5) .LineTo(10, 10) .Curve; Assert.AreEqual(-1, TopologicalLineUtils.CalculateOrientation( polyline, resol, out yMax)); polyline = (IPolyline)CurveConstruction.StartLine(10, 10) .LineTo(15, 5) .LineTo(10, 0) .Curve; Assert.AreEqual(1, TopologicalLineUtils.CalculateOrientation( polyline, resol, out yMax)); }
public void CanAllowSingleConnectedLineShorterThanNearDistance() { const string testName = "CanAllowSingleConnectedLineShorterThanNearDistance"; IFeatureClass lineClass = CreateFeatureClass(string.Format("{0}_lines", testName), esriGeometryType.esriGeometryPolyline); IFeature longLine = lineClass.CreateFeature(); longLine.Shape = CurveConstruction.StartLine(0, 0) .LineTo(100, 0) .Curve; longLine.Store(); IFeature shortLine = lineClass.CreateFeature(); shortLine.Shape = CurveConstruction.StartLine(100, 0) .LineTo(101, 0) .Curve; shortLine.Store(); IEnvelope verificationEnvelope = GeometryFactory.CreateEnvelope(0, 0, 500, 500); var test = new QaNodeLineCoincidence(lineClass, new[] { lineClass }, 2, false); var runner = new QaContainerTestRunner(1000, test); runner.Execute(verificationEnvelope); AssertUtils.NoError(runner); }
public void CanIgnoreEndNotCoincident() { IFeatureClass fcLine1; IFeatureClass fcLine2; IFeatureClass fcBorder1; IFeatureClass fcBorder2; CreateFeatureClasses(out fcLine1, out fcLine2, out fcBorder1, out fcBorder2); // border lines are coincident AddLineFeature(fcBorder1, 0, 0, 10, 0, stateId: "A"); AddLineFeature(fcBorder2, 10, 0, 0, 0, stateId: "B"); // connected to border: AddFeature(fcLine1, CurveConstruction.StartLine(4, 2).LineTo(4, 0).LineTo(8, 0).Curve, stateId: "A"); // connected to border, exact match: AddLineFeature(fcLine2, 8, 0, 5, 0, stateId: "B"); AddLineFeature(fcLine2, 5, 0, 4, 0, stateId: "B"); var test = new QaEdgeMatchBorderingLines(fcLine1, fcBorder1, fcLine2, fcBorder2, 0) { LineClass1BorderMatchCondition = "LINE.STATE = BORDER.STATE", LineClass2BorderMatchCondition = "LINE.STATE = BORDER.STATE", BorderingLineMatchCondition = "LINE1.STATE <> LINE2.STATE", AllowNonCoincidentEndPointsOnBorder = true }; AssertUtils.ExpectedErrors(0, Run(test, 1000)); AssertUtils.ExpectedErrors(0, Run(test, 5)); }
private static void VerifyErrorHasZ(IFeatureWorkspace ws) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, true, false)); IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass(ws, "VerifyErrorHasZ", fields, null); // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); IPolycurve line1 = CurveConstruction.StartLine(0, 0, 5) .LineTo(2, 0, 5) .Curve; IFeature row1 = featureClass.CreateFeature(); row1.Shape = line1; row1.Store(); IPolycurve line2 = CurveConstruction.StartLine(-1, 0.02, 5) .LineTo(1, 0.02, 5) .Curve; IFeature row2 = featureClass.CreateFeature(); row2.Shape = line2; row2.Store(); var test = new QaNotNear(featureClass, 0.1, 0.5); var runners = new List <QaTestRunnerBase> { new QaTestRunner(test) { KeepGeometry = true }, new QaContainerTestRunner(1000, test) { KeepGeometry = true } }; foreach (QaTestRunnerBase runner in runners) { runner.Execute(); Assert.True(runner.ErrorGeometries.Count > 0); foreach (IGeometry errorGeometry in runner.ErrorGeometries) { Assert.AreEqual(5, errorGeometry.Envelope.ZMin); } } }
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 CanFindDifferingParts() { IFeatureClass featureClass = CreateLineClass(TestWorkspace); IPolycurve line1 = CurveConstruction.StartLine(0, 0, 5) .LineTo(1, 0, 6) .LineTo(1.5, 0, 6) .LineTo(2, 0, 6) .LineTo(3, 0, 7) .LineTo(3.2, 0, 6.8) .LineTo(3.5, 0, 6.5) .LineTo(4, 0, 6) .LineTo(5, 0, 7) .LineTo(6, 0, 7) .Curve; IFeature row1 = featureClass.CreateFeature(); row1.Shape = line1; row1.Store(); var test = new QaMonotonicZ(featureClass) { AllowConstantValues = false, ExpectedMonotonicity = MonotonicityDirection.Increasing }; var runner = new QaTestRunner(test); runner.Execute(row1); Assert.AreEqual(3, runner.Errors.Count); }
public void CanTestLoopEndPoints() { IFeatureWorkspace ws = TestWorkspaceUtils.CreateInMemoryWorkspace("CanTestLoopEndPoints"); IFeatureClass fc = CreateLineClass(ws); IFeature row1 = fc.CreateFeature(); row1.Shape = CurveConstruction.StartLine(0, 0).LineTo(1, 1).LineTo(1, 0).LineTo(0, 0).Curve; row1.set_Value(fc.Fields.FindField(_nrFieldName), 1); row1.Store(); var test = new QaPseudoNodes(fc, new string[] { }); var runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); test.IgnoreLoopEndpoints = true; runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(0, runner.Errors.Count); }
public void CanTestLinesMaximumDifference() { var lineClass = new FeatureClassMock( 1, "line", esriGeometryType.esriGeometryPolyline); CurveConstruction line1 = CurveConstruction.StartLine(0, 0, 10) .LineTo(10, 0, 10) .LineTo(0, 10, 10); IFeature row1 = lineClass.CreateFeature(line1.Curve); CurveConstruction line2 = CurveConstruction.StartLine(2, -2, 21) .LineTo(2, 20, 21); IFeature row2 = lineClass.CreateFeature(line2.Curve); var test = new QaZDifferenceSelfWrapper(new[] { (IFeatureClass)lineClass }, 0, 10, ZComparisonMethod.BoundingBox, null); var runner = new QaTestRunner(test); int errorCount = test.TestDirect(row1, 0, row2, 0); Assert.AreEqual(1, errorCount); Assert.AreEqual(1, runner.Errors.Count); }
public void CanTestPseudoNodesFactory() { IFeatureWorkspace ws = TestWorkspaceUtils.CreateInMemoryWorkspace("CanTestPseudoNodes"); IFeatureClass fc = CreateLineClass(ws); IFeature row1 = fc.CreateFeature(); row1.Shape = CurveConstruction.StartLine(0, 0).LineTo(1, 1).LineTo(1, 0).LineTo(0, 0).Curve; row1.set_Value(fc.Fields.FindField(_nrFieldName), 1); row1.Store(); var ds1 = (IDataset)fc; var model = new SimpleModel("model", fc); Dataset mds1 = model.AddDataset(new ModelVectorDataset(ds1.Name)); var clsDesc = new ClassDescriptor(typeof(QaFactoryPseudoNodes)); var tstDesc = new TestDescriptor("GroupEnds", clsDesc); var condition = new QualityCondition("cndPseudoNodes", tstDesc); QualityConditionParameterUtils.AddParameterValue( condition, QaFactoryPseudoNodes.PolylineClassesParam, mds1); QualityConditionParameterUtils.AddParameterValue( condition, QaFactoryPseudoNodes.IgnoreFieldsParam, _nrFieldName); QualityConditionParameterUtils.AddParameterValue( condition, QaFactoryPseudoNodes.IgnoreFieldsParam, QaFactoryPseudoNodes.EndLayerFields); // implicit: ignoreLoopEndPoints = false var fact = new QaFactoryPseudoNodes(); fact.Condition = condition; IList <ITest> tests = fact.CreateTests(new SimpleDatasetOpener(model.MasterDatabaseWorkspaceContext)); Assert.AreEqual(1, tests.Count); ITest test = tests[0]; var runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(1, runner.Errors.Count); // set ignoreLoopEndPoints = true and rerun QualityConditionParameterUtils.AddParameterValue( condition, QaFactoryPseudoNodes.IgnoreLoopEndPointsParam, true); fact.Condition = condition; tests = fact.CreateTests(new SimpleDatasetOpener(model.MasterDatabaseWorkspaceContext)); Assert.AreEqual(1, tests.Count); test = tests[0]; runner = new QaTestRunner(test); runner.Execute(); Assert.AreEqual(0, runner.Errors.Count); }
private void TestConnections(IFeatureWorkspace ws) { IFieldsEdit fields = new FieldsClass(); fields.AddField(FieldUtils.CreateOIDField()); fields.AddField(FieldUtils.CreateIntegerField("LineTyp", "LineTyp")); fields.AddField(FieldUtils.CreateShapeField( "Shape", esriGeometryType.esriGeometryPolyline, SpatialReferenceUtils.CreateSpatialReference ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true), 1000, false, false)); IFeatureClass fc = DatasetUtils.CreateSimpleFeatureClass(ws, "TestConnections", fields, null); IList <ITable> tbls = new[] { (ITable)fc }; // make sure the table is known by the workspace ((IWorkspaceEdit)ws).StartEditing(false); ((IWorkspaceEdit)ws).StopEditing(true); { IFeature row = fc.CreateFeature(); row.set_Value(1, 1); row.Shape = CurveConstruction.StartLine(100, 100).LineTo(200, 200).Curve; row.Store(); } { IFeature row = fc.CreateFeature(); row.set_Value(1, 2); row.Shape = CurveConstruction.StartLine(100, 100.1).LineTo(100, 200).Curve; row.Store(); } IList <QaConnectionRule> rules = new[] { new QaConnectionRule(tbls, new[] { "LineTyp = 1" }), new QaConnectionRule(tbls, new[] { "LineTyp = 2" }) }; var test = new QaConnections(new[] { fc }, rules, 0); test.QaError += Test_QaError; _errorCount = 0; test.Execute(); Assert.AreEqual(0, _errorCount); test.QaError -= Test_QaError; var container = new TestContainer(); container.AddTest(test); container.QaError += Test_QaError; _errorCount = 0; container.Execute(); Assert.AreEqual(0, _errorCount); }
public void SegmentsLinearToAnglePerformance() { IPolycurve line = CurveConstruction.StartLine(10, 10).LineTo(11, 15).Curve; for (var i = 0; i < _segmentPerformanceCount; i++) { double angle; TopologicalLineUtils.CalculateToAngle((ISegmentCollection)line, out angle); } }
public void CanTestDefinedExtentMultipleTilesWithLinesNearTileBoundary() { IPolycurve leftOfTileBoundary = CurveConstruction.StartLine(99.5, 10) .LineTo(99.5, 90) .Curve; IPolycurve rightOfTileBoundary = CurveConstruction.StartLine(100.5, 10) .LineTo(100.5, 90) .Curve; IFeatureClass fc = CreateLineClass(_testWs, "CanTestDefinedExtentMultipleTiles_fc"); IFeature row = fc.CreateFeature(); row.Shape = rightOfTileBoundary; row.Store(); IFeatureClass nearClass = CreateLineClass(_testWs, "CanTestDefinedExtentMultipleTiles_near"); IFeature nearRow = nearClass.CreateFeature(); nearRow.Shape = leftOfTileBoundary; nearRow.Store(); IPolygon polygon = GeometryFactory.CreatePolygon( GeometryFactory.CreateEnvelope(0, 0, 200, 200)); const double maximumDistance = 1.5; // one tile for the entire verification extent QaContainerTestRunner runnerLargeTileSize = CreateTestRunner( fc, nearClass, 200, maximumDistance); runnerLargeTileSize.Execute(polygon); AssertUtils.NoError(runnerLargeTileSize); // 4 tiles. // The feature is in the second tile, to the right of the left tile boundary, but within the search distance of it. // The 'near feature' is in the first tile, to the left of the right tile boundary, but within the search distance of it. // NOTE currently this results in an error, since the 'near feature' is not returned again for the second tile // (the test container assumes that it was already considered in the first tile; in this case however, it is // needed for a feature in the *second* tile, which was not yet returned for the first tile. // -> if the search geometry overlaps the tile boundary but the source feature for the search DOES NOT, then // features must be returned by the search even if they overlap a previous tile QaContainerTestRunner runnerSmallTileSize = CreateTestRunner( fc, nearClass, 100, maximumDistance); runnerSmallTileSize.Execute(polygon); AssertUtils.NoError(runnerSmallTileSize); }
public void CanGetOrientationsForNonLinearLines() { const double resol = 0.0001; double yMax; var polyline = (IPolyline)CurveConstruction.StartLine(10, 0) .BezierTo(12, 2, 12, 4, 10, 6) .Curve; Assert.AreEqual(-1, TopologicalLineUtils.CalculateOrientation(polyline, resol, out yMax)); }
public void CanIntersectPointWithTouchingLine() { const double z1 = 10; const double z2 = 20; var g1 = GeometryFactory.CreatePoint(100, 200, z1); var g2 = CurveConstruction.StartLine(100, 200, z2) .LineTo(100, 300, z2) .Curve; Check(g1, g2, 0); Check(g2, g1, 0); }
public void CanIntersectPointWithLine() { const double z1 = 10; const double z2 = 20; var g1 = GeometryFactory.CreatePoint(100, 0, z1); var g2 = CurveConstruction.StartLine(0, 0, z2) .LineTo(200, 0, z2) .Curve; Check(g1, g2, 1, (p, i) => Equals(100, 0, z1, p.Point)); Check(g2, g1, 1, (p, i) => Equals(100, 0, z2, p.Point)); }
public void CanGetSingleSegmentOrientationToLR() { var polyline = (IPolyline)CurveConstruction.StartLine(10, 10) .LineTo(20, 0) .Curve; polyline.SpatialReference = CreateSpatialReference(); TopologicalLine topologicalLine = CreateTopologicalLine(polyline); Assert.AreEqual(2, topologicalLine.Orientation); }
public void CanGetSegmentsAngle() { var line = (ISegmentCollection)CurveConstruction.StartLine(10, 10) .LineTo(11, 15) .Curve; double fromAngle; double toAngle; Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle)); Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle)); Assert.IsTrue(Math.Abs(fromAngle - toAngle - Math.PI) < 1e-12); line = (ISegmentCollection)CurveConstruction.StartLine(10, 10) .LineTo(11, 11) .LineTo(12, 15) .Curve; Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle)); Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle)); Assert.IsTrue(Math.Abs(fromAngle - toAngle - Math.PI) > 1e-12); line = (ISegmentCollection)CurveConstruction.StartLine(10, 10) .LineTo(10, 10) .LineTo(11, 15) .Curve; Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle)); Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle)); Assert.IsTrue(Math.Abs(fromAngle - toAngle - Math.PI) < 1e-12); line = (ISegmentCollection)CurveConstruction.StartLine(10, 10) .LineTo(10, 10) .LineTo(10, 10) .Curve; Assert.IsFalse(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle)); Assert.IsFalse(TopologicalLineUtils.CalculateToAngle(line, out toAngle)); line = (ISegmentCollection)CurveConstruction.StartLine(10, 10) .BezierTo(10, 10, 11, 11, 11, 11) .Curve; Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle)); Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle)); Assert.IsTrue(Math.Abs(fromAngle - toAngle - Math.PI) < 1e-12); line = (ISegmentCollection)CurveConstruction.StartLine(10, 10) .BezierTo(11, 10, 12, 11, 12, 12) .Curve; Assert.IsTrue(TopologicalLineUtils.CalculateFromAngle(line, out fromAngle)); Assert.IsTrue(TopologicalLineUtils.CalculateToAngle(line, out toAngle)); Assert.IsTrue(Math.Abs(fromAngle) < 1e-12); Assert.IsTrue(Math.Abs(toAngle + Math.PI / 2) < 1e-12); }
public void SegmentNonLinearTangentPerformance() { var line = (ISegmentCollection)CurveConstruction.StartLine(10, 10) .BezierTo(11, 12, 11, 13, 12, 15) .Curve; ISegment segment = line.Segment[line.SegmentCount - 1]; ILine tangent = new LineClass(); for (var i = 0; i < _segmentPerformanceCount; i++) { segment.QueryTangent(esriSegmentExtension.esriExtendAtFrom, 0, false, 1, tangent); } }
public void SegmentWksFromPointPerformance() { IPolycurve line = CurveConstruction.StartLine(10, 10) .LineTo(11, 15) .Curve; ISegment segment = ((ISegmentCollection)line).Segment[0]; for (var i = 0; i < _segmentPerformanceCount; i++) { WKSPoint p; segment.QueryWKSFromPoint(out p); } }