BoundingBox and Feature ID structure used for storing in the quadtree
Beispiel #1
0
        /// <summary>
        /// Generates a spatial index for a specified shape file.
        /// </summary>
        /// <param name="filename"></param>
        private QuadTree CreateSpatialIndex(string filename)
        {
            List<QuadTree.BoxObjects> objList = new List<QuadTree.BoxObjects>();
            //Convert all the geometries to boundingboxes 
            uint i = 0;
            foreach (BoundingBox box in GetAllFeatureBoundingBoxes())
            {
                if (!double.IsNaN(box.Left) && !double.IsNaN(box.Right) && !double.IsNaN(box.Bottom) &&
                    !double.IsNaN(box.Top))
                {
                    QuadTree.BoxObjects g = new QuadTree.BoxObjects();
                    g.box = box;
                    g.ID = i;
                    objList.Add(g);
                    i++;
                }
            }

            Heuristic heur;
            heur.maxdepth = (int) Math.Ceiling(Math.Log(GetFeatureCount(), 2));
            heur.minerror = 10;
            heur.tartricnt = 5;
            heur.mintricnt = 2;
            return new QuadTree(objList, 0, heur);
        }
        /// <summary>
        /// Generates a spatial index for a specified shape file.
        /// </summary>
        private QuadTree CreateSpatialIndex(IEnvelope envelop)
        {
            var objList = new List<QuadTree.BoxObjects>();
            uint i = 0;
            foreach (BoundingBox box in GetAllFeatureBoundingBoxes(envelop))
            {
                if (!double.IsNaN(box.Left) && !double.IsNaN(box.Right) && !double.IsNaN(box.Bottom) &&
                    !double.IsNaN(box.Top))
                {
                    var g = new QuadTree.BoxObjects { box = box, ID = i, Data = new IndexEntry { Box = box, Data = new DynamicRTree() } };
                    objList.Add(g);
                    i++;
                }
            }

            Heuristic heur;
            heur.maxdepth = (int)Math.Ceiling(Math.Log(objList.Count, 2));
            heur.minerror = 10;
            heur.tartricnt = 5;
            heur.mintricnt = 2;

            return new QuadTree(objList, 0, heur);
        }