Exemple #1
0
 public void Insert(int recordIndex, QTNodeHelper helper, System.IO.Stream shapeFileStream)
 {
     if (helper.IsPointData())
     {
         rootNode.Insert(recordIndex, helper, shapeFileStream);
     }
     else
     {
         RectangleD recBounds = helper.GetRecordBoundsD(recordIndex, shapeFileStream);
         //check for zero width or height to avoid issue when checking rectangle intersection
         //if width/height is zero
         if (recBounds.Width < 0.0000001)
         {
             recBounds.Width = 0.0000001;
         }
         if (recBounds.Height < 0.0000001)
         {
             recBounds.Height = 0.0000001;
         }
         rootNode.Insert(recordIndex, helper, ref recBounds, shapeFileStream);
     }
 }
Exemple #2
0
        public void Insert(int recordIndex, QTNodeHelper helper, System.IO.Stream shapeFileStream)
        {
            if (Level == MaxLevels)
            {
                indexList.Add(recordIndex);
            }
            else
            {
                if (helper.IsPointData())
                {
                    PointD pt = helper.GetRecordPoint(recordIndex, shapeFileStream);

                    if (children == null)
                    {
                        CreateChildren();
                    }

                    if (children[TL].Bounds.Contains(pt))
                    {
                        children[TL].Insert(recordIndex, helper, shapeFileStream);
                    }
                    if (children[TR].Bounds.Contains(pt))
                    {
                        children[TR].Insert(recordIndex, helper, shapeFileStream);
                    }
                    if (children[BL].Bounds.Contains(pt))
                    {
                        children[BL].Insert(recordIndex, helper, shapeFileStream);
                    }
                    if (children[BR].Bounds.Contains(pt))
                    {
                        children[BR].Insert(recordIndex, helper, shapeFileStream);
                    }
                    //else
                    //{
                    //    throw new InvalidOperationException("point " + pt + " is not contained in children bounds");
                    //}
                }
                else
                {
                    RectangleD recBounds = helper.GetRecordBoundsD(recordIndex, shapeFileStream);

                    if (children == null)
                    {
                        CreateChildren();
                    }
                    int c = 0;
                    if (children[TL].Bounds.IntersectsWith(recBounds))
                    {
                        c++;
                        children[TL].Insert(recordIndex, helper, shapeFileStream);
                    }
                    if (children[TR].Bounds.IntersectsWith(recBounds))
                    {
                        c++;
                        children[TR].Insert(recordIndex, helper, shapeFileStream);
                    }
                    if (children[BL].Bounds.IntersectsWith(recBounds))
                    {
                        c++;
                        children[BL].Insert(recordIndex, helper, shapeFileStream);
                    }
                    if (children[BR].Bounds.IntersectsWith(recBounds))
                    {
                        c++;
                        children[BR].Insert(recordIndex, helper, shapeFileStream);
                    }
                }
            }
        }