Exemple #1
0
        /// <summary>
        /// Removes the feature with the specified index.
        /// </summary>
        /// <param name="index">Removes the feature from the specified index location.</param>
        public void RemoveAt(int index)
        {
            // Get shape range so we can update header smartly
            int         startIndex = index;
            IFeatureSet ifs        = Select(null, null, ref startIndex, 1);

            if (ifs.NumRows() > 0)
            {
                var shx = new ShapefileIndexFile();
                shx.Open(Filename);
                shx.Shapes.RemoveAt(index);
                shx.Save();

                AttributeTable dbf = GetAttributeTable(Filename);
                dbf.RemoveRowAt(index);
                if (_trackDeletedRows)
                {
                    _deletedRows = dbf.DeletedRows;
                }

                // Update extent in header if feature being deleted is NOT completely contained
                var hdr = new ShapefileHeader(Filename);

                Envelope featureEnv = ifs.GetFeature(0).Geometry.EnvelopeInternal;
                if (featureEnv.MinX <= hdr.Xmin || featureEnv.MaxX >= hdr.Xmax || featureEnv.MaxY >= hdr.Ymax || featureEnv.MinY <= hdr.Ymin)
                {
                    UpdateExtents();
                }

                // Update the Quadtree
                Quadtree?.Remove(featureEnv, index);
            }
        }
 /// <summary>
 /// Cache Index File in memory so we don't have to read it in every call to GetShapes
 /// </summary>
 /// <returns></returns>
 protected ShapefileIndexFile CacheShapeIndexFile()
 {
     if (null == _shx)
     {
         _shx = new ShapefileIndexFile();
         _shx.Open(Filename);
     }
     return(_shx);
 }
 /// <summary>
 /// Cache Index File in memory so we don't have to read it in every call to GetShapes
 /// </summary>
 /// <returns></returns>
 protected ShapefileIndexFile CacheShapeIndexFile()
 {
     if (null == _shx)
     {
         _shx = new ShapefileIndexFile();
         _shx.Open(Filename);
     }
     return _shx;
 }
        /// <inheritdocs/>
        public void RemoveAt(int index)
        {
            // Get shape range so we can update header smartly
            int startIndex = index;
            IFeatureSet ifs = Select(null, null, ref startIndex, 1);
            if (ifs.NumRows() > 0)
            {
                var shx = new ShapefileIndexFile();
                shx.Open(Filename);
                shx.Shapes.RemoveAt(index);
                shx.Save();

                AttributeTable dbf = GetAttributeTable(Filename);
                dbf.RemoveRowAt(index);
                if (_trackDeletedRows)
                    _deletedRows = dbf.DeletedRows;

                // Update extent in header if feature being deleted is NOT completely contained
                var hdr = new ShapefileHeader(Filename);

                IEnvelope featureEnv = ifs.GetFeature(0).Envelope;
                if (featureEnv.Left() <= hdr.Xmin || featureEnv.Right() >= hdr.Xmax || featureEnv.Top() >= hdr.Ymax || featureEnv.Bottom() <= hdr.Ymin)
                {
                    UpdateExtents();
                }

                // Update the Quadtree
                if (null != Quadtree)
                {
                    Quadtree.Remove(featureEnv, index);
                }
            }
        }