protected override int ExecuteCore(IRow row, int tableIndex)
        {
            if (tableIndex > 0)
            {
                return(NoError);
            }

            if (_filter == null)
            {
                InitFilter();
            }

            ISpatialFilter filter = Assert.NotNull(_filter, "_filter");

            var processed0 = new SegmentNeighbors(new SegmentPartComparer());

            IGeometry geom0 = ((IFeature)row).Shape;
            IEnvelope box0  = geom0.Envelope;

            box0.Expand(SearchDistance, SearchDistance, false);

            filter.Geometry = box0;

            var errorCount = 0;

            double    maxNear            = SearchDistance;
            const int neighborTableIndex = 1;

            IFeatureRowsDistance rowsDistance =
                NearDistanceProvider.GetRowsDistance(row, tableIndex);

            foreach (IRow neighborRow in
                     Search((ITable)_reference, filter, _helper, geom0))
            {
                var rowNeighbor = (IFeature)neighborRow;

                if (IgnoreNeighbor(row, neighborRow))
                {
                    continue;
                }

                SegmentNeighbors processed1;
                var neighborKey = new RowKey(rowNeighbor, neighborTableIndex);
                if (!ProcessedList.TryGetValue(neighborKey, out processed1))
                {
                    processed1 = new SegmentNeighbors(new SegmentPartComparer());
                    ProcessedList.Add(neighborKey, processed1);
                }

                NeighborhoodFinder finder =
                    GetNeighborhoodFinder(rowsDistance, (IFeature)row, tableIndex,
                                          rowNeighbor, neighborTableIndex);
                errorCount += FindNeighborhood(finder, tableIndex, processed0,
                                               neighborTableIndex, processed1,
                                               maxNear);
            }

            return(errorCount);
        }
Esempio n. 2
0
        protected override int ExecuteCore(IRow row, int tableIndex)
        {
            if (tableIndex != 0)
            {
                return(NoError);
            }

            if (_spatialFilters == null)
            {
                InitFilter();
            }

            IList <ISpatialFilter> filters = Assert.NotNull(_spatialFilters);

            // iterating over all needed tables
            int neighborTableIndex = -1;

            IGeometry geom0 = ((IFeature)row).Shape;

            geom0.QueryEnvelope(_queryBox);

            SegmentNeighbors processed0;
            var rowKey = new RowKey(row, tableIndex);

            if (!ProcessedList.TryGetValue(rowKey, out processed0))
            {
                // add to process List
                processed0 = new SegmentNeighbors(new SegmentPartComparer());
                ProcessedList.Add(rowKey, processed0);
            }

            _queryBox.Expand(SearchDistance, SearchDistance, false);
            double maxNear = SearchDistance;

            IFeatureRowsDistance rowsDistance =
                NearDistanceProvider.GetRowsDistance(row, tableIndex);

            foreach (IFeatureClass neighborFeatureClass in _referenceList)
            {
                neighborTableIndex++;

                ISpatialFilter spatialFilter = filters[neighborTableIndex];
                spatialFilter.Geometry = _queryBox;

                var neighborTable = (ITable)neighborFeatureClass;

                foreach (IRow neighborRow in
                         Search(neighborTable, spatialFilter, _helperList[neighborTableIndex], geom0))
                {
                    if (IgnoreNeighbor(row, neighborRow, neighborTableIndex))
                    {
                        continue;
                    }

                    var neighborFeature = (IFeature)neighborRow;
                    var processed1      = new SegmentNeighbors(new SegmentPartComparer());

                    var finder = new FullNeighborhoodFinder(
                        rowsDistance, (IFeature)row, tableIndex, neighborFeature,
                        neighborTableIndex);
                    FindNeighborhood(finder, tableIndex, processed0,
                                     neighborTableIndex, processed1,
                                     maxNear);
                }
            }

            // Remark: here only the neighborhood properties are found
            // if these properties are correct is checked in OnProgressedChanged
            return(NoError);
        }
Esempio n. 3
0
        protected override int ExecuteCore(IRow row, int tableIndex)
        {
            if (tableIndex > 0)
            {
                return(NoError);
            }

            var feature = row as IFeature;

            if (feature == null)
            {
                return(NoError);
            }

            if (_filter == null)
            {
                InitFilter();
                Assert.NotNull(_filter, "_filter");
            }

            var processed0 = new SegmentNeighbors(new SegmentPartComparer());

            IGeometry geom0 = feature.Shape;
            IEnvelope box0  = geom0.Envelope;

            const bool asRatio = false;

            box0.Expand(SearchDistance, SearchDistance, asRatio);

            ISpatialFilter filter = Assert.NotNull(_filter);

            filter.Geometry = box0;

            var errorCount = 0;

            double               maxNear             = SearchDistance;
            const int            referenceTableIndex = 0;
            IFeatureRowsDistance rowsDistance        =
                NearDistanceProvider.GetRowsDistance(feature, tableIndex);

            foreach (IRow neighborRow in Search((ITable)_reference, filter, _helper, geom0))
            {
                var neighborFeature = (IFeature)neighborRow;

                if (neighborFeature == feature)
                {
                    continue;
                }

                // TODO apply comparison condition to filter out irrelevant pairs
                if (IgnoreNeighbor(row, neighborRow))
                {
                    continue;
                }

                SegmentNeighbors processed1;
                var neighborKey = new RowKey(neighborFeature, referenceTableIndex);
                if (!ProcessedList.TryGetValue(neighborKey, out processed1))
                {
                    processed1 = new SegmentNeighbors(new SegmentPartComparer());

                    ProcessedList.Add(neighborKey, processed1);
                }

                NeighborhoodFinder finder = new NotNearNeighborhoodFinder(
                    rowsDistance, feature, tableIndex, neighborFeature, referenceTableIndex);

                errorCount += FindNeighborhood(finder, tableIndex, processed0,
                                               referenceTableIndex, processed1,
                                               maxNear);
            }

            return(errorCount);
        }