예제 #1
0
        /*
         * public IFeature GetFeature(int id, getFeatureQueryType type)
         * {
         *  if (_dataset == null) return null;
         *
         *  string sql = this.IDFieldName + "=" + id.ToString();
         *  QueryFilter filter = new QueryFilter();
         *  filter.WhereClause = sql;
         *
         *  switch (type)
         *  {
         *      case getFeatureQueryType.All:
         *          filter.SubFields = "*";
         *          break;
         *      case getFeatureQueryType.Attributes:
         *          if (this.Fields == null) return null;
         *          foreach (IField field in this.Fields)
         *          {
         *              if (field.type == FieldType.Shape) continue;
         *              filter.AddField(field.name);
         *          }
         *          break;
         *      case getFeatureQueryType.Geometry:
         *          if (filter.SubFields != "*") filter.AddField(ShapeFieldName);
         *          break;
         *  }
         *
         *  SdeFeatureCursor cursor = new SdeFeatureCursor(_dataset, this, filter);
         *  return cursor.NextFeature;
         * }
         *
         * public IFeatureCursor GetFeatures(List<int> ids, getFeatureQueryType type)
         * {
         *  if (_dataset == null) return null;
         *
         *  StringBuilder sql = new StringBuilder();
         *  sql.Append(this.IDFieldName + " in (");
         *  for (int i = 0; i < ids.Count; i++)
         *  {
         *      if (i > 0) sql.Append(",");
         *      sql.Append(ids[i].ToString());
         *  }
         *  sql.Append(")");
         *  QueryFilter filter = new QueryFilter();
         *  filter.WhereClause = sql.ToString();
         *
         *  switch (type)
         *  {
         *      case getFeatureQueryType.All:
         *          filter.SubFields = "*";
         *          break;
         *      case getFeatureQueryType.Attributes:
         *          if (this.Fields == null) return null;
         *          foreach (IField field in this.Fields)
         *          {
         *              if (field.type == FieldType.Shape) continue;
         *              filter.AddField(field.name);
         *          }
         *          break;
         *      case getFeatureQueryType.Geometry:
         *          filter.SubFields = this.ShapeFieldName;
         *          break;
         *  }
         *
         *  SdeFeatureCursor cursor = new SdeFeatureCursor(_dataset, this, filter);
         *  return cursor;
         * }
         */

        public IFeatureCursor GetFeatures(IQueryFilter filter)
        {
            try
            {
                //if (filter is ISpatialFilter)
                //{
                //    ISpatialFilter filterIDs = filter.Clone() as ISpatialFilter;
                //    filterIDs.SubFields = this.IDFieldName;

                //    SdeFeatureCursor cursor = new SdeFeatureCursor(_dataset, this, filterIDs);
                //    if (cursor == null) return null;

                //    List<int> ids = new List<int>();
                //    IFeature feature;
                //    while ((feature = cursor.NextFeature) != null)
                //    {
                //        ids.Add(feature.OID);
                //    }
                //}
                SdeFeatureCursor cursor = new SdeFeatureCursor(_dataset, this, filter);
                return(cursor);
            }
            catch (Exception ex)
            {
                _errMsg = ex.Message;
                return(null);
            }
        }
예제 #2
0
        public ISelectionSet Select(IQueryFilter filter)
        {
            filter.SubFields = this.IDFieldName;

            using (SdeFeatureCursor cursor = new SdeFeatureCursor(_dataset, this, filter))
            {
                IFeature feat;

                IDSelectionSet selSet = new IDSelectionSet();
                while ((feat = cursor.NextFeature) != null)
                {
                    selSet.AddID(feat.OID);
                }

                return(selSet);
            }
        }
예제 #3
0
        public ICursor Search(IQueryFilter filter)
        {
            SdeFeatureCursor cursor = new SdeFeatureCursor(_dataset, this, filter);

            return(cursor);
        }