Example #1
0
        /// <summary>
        /// Boundingbox of dataset
        /// </summary>
        /// <returns>boundingbox</returns>
        public GeoAPI.Geometries.IEnvelope GetExtents()
        {
            GeoAPI.Geometries.IEnvelope box = null;
            using (System.Data.OleDb.OleDbConnection conn = new OleDbConnection(_ConnectionString))
            {
                string strSQL = "Select Min(" + this.XColumn + ") as MinX, Min(" + this.YColumn + ") As MinY, " +
                                "Max(" + this.XColumn + ") As MaxX, Max(" + this.YColumn + ") As MaxY FROM " + this.Table;
                if (!String.IsNullOrEmpty(_defintionQuery))                 //If a definition query has been specified, add this as a filter on the query
                {
                    strSQL += " WHERE " + _defintionQuery;
                }

                using (System.Data.OleDb.OleDbCommand command = new OleDbCommand(strSQL, conn))
                {
                    conn.Open();
                    using (System.Data.OleDb.OleDbDataReader dr = command.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            //If the read row is OK, create a point geometry from the XColumn and YColumn and return it
                            if (dr[0] != DBNull.Value && dr[1] != DBNull.Value && dr[2] != DBNull.Value && dr[3] != DBNull.Value)
                            {
                                box = SharpMap.Converters.Geometries.GeometryFactory.CreateEnvelope((double)dr[0], (double)dr[1], (double)dr[2], (double)dr[3]);
                            }
                        }
                    }
                    conn.Close();
                }
            }
            return(box);
        }
Example #2
0
        /// <summary>
        /// Returns geometry Object IDs whose bounding box intersects 'bbox'
        /// </summary>
        /// <param name="bbox"></param>
        /// <returns></returns>
        public Collection <uint> GetObjectIDsInView(GeoAPI.Geometries.IEnvelope bbox)
        {
            Collection <uint> objectlist = new Collection <uint>();

            using (System.Data.OleDb.OleDbConnection conn = new OleDbConnection(_ConnectionString))
            {
                string strSQL = "Select " + this.ObjectIdColumn + " FROM " + this.Table + " WHERE ";
                if (!String.IsNullOrEmpty(_defintionQuery))
                {
                    strSQL += _defintionQuery + " AND ";
                }
                //Limit to the points within the boundingbox
                strSQL += this.XColumn + " BETWEEN " + bbox.MinX.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + bbox.MaxX.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + this.YColumn +
                          " BETWEEN " + bbox.MaxY.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + bbox.MinY.ToString(SharpMap.Map.numberFormat_EnUS);

                using (System.Data.OleDb.OleDbCommand command = new OleDbCommand(strSQL, conn))
                {
                    conn.Open();
                    using (System.Data.OleDb.OleDbDataReader dr = command.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (dr[0] != DBNull.Value)
                            {
                                objectlist.Add((uint)(int)dr[0]);
                            }
                        }
                    }
                    conn.Close();
                }
            }
            return(objectlist);
        }
Example #3
0
        /// <summary>
        /// Returns geometries within the specified bounding box
        /// </summary>
        /// <param name="bbox"></param>
        /// <returns></returns>
        public Collection <GeoAPI.Geometries.IGeometry> GetGeometriesInView(GeoAPI.Geometries.IEnvelope bbox)
        {
            Collection <GeoAPI.Geometries.IGeometry> features = new Collection <GeoAPI.Geometries.IGeometry>();

            using (System.Data.OleDb.OleDbConnection conn = new OleDbConnection(_ConnectionString))
            {
                string strSQL = "Select " + this.XColumn + ", " + this.YColumn + " FROM " + this.Table + " WHERE ";
                if (!String.IsNullOrEmpty(_defintionQuery))
                {
                    strSQL += _defintionQuery + " AND ";
                }
                //Limit to the points within the boundingbox
                strSQL += this.XColumn + " BETWEEN " + bbox.MinX.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + bbox.MaxX.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " +
                          this.YColumn + " BETWEEN " + bbox.MaxY.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + bbox.MinY.ToString(SharpMap.Map.numberFormat_EnUS);

                using (System.Data.OleDb.OleDbCommand command = new OleDbCommand(strSQL, conn))
                {
                    conn.Open();
                    using (System.Data.OleDb.OleDbDataReader dr = command.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            if (dr[0] != DBNull.Value && dr[1] != DBNull.Value)
                            {
                                features.Add(SharpMap.Converters.Geometries.GeometryFactory.CreatePoint((double)dr[0], (double)dr[1]));
                            }
                        }
                    }
                    conn.Close();
                }
            }
            return(features);
        }
