public static int Execute([NotNull] TestContainer container, [CanBeNull] AreaOfInterest areaOfInterest) { Assert.ArgumentNotNull(container, nameof(container)); IGeometry testPerimeter = areaOfInterest?.Geometry; // TODO move enlarging by search distance WITHIN the container? IGeometry enlargedTestPerimeter = GetEnlargedTestPerimeter(container, testPerimeter); var box = enlargedTestPerimeter as IEnvelope; if (box != null) { return(container.Execute(box)); } var polygon = enlargedTestPerimeter as IPolygon; if (polygon != null) { return(container.Execute(polygon)); } if (enlargedTestPerimeter == null) { return(container.Execute()); } throw new ArgumentException("Invalid geometry type " + enlargedTestPerimeter.GeometryType); }
private IList <ITest> AssembleTests([NotNull] IEnumerable <ITest> tests, [CanBeNull] AreaOfInterest areaOfInterest, bool filterTableRowsUsingRelatedGeometry, [NotNull] out List <ITest> testsToVerifyByRelatedGeometry) { Assert.ArgumentNotNull(tests, nameof(tests)); List <ITest> containerTests = new List <ITest>(); testsToVerifyByRelatedGeometry = new List <ITest>(); foreach (ITest test in tests) { // only if none of the involved datasets is a feature class or a terrain bool filterByRelatedGeometry = filterTableRowsUsingRelatedGeometry && areaOfInterest != null && !_getQualityCondition(test).NeverFilterTableRowsUsingRelatedGeometry&& !TestUtils.UsesSpatialDataset(test); if (filterByRelatedGeometry) { // only if none of the involved datasets is a feature class or a terrain testsToVerifyByRelatedGeometry.Add(test); } else { containerTests.Add(test); } } return(containerTests); }
private static IPolygon GetPolygon([NotNull] AreaOfInterest aoi, [NotNull] ISpatialReference spatialReference) { IPolygon result = aoi.CreatePolygon(); GeometryUtils.EnsureSpatialReference(result, spatialReference); return(result); }
public List <IList <QualityCondition> > BuildQualityConditionGroups( [NotNull] IList <ITest> tests, [CanBeNull] AreaOfInterest areaOfInterest, bool filterTableRowsUsingRelatedGeometry, int maxProcesses) { IList <ITest> containerTests = AssembleTests( tests, areaOfInterest, filterTableRowsUsingRelatedGeometry, out IList <TestsWithRelatedGeometry> testsWithRelatedGeometry); return(BuildQcGroups(containerTests, testsWithRelatedGeometry, maxProcesses)); }
public void Execute(IEnumerable <ITest> tests, AreaOfInterest areaOfInterest, CancellationTokenSource cancellationTokenSource) { Assert.NotNull(TestAssembler, nameof(TestAssembler)); StartVerification(QualityVerification); TimeSpan processorStartTime = Process.GetCurrentProcess().UserProcessorTime; CancellationTokenSource = cancellationTokenSource; CancellationTokenSource.Token.Register(() => _executeContainer?.StopExecute()); VerificationTimeStats = new VerificationTimeStats(); _testPerimeter = areaOfInterest?.Geometry; IList <ITest> containerTests = TestAssembler.AssembleTests( tests, areaOfInterest, FilterTableRowsUsingRelatedGeometry, out IList <TestsWithRelatedGeometry> testsWithRelatedGeometry); var container = GetTestContainer(containerTests, AllowEditing, _tileSize, ForceFullScanForNonContainerTests); RowsWithStopConditions.Clear(); VerifyByRelatedGeometry(testsWithRelatedGeometry); if (!Cancelled) { Verify(container, areaOfInterest); } EndVerification(QualityVerification, processorStartTime); _msg.DebugFormat("Number of rows with stop conditions: {0}", RowsWithStopConditions.Count); }
internal IList <ITest> AssembleTests( [NotNull] IEnumerable <ITest> tests, [CanBeNull] AreaOfInterest areaOfInterest, bool filterTableRowsUsingRelatedGeometry, [NotNull] out IList <TestsWithRelatedGeometry> testsWithRelatedGeometry) { IList <ITest> containerTests = AssembleTests( tests, areaOfInterest, filterTableRowsUsingRelatedGeometry, out List <ITest> testsToVerifyByRelatedGeometry); testsWithRelatedGeometry = FindTestsWithRelatedGeometry( testsToVerifyByRelatedGeometry, _datasetResolver, out IList <ITest> testsWithoutGeometry); foreach (ITest test in testsWithoutGeometry) { containerTests.Add(test); } return(containerTests); }
public IFeatureClass WriteAreaOfInterest( [NotNull] AreaOfInterest aoi, [NotNull] ISpatialReference spatialReference) { Assert.ArgumentNotNull(aoi, nameof(aoi)); Assert.ArgumentNotNull(spatialReference, nameof(spatialReference)); Assert.ArgumentCondition(!aoi.IsEmpty, "area of interest must not be empty"); IPolygon polygon = GetPolygon(aoi, spatialReference); const bool hasM = false; bool hasZ = GeometryUtils.IsZAware(polygon) && !GeometryUtils.HasUndefinedZValues(polygon); // create table IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass( _featureWorkspace, "AreaOfInterest", FieldUtils.CreateFields(GetFields(spatialReference, hasZ, hasM))); DatasetUtils.TrySetAliasName(featureClass, LocalizableStrings.AoiLayerName); IFeature feature = featureClass.CreateFeature(); GeometryUtils.EnsureSchemaZM(polygon, hasZ, hasM); feature.Shape = polygon; Write(feature, AttributeRole.Description, aoi.Description); Write(feature, AttributeRole.FeatureSource, aoi.FeatureSource); Write(feature, AttributeRole.WhereClause, aoi.WhereClause); Write(feature, AttributeRole.BufferDistance, aoi.BufferDistance); Write(feature, AttributeRole.GeneralizationTolerance, aoi.GeneralizationTolerance); feature.Store(); return(featureClass); }
private void Verify([NotNull] TestContainer container, [CanBeNull] AreaOfInterest areaOfInterest) { Assert.ArgumentNotNull(container, nameof(container)); ClearCurrentRow(); // add handlers container.TestingRow += container_TestingRow; container.QaError += HandleError; container.ProgressChanged += container_OnProgressChanged; try { _executeContainer = container; // TODO let the container know about the selected features // (filter TestRows by inclusion in selection list) TestExecutionUtils.Execute(container, areaOfInterest); } catch (TestContainerException e) { QualityCondition qualityCondition = GetQualityCondition(e.Test); string description = string.Format("Error testing {0}: {1}", qualityCondition.Name, e.Message); var involvedRows = new InvolvedRow[] { }; IGeometry exceptionErrorGeometry = null; if (_currentRow != null) { if (_currentRow.HasOID && _currentRow.Table.HasOID) // ie TerrainRow (wrapper around terrain tile) { // second part: ESRI Bug for IQueryDefTables // which returns row.HasOID = true involvedRows = new[] { new InvolvedRow(_currentRow) }; } try { var feature = _currentRow as IFeature; IGeometry shape = feature?.Shape; if (shape != null && !shape.IsEmpty) { exceptionErrorGeometry = feature.ShapeCopy; } } catch (Exception exception) { _msg.Error( "Error trying to get geometry from feature involved in failed test", exception); } } if (exceptionErrorGeometry == null) { exceptionErrorGeometry = e.Box; } var qaError = new QaError(e.Test, description, involvedRows, exceptionErrorGeometry, null, null); ProcessQaError(qaError); CancellationTokenSource.Cancel(); CancellationMessage = description; _msg.Error(description, e); } finally { // remove handlers container.ProgressChanged -= container_OnProgressChanged; container.QaError -= HandleError; container.TestingRow -= container_TestingRow; } }