public TNeighbors GetNeighbors(
            [NotNull] TBorderConnection borderConnection)
        {
            Dictionary <FeatureKey, TNeighbors> neighborsByFeature;
            var geometryFeatureKey = new FeatureKey(borderConnection.Feature.OID,
                                                    borderConnection.ClassIndex);

            if (!_borderConnections.TryGetValue(geometryFeatureKey, out neighborsByFeature))
            {
                neighborsByFeature =
                    new Dictionary <FeatureKey, TNeighbors>(new FeatureKeyComparer());
                _borderConnections.Add(geometryFeatureKey, neighborsByFeature);
            }

            TNeighbors neighbors;
            var        borderFeatureKey = new FeatureKey(
                borderConnection.BorderFeature.OID, borderConnection.BorderClassIndex);

            if (!neighborsByFeature.TryGetValue(borderFeatureKey, out neighbors))
            {
                neighbors = CreateNeighbors(borderConnection);
                neighborsByFeature.Add(borderFeatureKey, neighbors);
            }

            return(neighbors);
        }
示例#2
0
        public IEnumerable <T> GetBorderConnections <TG>(
            [NotNull] TG geometry,
            [NotNull] IFeature geometryFeature,
            int geometryClassIndex,
            int borderClassIndex,
            ITable borderClass,
            ISpatialFilter spatialFilter,
            QueryFilterHelper filterHelper,
            Func <ITable, IQueryFilter, QueryFilterHelper, IEnumerable <IRow> > search,
            RowPairCondition borderMatchCondition)
            where TG : IGeometry
        {
            var geometryKey = new FeatureKey(geometryFeature.OID, geometryClassIndex);

            Dictionary <FeatureKey, T> borderConnections;

            if (!_cache.TryGetValue(geometryKey, out borderConnections))
            {
                borderConnections = new Dictionary <FeatureKey, T>(new FeatureKeyComparer());

                _cache.Add(geometryKey, borderConnections);
            }

            IPolyline geometryLine = geometry is IPolyline
                                                         ? (IPolyline)geometry
                                                         : (IPolyline)((ITopologicalOperator)geometry).Boundary;

            IEnumerable <IFeature> borderFeatures =
                GetConnectedBorderFeatures(geometry, geometryFeature, geometryClassIndex,
                                           borderClassIndex, search, borderClass, spatialFilter,
                                           filterHelper, borderMatchCondition);

            foreach (IFeature borderFeature in borderFeatures)
            {
                var borderKey = new FeatureKey(borderFeature.OID, borderClassIndex);

                T borderConnection;
                if (!borderConnections.TryGetValue(borderKey, out borderConnection))
                {
                    IPolyline geometryAlongBorder = GetGeometryAlongBorder(borderFeature,
                                                                           geometryLine);

                    borderConnection = CreateBorderConnection(geometryFeature, geometryClassIndex,
                                                              borderFeature,
                                                              borderClassIndex,
                                                              geometryAlongBorder,
                                                              geometryAlongBorder);

                    borderConnections.Add(borderKey, borderConnection);
                }
            }

            return(new List <T>(borderConnections.Values));
        }