Ejemplo n.º 1
0
        async public Task <IFeatureCursor> GetFeatures(IQueryFilter filter)
        {
            if (filter is ISpatialFilter)
            {
                filter = SpatialFilter.Project(filter as ISpatialFilter, this.SpatialReference);
            }

            return(await FeatureCursor.Create(_etcon, filter, this));
        }
Ejemplo n.º 2
0
        async static public Task <FeatureCursor> Create(EventTableConnection etconn, IQueryFilter filter, IFeatureClass fc)
        {
            var cursor = new FeatureCursor(etconn, filter);

            cursor._etcon = etconn;
            if (etconn != null)
            {
                CommonDbConnection conn = new CommonDbConnection();
                conn.ConnectionString2 = etconn.DbConnectionString.ConnectionString;

                string appendWhere = String.Empty;
                if (filter is ISpatialFilter &&
                    ((ISpatialFilter)filter).Geometry != null)
                {
                    if (!(((ISpatialFilter)filter).Geometry is Envelope))
                    {
                        cursor._addShape = true;
                        filter.AddField("#SHAPE#");
                        cursor._spatialFilter = (ISpatialFilter)filter;
                    }
                    IEnvelope env = ((ISpatialFilter)filter).Geometry.Envelope;
                    appendWhere =
                        etconn.XFieldName + ">=" + env.minx.ToString(_nhi) + " AND " +
                        etconn.XFieldName + "<=" + env.maxx.ToString(_nhi) + " AND " +
                        etconn.YFieldName + ">=" + env.miny.ToString(_nhi) + " AND " +
                        etconn.YFieldName + "<=" + env.maxy.ToString(_nhi);
                }
                if (filter is IRowIDFilter)
                {
                    IRowIDFilter idFilter = (IRowIDFilter)filter;
                    appendWhere = idFilter.RowIDWhereClause;
                }

                string where = (filter != null) ? filter.WhereClause : String.Empty;
                if (!String.IsNullOrEmpty(where))
                {
                    where += (String.IsNullOrEmpty(appendWhere) ? String.Empty : " AND (" + appendWhere + ")");
                }
                else
                {
                    where = appendWhere;
                }

                StringBuilder sb = new StringBuilder();
                sb.Append(filter.SubFieldsAndAlias);
                foreach (string fieldname in filter.SubFields.Split(' '))
                {
                    if (fieldname == "#SHAPE#")
                    {
                        if (sb.Length > 0)
                        {
                            sb.Append(",");
                        }

                        sb.Append(cursor._etcon.XFieldName + "," + cursor._etcon.YFieldName);
                        cursor._addShape = true;
                    }
                    if (fieldname == "*")
                    {
                        cursor._addShape = true;
                    }
                }

                string fields = sb.ToString().Replace(",#SHAPE#", "").Replace("#SHAPE#,", "").Replace("#SHAPE#", "");

                //_tab = conn.Select(sb.ToString(), etconn.TableName, where);
                //_addShape = _tab.Columns.Contains(_etcon.XFieldName) &&
                //            _tab.Columns.Contains(_etcon.YFieldName);

                var limits           = conn.LimitResults(filter, fc);
                var dataReaderResult = await conn.DataReaderAsync("select " + limits.top + fields + " from " + etconn.TableName + (String.IsNullOrEmpty(where) ? String.Empty : " WHERE " + where) + limits.limit);

                cursor._dbReader     = dataReaderResult.reader;
                cursor._dbConnection = dataReaderResult.connection;
            }

            return(cursor);
        }