private void AddDanglingEndpoint([NotNull] TableIndexRow tableIndexRow, [NotNull] IPoint endPoint) { int tableIndex = tableIndexRow.TableIndex; IDictionary <int, FeatureDangleCount> dangleCountPerFeature; if (!_dangleCounts.TryGetValue(tableIndex, out dangleCountPerFeature)) { dangleCountPerFeature = new Dictionary <int, FeatureDangleCount>(); _dangleCounts.Add(tableIndex, dangleCountPerFeature); } var feature = (IFeature)tableIndexRow.Row; int oid = feature.OID; FeatureDangleCount dangleCount; if (!dangleCountPerFeature.TryGetValue(oid, out dangleCount)) { feature.Shape.QueryEnvelope(_envelopeTemplate); dangleCount = new FeatureDangleCount(feature, _envelopeTemplate.XMax, _envelopeTemplate.YMax); dangleCountPerFeature[oid] = dangleCount; } dangleCount.AddDanglingPoint(endPoint); }
private void AddNetElements([NotNull] TableIndexRow row, [NotNull] List <NetElement> netElems) { IGeometry geom = ((IFeature)row.Row).Shape; switch (geom.GeometryType) { case esriGeometryType.esriGeometryPoint: netElems.Add(new NetPoint(row)); break; case esriGeometryType.esriGeometryPolyline: foreach (DirectedRow directedRow in GetDirectedRows(row)) { netElems.Add(directedRow); netElems.Add(directedRow.Reverse()); } break; default: throw new ArgumentException("Invalid geometry type " + geom.GeometryType); } }
private string GetGroup([NotNull] TableIndexRow row) { string group; GetDataRow(row, out group); return(group); }
private static bool IsPseudoNode([NotNull] IEnumerable <NetElement> connectedRows, bool ignoreLoopEndpoints, [CanBeNull] out IRow lineFeature1, [CanBeNull] out IRow lineFeature2) { lineFeature1 = null; lineFeature2 = null; var connectedLines = new TableIndexRow[2]; int lineRowIndex = 0; foreach (NetElement elem in connectedRows) { if (elem is NetPoint) { // valid pseudo node return(false); } if (lineRowIndex >= 2) { // more than 2 lines return(false); } connectedLines[lineRowIndex] = elem.Row; lineRowIndex++; } if (lineRowIndex != 2) { return(false); } var line1 = connectedLines[0]; var line2 = connectedLines[1]; if (line1.TableIndex != line2.TableIndex) { // from different line feature class parameter return(false); } if (ignoreLoopEndpoints) { if (line1.Row.OID == line2.Row.OID && line1.Row.Table == line2.Row.Table) { // same row -> don't report loop node return(false); } } lineFeature1 = line1.Row; lineFeature2 = line2.Row; return(true); }
public void Add([NotNull] DataRow dataRow, [NotNull] TableIndexRow row, [NotNull] Func <bool> existsRowFilterValue) { if (!_existsRowFilterFulfilled) { _existsRowFilterFulfilled = existsRowFilterValue(); } Add(dataRow, row); }
private DataRow GetDataRow([NotNull] TableIndexRow tableIndexRow, [NotNull] out string group) { TableView helper = _helpers[tableIndexRow.TableIndex]; var result = Assert.NotNull(helper.Add(tableIndexRow.Row), "no dataRow"); object value = result[_groupByColumn]; group = value == null || value is DBNull ? string.Empty : value.ToString(); return(result); }
protected override void Add(DataRow dataRow, TableIndexRow row) { string value = GetDistinctExpressionValue(dataRow); List <TestRowReference[]> oidTuples; if (!_distinctValues.TryGetValue(value, out oidTuples)) { oidTuples = new List <TestRowReference[]>(); _distinctValues.Add(value, oidTuples); } oidTuples.Add(IsJoinedTable ? GetJoinedRowOIDTuple(dataRow) : new[] { row.GetRowInfo() }); }
private List <IRow> GetConnectedRows( [NotNull] ICollection <NetElement> connectedElements, bool getAllLineFieldValues, [NotNull] out List <object> lineFieldValues, [NotNull] out List <object> distinctPointFieldValues, out int pointCount) { int connectedElementsCount = connectedElements.Count; var result = new List <IRow>(connectedElementsCount); lineFieldValues = new List <object>(); distinctPointFieldValues = new List <object>(); pointCount = 0; foreach (NetElement netElement in connectedElements) { TableIndexRow row = netElement.Row; result.Add(row.Row); int tableIndex = row.TableIndex; bool isPoint = tableIndex >= _pointClassesMinIndex; if (isPoint) { pointCount++; if (!_usePointFields) { continue; } } bool getDistinctValues = isPoint || !getAllLineFieldValues; AddToValues(netElement, tableIndex, getDistinctValues, isPoint ? distinctPointFieldValues : lineFieldValues); } return(result); }
protected IEnumerable <DirectedRow> GetDirectedRows(TableIndexRow row) { IGeometry geom = ((IFeature)row.Row).Shape; var paths = (IGeometryCollection)geom; if (!UseMultiParts) { yield return(new DirectedRow(row, -1, isBackward: false)); yield break; } int pathCount = paths.GeometryCount; for (var iPath = 0; iPath < pathCount; iPath++) { yield return(new DirectedRow(row, iPath, isBackward: false)); } }
private void UpdateDangleCount([NotNull] IList <NetElement> connectedRows) { if (connectedRows.Count != 1) { return; } var directedRow = connectedRows[0] as DirectedRow; if (directedRow == null) { return; } // we found an edge end point not connected to any other feature --> a dangle TableIndexRow feature = directedRow.Row; AddDanglingEndpoint(feature, directedRow.NetPoint); }
private bool HasPointsAndAllAreAllowed( [NotNull] IEnumerable <NetElement> connectedElements, [NotNull] out IList <NetElement> elementsToCheck, [NotNull] IList <TableView> allowedPointsTableViews) { var hasPoints = false; var allPointsAllowed = true; elementsToCheck = new List <NetElement>(); foreach (NetElement connectedElement in connectedElements) { TableIndexRow row = connectedElement.Row; int tableIndex = row.TableIndex; if (tableIndex < _pointClassesMinIndex) { elementsToCheck.Add(connectedElement); continue; } hasPoints = true; // found a point int pointClassIndex = row.TableIndex - _pointClassesMinIndex; TableView allowedPointsTableView = allowedPointsTableViews[pointClassIndex]; allowedPointsTableView.ClearRows(); allowedPointsTableView.Add(row.Row); if (!allowedPointsTableView.MatchesConstraint(row.Row)) { elementsToCheck.Add(connectedElement); allPointsAllowed = false; // found an unallowed point } } // if there are any points, then they are all allowed by here. return(hasPoints && allPointsAllowed); }
private int CheckRows([NotNull] IList <NetElement> connectedElements) { int tableCount = _tableFilterHelpers.Length; for (int i = 0; i < tableCount; i++) { _tableFilterHelpers[i].ClearRows(); } int connectedElementsCount = connectedElements.Count; var connectedRows = new List <IRow>(connectedElementsCount); var connectedRowTableIndices = new List <int>(connectedElementsCount); foreach (NetElement netElement in connectedElements) { TableIndexRow row = netElement.Row; connectedRows.Add(row.Row); int tableIndex = row.TableIndex; connectedRowTableIndices.Add(tableIndex); TableView baseHelper = _tableFilterHelpers[tableIndex]; DataRow helperRow = baseHelper.Add(row.Row); Assert.NotNull(helperRow, "no row returned"); if (netElement is DirectedRow) { helperRow[StartsIn] = !((DirectedRow)netElement).IsBackward; } } bool fulfilledRuleFound = false; foreach (QaConnectionRuleHelper ruleHelper in _ruleHelpers) { // check if all rows comply to the current rule int matchingRowsCount = 0; for (int tableIndex = 0; tableIndex < tableCount; tableIndex++) { matchingRowsCount += GetMatchingRowsCount(tableIndex, ruleHelper); } Assert.True(matchingRowsCount <= connectedElementsCount, "Unexpected matching rows count: {0}; total connected rows: {1}", matchingRowsCount, connectedElementsCount); if (matchingRowsCount == connectedElementsCount && ruleHelper.VerifyCountRules()) { // all rows comply to the current rule, // so one rule if fulfilled and no further checking needed fulfilledRuleFound = true; break; } } if (fulfilledRuleFound) { // TODO apply further checks? return(NoError); } // no rule fulfills all the rows const string description = "Rows do not fulfill rules"; return(ReportError(description, connectedElements[0].NetPoint, Codes[Code.RulesNotFulfilled], null, GetInvolvedRows(connectedRows))); }
protected abstract void Add([NotNull] DataRow dataRow, [NotNull] TableIndexRow row);
private bool GetExistsRowFilterValue([NotNull] TableIndexRow tableIndexRow) { return(Assert.NotNull(_existsRowGroupFilter)[tableIndexRow.TableIndex] .IsFulfilled(tableIndexRow.Row)); }