Beispiel #1
0
        /// <summary>
        /// Returns a <see cref="SharpMap.Data.FeatureDataRow"/> based on a RowID
        /// </summary>
        /// <param name="rowId"></param>
        /// <returns>datarow</returns>
        public FeatureDataRow GetFeature(uint rowId)
        {
            var fdt = CreateTable(_esriTable);

            fdt.BeginLoadData();
            var where = string.Format(CultureInfo.InvariantCulture, "{0}={1}", fdt.PrimaryKey[0].ColumnName, rowId);
            var fi = _esriTable.FieldInformation;

            foreach (var row in _esriTable.Search("*", where, Esri.FileGDB.RowInstance.Recycle))
            {
                var tmp = new List <object>(_esriTable.FieldInformation.Count - 1);
                for (var i = 0; i < fi.Count; i++)
                {
                    if (fi.GetFieldType(i) == Esri.FileGDB.FieldType.Geometry)
                    {
                        continue;
                    }
                    tmp.Add(row[fi.GetFieldName(i)]);
                }
                var fdr = (FeatureDataRow)fdt.LoadDataRow(tmp.ToArray(), true);
                fdr.Geometry = FileGdbGeometryConverter.ToSharpMapGeometry(row.GetGeometry());
            }
            fdt.EndLoadData();

            return((FeatureDataRow)fdt.Rows[0]);
        }
Beispiel #2
0
        /// <summary>
        /// Returns the data associated with all the geometries that are intersected by 'geom'
        /// </summary>
        /// <param name="box">Geometry to intersect with</param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        public void ExecuteIntersectionQuery(BoundingBox box, FeatureDataSet ds)
        {
            var fdt = CreateTable(_esriTable);

            fdt.BeginLoadData();
            var fi = _esriTable.FieldInformation;

            foreach (var row in _esriTable.Search("*", string.Empty, FileGdbGeometryConverter.ToEsriExtent(box), Esri.FileGDB.RowInstance.Recycle))
            {
                var tmp = new List <object>(_esriTable.FieldInformation.Count - 1);
                for (var i = 0; i < fi.Count; i++)
                {
                    if (fi.GetFieldType(i) == Esri.FileGDB.FieldType.Geometry)
                    {
                        continue;
                    }
                    tmp.Add(row[fi.GetFieldName(i)]);
                }
                var fdr = (FeatureDataRow)fdt.LoadDataRow(tmp.ToArray(), true);

                using (var buffer = row.GetGeometry())
                    fdr.Geometry = FileGdbGeometryConverter.ToSharpMapGeometry(buffer);
            }
            fdt.EndLoadData();
            ds.Tables.Add(fdt);
        }
Beispiel #3
0
        /// <summary>
        /// Returns all objects whose <see cref="SharpMap.Geometries.BoundingBox"/> intersects 'bbox'.
        /// </summary>
        /// <remarks>
        /// This method is usually much faster than the QueryFeatures method, because intersection tests
        /// are performed on objects simplifed by their <see cref="SharpMap.Geometries.BoundingBox"/>, and using the Spatial Index
        /// </remarks>
        /// <param name="bbox">Box that objects should intersect</param>
        /// <returns></returns>
        public Collection <uint> GetObjectIDsInView(BoundingBox bbox)
        {
            var res = new Collection <uint>();

            foreach (var row in _esriTable.Search(string.Empty, string.Empty, FileGdbGeometryConverter.ToEsriExtent(bbox), Esri.FileGDB.RowInstance.Recycle))
            {
                res.Add((uint)row.GetOID());
            }
            return(res);
        }
Beispiel #4
0
        /// <summary>
        /// Returns the geometry corresponding to the Object ID
        /// </summary>
        /// <param name="oid">Object ID</param>
        /// <returns>geometry</returns>
        public Geometry GetGeometryByID(uint oid)
        {
            var fdt = CreateTable(_esriTable);

            var where = string.Format(CultureInfo.InvariantCulture, "{0}={1}", fdt.PrimaryKey[0].ColumnName, oid);
            foreach (var row in _esriTable.Search("*", where, Esri.FileGDB.RowInstance.Recycle))
            {
                return(FileGdbGeometryConverter.ToSharpMapGeometry(row.GetGeometry()));
            }
            return(null);
        }
Beispiel #5
0
        /// <summary>
        /// Gets the features within the specified <see cref="SharpMap.Geometries.BoundingBox"/>
        /// </summary>
        /// <param name="bbox"></param>
        /// <returns>Features within the specified <see cref="SharpMap.Geometries.BoundingBox"/></returns>
        public Collection <Geometry> GetGeometriesInView(BoundingBox bbox)
        {
            var res = new Collection <Geometry>();

            foreach (var row in _esriTable.Search("*", string.Empty, FileGdbGeometryConverter.ToEsriExtent(bbox), Esri.FileGDB.RowInstance.Recycle))
            {
                using (var buffer = row.GetGeometry())
                {
                    var geom = FileGdbGeometryConverter.ToSharpMapGeometry(buffer);
                    if (geom != null)
                    {
                        res.Add(geom);
                    }
                }
            }
            return(res);
        }