Пример #1
0
        public IFeatureCursor GetEdgeFeatures(IQueryFilter filter)
        {
            if (_edgeFcs.Count == 0)
            {
                return(null);
            }

            if (filter is SpatialFilter)
            {
                List <IFeatureClass> edgeFcs = new List <IFeatureClass>();
                if (_edgeFcs != null)
                {
                    foreach (IFeatureClass fc in _edgeFcs.Values)
                    {
                        edgeFcs.Add(fc);
                    }
                }
                return(new NetworkFeatureCursor(_fdb, _name, edgeFcs, null, filter));
            }

            if (filter is RowIDFilter)
            {
                RowIDFilter idFilter = (RowIDFilter)filter;

                Dictionary <int, QueryFilter> rfilters = new Dictionary <int, QueryFilter>();
                Dictionary <int, Dictionary <int, List <FieldValue> > > additionalFields = new Dictionary <int, Dictionary <int, List <FieldValue> > >();
                foreach (int eid in idFilter.IDs)
                {
                    IGraphEdge edge = _pageManager.GetEdge(eid);
                    if (edge == null || _edgeFcs.ContainsKey(edge.FcId) == false)
                    {
                        continue;
                    }

                    if (!rfilters.ContainsKey(edge.FcId))
                    {
                        string idFieldName    = "FDB_OID";
                        string shapeFieldName = "FDB_SHAPE";

                        IFeatureClass fc = edge.FcId >= 0 ? _fdb.GetFeatureclass(edge.FcId) : null;
                        if (fc != null)
                        {
                            idFieldName    = fc.IDFieldName;
                            shapeFieldName = fc.ShapeFieldName;
                        }

                        RowIDFilter rfilter = new RowIDFilter(edge.FcId >= 0 ? idFieldName : "EID");
                        rfilter.fieldPostfix = rfilter.fieldPrefix = "\"";
                        rfilters.Add(edge.FcId, rfilter);
                        rfilters[edge.FcId].AddField(shapeFieldName);
                        additionalFields.Add(edge.FcId, new Dictionary <int, List <FieldValue> >());

                        rfilter.IgnoreUndefinedFields = true;
                        rfilters[edge.FcId].AddField(shapeFieldName);
                        if (filter.SubFields.IndexOf("*") != -1)
                        {
                            rfilters[edge.FcId].AddField("*");
                        }
                        else
                        {
                            foreach (string field in filter.SubFields.Split(' '))
                            {
                                if (field == shapeFieldName)
                                {
                                    continue;
                                }
                                if (fc.Fields.FindField(field) != null)
                                {
                                    rfilter.AddField(fc.Fields.FindField(field).name);
                                }
                            }
                        }
                    }

                    ((RowIDFilter)rfilters[edge.FcId]).IDs.Add(edge.FcId >= 0 ? edge.Oid : edge.Eid);
                    additionalFields[edge.FcId].Add(edge.FcId >= 0 ? edge.Oid : edge.Eid, new List <FieldValue>()
                    {
                        new FieldValue("_eid", edge.Eid)
                    });
                }
                if (rfilters.ContainsKey(-1))
                {
                    RowIDFilter complexEdgeFilter = (RowIDFilter)rfilters[-1];
                    QueryFilter ceFilter          = new QueryFilter(complexEdgeFilter);
                    ceFilter.WhereClause = complexEdgeFilter.RowIDWhereClause;
                    rfilters[-1]         = ceFilter;
                }
                return(new CursorCollection <int>(_edgeFcs, rfilters, additionalFields));
            }

            return(null);
        }