Example #4
0
        /// <summary>
        /// Returns all features with the view box
        /// </summary>
        /// <param name="bbox">view box</param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        public void ExecuteIntersectionQuery(GeoAPI.Geometries.IEnvelope bbox, FeatureDataSet ds)
        {
            //List<Geometries.Geometry> features = new List<SharpMap.Geometries.Geometry>();
            using (System.Data.OleDb.OleDbConnection conn = new OleDbConnection(_ConnectionString))
            {
                string strSQL = "Select * FROM " + this.Table + " WHERE ";
                if (!String.IsNullOrEmpty(_defintionQuery))                 //If a definition query has been specified, add this as a filter on the query
                {
                    strSQL += _defintionQuery + " AND ";
                }
                //Limit to the points within the boundingbox
                strSQL += this.XColumn + " BETWEEN " + bbox.MinX.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + bbox.MaxX.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + this.YColumn +
                          " BETWEEN " + bbox.MaxY.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + bbox.MinY.ToString(SharpMap.Map.numberFormat_EnUS);

                using (System.Data.OleDb.OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL, conn))
                {
                    conn.Open();
                    System.Data.DataSet ds2 = new System.Data.DataSet();
                    adapter.Fill(ds2);
                    conn.Close();
                    if (ds2.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds2.Tables[0]);
                        foreach (System.Data.DataColumn col in ds2.Tables[0].Columns)
                        {
                            fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        }
                        foreach (System.Data.DataRow dr in ds2.Tables[0].Rows)
                        {
                            SharpMap.Data.FeatureDataRow fdr = fdt.NewRow();
                            foreach (System.Data.DataColumn col in ds2.Tables[0].Columns)
                            {
                                fdr[col.ColumnName] = dr[col];
                            }
                            if (dr[this.XColumn] != DBNull.Value && dr[this.YColumn] != DBNull.Value)
                            {
                                fdr.Geometry = SharpMap.Converters.Geometries.GeometryFactory.CreatePoint((double)dr[this.XColumn], (double)dr[this.YColumn]);
                            }
                            fdt.AddRow(fdr);
                        }
                        ds.Tables.Add(fdt);
                    }
                }
            }
        }
Example #5
0
 public void Init(GeoAPI.Geometries.IEnvelope env)
 {
     throw new NotImplementedException();
 }
Example #6
0
 public void ExpandToInclude(GeoAPI.Geometries.IEnvelope other)
 {
     throw new NotImplementedException();
 }
Example #7
0
 public double Distance(GeoAPI.Geometries.IEnvelope env)
 {
     throw new NotImplementedException();
 }
Example #8
0
 public bool Covers(GeoAPI.Geometries.IEnvelope other)
 {
     throw new NotImplementedException();
 }
Example #9
0
 public int CompareTo(GeoAPI.Geometries.IEnvelope other)
 {
     throw new NotImplementedException();
 }
Example #10
0
 public GeoAPI.Geometries.IEnvelope Union(GeoAPI.Geometries.IEnvelope box)
 {
     throw new NotImplementedException();
 }
Example #11
0
 public GeoAPI.Geometries.IEnvelope Intersection(GeoAPI.Geometries.IEnvelope env)
 {
     throw new NotImplementedException();
 }