Esempio n. 1
0
 /// <summary>
 /// Function to get a specific feature's geometry from the database.
 /// </summary>
 /// <param name="oid">The object id</param>
 /// <returns>A geometry</returns>
 protected virtual IGeometry GetGeometryByIDInternal(uint oid)
 {
     using (var cn = CreateOpenDbConnection())
     {
         using (var cmd = cn.CreateCommand())
         {
             cmd.CommandText = FeatureColumns.GetSelectColumnClause(cmd, ObjectIdColumn, oid);
             using (var dr = cmd.ExecuteReader())
             {
                 if (dr.HasRows)
                 {
                     var geometry = GeometryFromWKB.Parse((byte[])dr.GetValue(0), Factory);
                     return(geometry);
                 }
             }
         }
     }
     return(null);
 }
Esempio n. 2
0
 /// <summary>
 /// Function to get a specific feature's geometry from the database.
 /// </summary>
 /// <param name="oid">The object id</param>
 /// <returns>A geometry</returns>
 protected virtual IGeometry GetGeometryByIDInternal(uint oid)
 {
     using (var cn = CreateOpenDbConnection())
     {
         using (var cmd = cn.CreateCommand())
         {
             cmd.CommandText = FeatureColumns.GetSelectColumnClause(cmd, _geometryColumn, oid);
             Logger.Debug(t => t("Executing query:\n{0}", PrintCommand(cmd)));
             using (var dr = cmd.ExecuteReader())
             {
                 if (dr.HasRows)
                 {
                     while (dr.Read())
                     {
                         var geometry = GeometryFromWKB.Parse((byte[])dr.GetValue(0), Factory);
                         return(geometry);
                     }
                 }
             }
         }
     }
     return(null);
 }
Esempio n. 3
0
        /// <summary>
        /// Gets the object of features that lie within the specified <see cref="GeoAPI.Geometries.Envelope"/>
        /// </summary>
        /// <param name="bbox">The bounding box</param>
        /// <returns>A collection of object ids</returns>
        protected virtual Collection <uint> GetObjectIDsInViewInternal(Envelope bbox)
        {
            var res = new Collection <uint>();

            using (var cn = CreateOpenDbConnection())
            {
                using (var cmd = cn.CreateCommand())
                {
                    cmd.CommandText = FeatureColumns.GetSelectColumnClause(cmd, _dbUtility.DecorateEntity(ObjectIdColumn), GetSpatialWhere(bbox, cmd));
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                res.Add(Convert.ToUInt32(dr.GetValue(0)));
                            }
                        }
                    }
                }
            }
            return(res);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the geometries of features that lie within the specified <see cref="GeoAPI.Geometries.Envelope"/>
        /// </summary>
        /// <param name="bbox">The bounding box</param>
        /// <returns>Geometries within the specified <see cref="GeoAPI.Geometries.Envelope"/></returns>
        protected virtual Collection <IGeometry> GetGeometriesInViewInternal(Envelope bbox)
        {
            var res = new Collection <IGeometry>();

            using (var cn = CreateOpenDbConnection())
            {
                using (var cmd = cn.CreateCommand())
                {
                    cmd.CommandText = FeatureColumns.GetSelectColumnClause(cmd, FeatureColumns.GetGeometryColumn(true), GetSpatialWhere(bbox, cmd));
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                res.Add(GeometryFromWKB.Parse((byte[])dr.GetValue(0), Factory));
                            }
                        }
                    }
                }
            }
            return(res);
        }
Esempio n. 5
0
        /// <summary>
        /// Gets the object ids of features that lie within the specified <see cref="GeoAPI.Geometries.Envelope"/>
        /// </summary>
        /// <param name="bbox">The bounding box</param>
        /// <returns>A collection of object ids</returns>
        protected virtual IEnumerable <object> GetObjectIDsInViewInternal(Envelope bbox, CancellationToken?cancellationToken = null)
        {
            var res = new Collection <uint>();

            using (var cn = CreateOpenDbConnection())
            {
                using (var cmd = cn.CreateCommand())
                {
                    cmd.CommandText = FeatureColumns.GetSelectColumnClause(cmd, _oidColumn, GetSpatialWhere(bbox, cmd));
                    Logger.Debug(t => t("Executing query:\n{0}", PrintCommand(cmd)));
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                yield return(dr.GetValue(0));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the object ids of features that lie within the specified <see cref="GeoAPI.Geometries.Envelope"/>
        /// </summary>
        /// <param name="bbox">The bounding box</param>
        /// <returns>A collection of object ids</returns>
        protected virtual Collection <uint> GetObjectIDsInViewInternal(Envelope bbox)
        {
            var res = new Collection <uint>();

            using (var cn = CreateOpenDbConnection())
            {
                using (var cmd = cn.CreateCommand())
                {
                    cmd.CommandText = FeatureColumns.GetSelectColumnClause(cmd, _oidColumn, GetSpatialWhere(bbox, cmd));
                    Logger.Debug(t => t("Executing query:\n{0}", PrintCommand(cmd)));
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                res.Add(Convert.ToUInt32(dr.GetValue(0)));
                            }
                        }
                    }
                }
            }
            return(res);
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the geometries of features that lie within the specified <see cref="GeoAPI.Geometries.Envelope"/>
        /// </summary>
        /// <param name="bbox">The bounding box</param>
        /// <returns>Geometries within the specified <see cref="GeoAPI.Geometries.Envelope"/></returns>
        protected virtual Collection <IGeometry> GetGeometriesInViewInternal(Envelope bbox, CancellationToken?cancellationToken = null)
        {
            var res = new Collection <IGeometry>();

            using (var cn = CreateOpenDbConnection())
            {
                using (var cmd = cn.CreateCommand())
                {
                    cmd.CommandText = FeatureColumns.GetSelectColumnClause(cmd, _geometryColumn, GetSpatialWhere(bbox, cmd));
                    Logger.Debug(t => t("Executing query:\n{0}", PrintCommand(cmd)));
                    using (var dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                res.Add(GeometryFromWKB.Parse((byte[])dr.GetValue(0), Factory));
                            }
                        }
                    }
                }
            }
            return(res);
        }