예제 #1
0
        protected override int ExecuteCore(IRow row, int tableIndex)
        {
            if (_queryFilter == null)
            {
                InitFilter();
                Assert.NotNull(_queryFilter, "_queryFilter");
            }

            if (_relevantRelationCondition == null)
            {
                _relevantRelationCondition =
                    new RelevantRelationCondition(_relevantRelationConditionSql,
                                                  GetSqlCaseSensitivity());
            }

            var feature = (IFeature)row;

            if (_crossTileFeatureState.IsFeatureKnownOK(tableIndex, feature.OID))
            {
                return(NoError);
            }

            IGeometry shape = feature.Shape;

            int startTableIndex = IgnoreUndirected
                                                      ? tableIndex
                                                      : 0;

            bool anyTouching = false;

            for (int relatedTableIndex = startTableIndex;
                 relatedTableIndex < _totalClassesCount;
                 relatedTableIndex++)
            {
                foreach (IFeature relatedFeature in GetRelatedFeatures(shape, relatedTableIndex))
                {
                    if (!_relevantRelationCondition.IsFulfilled(row, tableIndex,
                                                                relatedFeature, relatedTableIndex))
                    {
                        continue;
                    }

                    // a relevant touching feature is found -> correct
                    anyTouching = true;
                    _crossTileFeatureState.FlagFeatureAsOK(tableIndex, feature);

                    // the related feature is now also known to be correct
                    _crossTileFeatureState.FlagFeatureAsOK(relatedTableIndex, relatedFeature);
                }
            }

            if (!anyTouching)
            {
                // could be an error; but maybe there's a touching feature in a later tile
                PendingFeature pendingFeature;
                _crossTileFeatureState.FlagFeatureAsSuspicious(tableIndex, feature,
                                                               out pendingFeature);
            }

            return(NoError);
        }
        protected sealed override int ExecuteCore(IRow row, int tableIndex)
        {
            if (_queryFilter == null)
            {
                InitFilter();
                Assert.NotNull(_queryFilter, "_queryFilter");
            }

            if (_relevantRelationCondition == null)
            {
                _relevantRelationCondition =
                    new RelevantRelationCondition(_relevantRelationConditionSql,
                                                  GetSqlCaseSensitivity());
            }

            if (tableIndex >= _firstOtherClassIndex)
            {
                // it's a row from the other feature classes, ignore
                return(NoError);
            }

            var feature = (IFeature)row;

            if (CrossTileFeatureState.IsFeatureKnownOK(tableIndex, feature.OID))
            {
                return(NoError);
            }

            IGeometry shape = feature.Shape;

            bool      searchGeometryIsExpanded;
            IGeometry searchGeometry = GetSearchGeometry(feature, tableIndex,
                                                         out searchGeometryIsExpanded);

            var anyRelated = false;

            if (searchGeometry != null && !searchGeometry.IsEmpty)
            {
                for (int relatedTableIndex = _firstOtherClassIndex;
                     relatedTableIndex < _totalClassesCount;
                     relatedTableIndex++)
                {
                    foreach (IFeature relatedFeature in
                             GetRelatedFeatures(searchGeometry, relatedTableIndex,
                                                feature.Shape))
                    {
                        if (relatedFeature == feature)
                        {
                            continue;                             // same feature instance
                        }

                        if (relatedFeature.OID == feature.OID &&
                            relatedFeature.Table == feature.Table)
                        {
                            continue;                             // same feature
                        }

                        if (!_relevantRelationCondition.IsFulfilled(row, tableIndex,
                                                                    relatedFeature,
                                                                    relatedTableIndex))
                        {
                            continue;                             // the pair does not fulfill the condition
                        }

                        // this check can be expensive, so do this after the condition check
                        if (!IsValidRelation(shape, relatedFeature))
                        {
                            continue;
                        }

                        // a relevant related feature is found -> correct
                        anyRelated = true;
                        CrossTileFeatureState.FlagFeatureAsOK(tableIndex, feature);
                    }
                }
            }

            if (!anyRelated)
            {
                // could be an error; but maybe there's a related feature in a later tile
                FlagFeatureAsSuspicious(tableIndex, feature);
            }

            return(NoError);
        }